From: Ben Pfaff Date: Thu, 1 Jan 2009 00:13:33 +0000 (-0800) Subject: vswitchd: Prevent a single interface from being added to two different ports. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e287d46f6086286c1f64f2e6c06a04f0adb33e09;p=openvswitch vswitchd: Prevent a single interface from being added to two different ports. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 21c4a51d..81806d97 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -775,10 +775,10 @@ bridge_run_one(struct bridge *br) static void bridge_reconfigure_one(struct bridge *br) { - struct svec old_ports, new_ports; + struct svec old_ports, new_ports, ifaces; const char *controller; + size_t i, j; char *ctl; - size_t i; /* Collect old and new ports. */ svec_init(&old_ports); @@ -813,6 +813,31 @@ bridge_reconfigure_one(struct bridge *br) port_reconfigure(br->ports[i]); } + /* Check and delete duplicate interfaces. */ + svec_init(&ifaces); + for (i = 0; i < br->n_ports; ) { + struct port *port = br->ports[i]; + for (j = 0; j < port->n_ifaces; ) { + struct iface *iface = port->ifaces[j]; + if (svec_contains(&ifaces, iface->name)) { + VLOG_ERR("bridge %s: %s interface is on multiple ports, " + "removing from %s", + br->name, iface->name, port->name); + iface_destroy(iface); + } else { + svec_add(&ifaces, iface->name); + svec_sort(&ifaces); + j++; + } + } + if (!port->n_ifaces) { + VLOG_ERR("%s port has no interfaces, dropping", port->name); + port_destroy(port); + } else { + i++; + } + } + /* Configure remote controller. */ controller = cfg_get_string(0, "bridge.%s.controller", br->name); ctl = controller ? xstrdup(controller) : NULL;