[ovs-dev] [PATCH] vswitchd: Avoid segfault when local port is required but missing.

Ben Pfaff blp at nicira.com
Mon Dec 7 13:03:14 PST 2009


Connecting to a controller requires the vswitch to have a local port
(typically named the same as the bridge itself).  Before the introduction
of ovsdb ovs-vswitchd simply added the local port itself if it was missing.
This was not properly implemented with the ovsdb transition, and a segfault
resulted.  This commit avoids the segfault, although it should possibly
be improved to also add the local port, as before.

CC: Jeremy Stribling <strib at nicira.com>
---
 vswitchd/bridge.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index d7f4d32..f3512a0 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1253,14 +1253,21 @@ bridge_reconfigure_one(const struct ovsrec_open_vswitch *ovs_cfg,
                       br->name, name);
         }
     }
+
+    /* If we have a controller, then we need a local port.  Complain if the
+     * user didn't specify one.
+     *
+     * XXX perhaps we should synthesize a port ourselves in this case. */
     if (bridge_get_controller(ovs_cfg, br)) {
         char local_name[IF_NAMESIZE];
         int error;
 
         error = dpif_port_get_name(br->dpif, ODPP_LOCAL,
                                    local_name, sizeof local_name);
-        if (!error) {
-            shash_add_once(&new_ports, local_name, NULL);
+        if (!error && !shash_find(&new_ports, local_name)) {
+            VLOG_WARN("bridge %s: controller specified but no local port "
+                      "(port named %s) defined",
+                      br->name, local_name);
         }
     }
 
-- 
1.6.3.3





More information about the dev mailing list