size_t i, j;
char *ctl, *pfx;
- /* Collect old and new ports. */
+ /* Decide on remote controller. */
+ pfx = xasprintf("bridge.%s.controller", br->name);
+ controller = cfg_get_string(0, "%s", pfx);
+ ctl = controller ? xstrdup(controller) : NULL;
+
+ /* Collect old ports. */
svec_init(&old_ports);
- svec_init(&new_ports);
for (i = 0; i < br->n_ports; i++) {
svec_add(&old_ports, br->ports[i]->name);
}
- cfg_get_all_keys(&new_ports, "bridge.%s.port", br->name);
-
- ofproto_set_mgmt_id(br->ofproto, mgmt_id);
-
- /* Get rid of deleted ports and add new ports. */
svec_sort(&old_ports);
assert(svec_is_unique(&old_ports));
+
+ /* Collect new ports. */
+ svec_init(&new_ports);
+ cfg_get_all_keys(&new_ports, "bridge.%s.port", br->name);
svec_sort(&new_ports);
+ if (ctl && !svec_contains(&new_ports, br->name)) {
+ svec_add(&new_ports, br->name);
+ svec_sort(&new_ports);
+ }
if (!svec_is_unique(&new_ports)) {
VLOG_WARN("bridge %s: %s specified twice as bridge port",
br->name, svec_get_duplicate(&new_ports));
svec_unique(&new_ports);
}
+
+ ofproto_set_mgmt_id(br->ofproto, mgmt_id);
+
+ /* Get rid of deleted ports and add new ports. */
for (i = 0; i < br->n_ports; ) {
struct port *port = br->ports[i];
if (!svec_contains(&new_ports, port->name)) {
}
svec_destroy(&ifaces);
- /* Configure remote controller. */
- pfx = xasprintf("bridge.%s.controller", br->name);
- controller = cfg_get_string(0, "%s", pfx);
- ctl = controller ? xstrdup(controller) : NULL;
-
/* If a controller is not specified for the bridge, try using the
* management channel's settings. */
if (!ctl) {