/* Modify the existing configuration according to 'act'. The configuration
* file will be modified to reflect these changes. The caller is
- * responsible for causing vswitchd to actually re-read its configuration. */
-void
+ * responsible for causing vswitchd to actually re-read its configuration.
+ * Returns 0 on success, otherwise a postive errno. */
+int
brc_modify_config(const char *dp_name, const char *port_name,
enum bmc_action act)
{
if (!brc_enabled) {
- return;
+ return 0;
}
if (cfg_lock(NULL)) {
/* Couldn't lock config file. */
- /* xxx Handle this better */
- return;
+ return EAGAIN;
}
switch (act) {
cfg_write();
cfg_unlock();
+
+ return 0;
}
static int
brc_add_dp(const char *dp_name)
{
+ int retval;
+
if (bridge_exists(dp_name)) {
return EEXIST;
}
- brc_modify_config(dp_name, NULL, BMC_ADD_DP);
+ retval = brc_modify_config(dp_name, NULL, BMC_ADD_DP);
+ if (retval) {
+ return retval;
+ }
reconfigure();
static int
brc_del_dp(const char *dp_name)
{
+ int retval;
+
if (!bridge_exists(dp_name)) {
return ENXIO;
}
- brc_modify_config(dp_name, NULL, BMC_DEL_DP);
+ retval = brc_modify_config(dp_name, NULL, BMC_DEL_DP);
+ if (retval) {
+ return retval;
+ }
reconfigure();
{
struct nlattr *attrs[ARRAY_SIZE(brc_port_policy)];
const char *dp_name, *port_name;
+ int retval;
if (!nl_policy_parse(buffer, NLMSG_HDRLEN + GENL_HDRLEN, brc_port_policy,
attrs, ARRAY_SIZE(brc_port_policy))) {
}
if (add) {
- brc_modify_config(dp_name, port_name, BMC_ADD_PORT);
+ retval = brc_modify_config(dp_name, port_name, BMC_ADD_PORT);
} else {
- brc_modify_config(dp_name, port_name, BMC_DEL_PORT);
+ retval = brc_modify_config(dp_name, port_name, BMC_DEL_PORT);
+ }
+ if (retval) {
+ return retval;
}
/* Force vswitchd to reconfigure itself. */