ovs-vsctl: Create AutoAttach records on demand, for backward compatibility.
authorBen Pfaff <blp@nicira.com>
Fri, 20 Mar 2015 06:22:05 +0000 (23:22 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 20 Mar 2015 07:25:13 +0000 (00:25 -0700)
The AutoAttach table is new in OVS 2.3.90, but ovs-vsctl was creating a
record in the table unconditionally whenever it created a new bridge.
This caused a gratuitous incompatibility with older databases, which can
be a problem during upgrade.  This commit switches to creating the
AutoAttaach record for a bridge lazily, only when the first mapping is
created for the bridge.

VMware-BZ: #1413562
CC: Dennis Flynn <drflynn@avaya.com>
Reported-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
utilities/ovs-vsctl.c

index 1abefb4..fa73b00 100644 (file)
@@ -1807,7 +1807,6 @@ cmd_add_br(struct vsctl_context *ctx)
 
     if (!parent_name) {
         struct ovsrec_port *port;
-        struct ovsrec_autoattach *aa;
         struct ovsrec_bridge *br;
 
         iface = ovsrec_interface_insert(ctx->txn);
@@ -1818,12 +1817,9 @@ cmd_add_br(struct vsctl_context *ctx)
         ovsrec_port_set_name(port, br_name);
         ovsrec_port_set_interfaces(port, &iface, 1);
 
-        aa = ovsrec_autoattach_insert(ctx->txn);
-
         br = ovsrec_bridge_insert(ctx->txn);
         ovsrec_bridge_set_name(br, br_name);
         ovsrec_bridge_set_ports(br, &port, 1);
-        ovsrec_bridge_set_auto_attach(br, aa);
 
         ovs_insert_bridge(ctx->ovs, br);
     } else {
@@ -2732,6 +2728,10 @@ cmd_add_aa_mapping(struct vsctl_context *ctx)
     }
 
     if (br && br->br_cfg) {
+        if (!br->br_cfg->auto_attach) {
+            struct ovsrec_autoattach *aa = ovsrec_autoattach_insert(ctx->txn);
+            ovsrec_bridge_set_auto_attach(br->br_cfg, aa);
+        }
         autoattach_insert_mapping(br->br_cfg->auto_attach, isid, vlan);
     }
 }