vswitchd: Create all interfaces at the same time.
authorBen Pfaff <blp@nicira.com>
Mon, 27 Sep 2010 18:39:41 +0000 (11:39 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 11 Oct 2010 17:40:05 +0000 (10:40 -0700)
It seems inconsistent to create some early, some late.  I hope that
this helps to clarify what is happening.

vswitchd/bridge.c

index 5210da1..472cddf 100644 (file)
@@ -684,12 +684,21 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
                     reconfigure_iface_netdev(iface);
                 }
             } else {
-                /* Need to add to datapath. */
                 bool internal;
                 int error;
 
-                /* Add to datapath. */
+                /* Create interface if it doesn't already exist. */
                 internal = iface_is_internal(br, if_name);
+                if (!internal) {
+                    error = create_iface_netdev(iface);
+                    if (error) {
+                        VLOG_WARN("could not create iface %s: %s", iface->name,
+                                  strerror(error));
+                    }
+                    continue;
+                }
+
+                /* Add to datapath. */
                 error = dpif_port_add(br->dpif, if_name,
                                       internal ? ODP_PORT_INTERNAL : 0, NULL);
                 if (error == EFBIG) {
@@ -3692,7 +3701,6 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg)
     struct bridge *br = port->bridge;
     struct iface *iface;
     char *name = if_cfg->name;
-    int error;
 
     iface = xzalloc(sizeof *iface);
     iface->port = port;
@@ -3706,20 +3714,6 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg)
 
     shash_add_assert(&br->iface_by_name, iface->name, iface);
 
-    /* Attempt to create the network interface in case it doesn't exist yet. */
-    if (!iface_is_internal(br, iface->name)) {
-        error = create_iface_netdev(iface);
-        if (error) {
-            VLOG_WARN("could not create iface %s: %s", iface->name,
-                      strerror(error));
-
-            shash_find_and_delete_assert(&br->iface_by_name, iface->name);
-            free(iface->name);
-            free(iface);
-            return NULL;
-        }
-    }
-
     if (port->n_ifaces >= port->allocated_ifaces) {
         port->ifaces = x2nrealloc(port->ifaces, &port->allocated_ifaces,
                                   sizeof *port->ifaces);