ovn-controller: Fix invalid br_int_name handling.
authorRussell Bryant <rbryant@redhat.com>
Fri, 1 May 2015 18:22:01 +0000 (14:22 -0400)
committerJustin Pettit <jpettit@nicira.com>
Fri, 1 May 2015 21:56:41 +0000 (14:56 -0700)
While doing some testing, I noticed the following error message:

  Integration bridge '<garbage>' dissapeared

The reason is that the code kept around the value of the "ovn-bridge"
configuration without copying it.  The result was pointing to bogus
memory.  You would only see this if you set "ovn_bridge".  If you
relied on the default, the bug would not occur.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Acked-by: Kyle Mestery <mestery@mestery.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
ovn/controller/ovn-controller.c
ovn/controller/ovn-controller.h

index 477ad0a..778dd43 100644 (file)
@@ -102,14 +102,15 @@ get_core_config(struct controller_ctx *ctx)
 
     while (1) {
         const struct ovsrec_bridge *br_int;
-        const char *remote, *system_id;
+        const char *remote, *system_id, *br_int_name;
 
         ovsdb_idl_run(ctx->ovs_idl);
 
-        ctx->br_int_name = smap_get(&cfg->external_ids, "ovn-bridge");
-        if (!ctx->br_int_name) {
-            ctx->br_int_name = DEFAULT_BRIDGE_NAME;
+        br_int_name = smap_get(&cfg->external_ids, "ovn-bridge");
+        if (!br_int_name) {
+            br_int_name = DEFAULT_BRIDGE_NAME;
         }
+        ctx->br_int_name = xstrdup(br_int_name);
 
         br_int = get_bridge(ctx, ctx->br_int_name);
         if (!br_int) {
@@ -240,6 +241,8 @@ main(int argc, char *argv[])
     ovsdb_idl_destroy(ctx.ovs_idl);
     ovsdb_idl_destroy(ctx.ovnsb_idl);
 
+    free(ctx.br_int_name);
+
     exit(retval);
 }
 
index 9d2fb39..a1630f7 100644 (file)
@@ -19,7 +19,7 @@
 
 struct controller_ctx {
     char *chassis_id;               /* ID for this chassis. */
-    const char *br_int_name;        /* Name of local integration bridge. */
+    char *br_int_name;              /* Name of local integration bridge. */
     struct ovsdb_idl *ovnsb_idl;
     struct ovsdb_idl *ovs_idl;