ovn: Support l2gateway-chassis option in "l2gateway" logical ports
authorNuman Siddique <nusiddiq@redhat.com>
Fri, 8 Jul 2016 11:37:37 +0000 (17:07 +0530)
committerRussell Bryant <russell@ovn.org>
Fri, 8 Jul 2016 14:56:17 +0000 (10:56 -0400)
ovn-controller will now bind the l2gateway logical ports.

Signed-Off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
ovn/TODO
ovn/controller/binding.c
ovn/ovn-nb.xml
ovn/ovn-sb.xml
tests/ovn.at

index 3f358c2..4f134a4 100644 (file)
--- a/ovn/TODO
+++ b/ovn/TODO
@@ -247,14 +247,3 @@ large.
 ** Support reject action.
 
 ** Support log option.
-
-* Software L2 gateway
-
-** Support "chassis" option in Logical_Switch_Port with type of "l2gateway".
-
-   Right now an "l2gateway" port is bound to a chassis by setting the "chassis"
-   column of the port binding in the southbound database directly.  We should
-   support a "chassis" option in the "options" column of the
-   "Logical_Switch_Port" in the northbound database.  This would bring
-   "l2gateway" into alignment with how chassis binding is done for L3 gateways
-   (a "chassis" option for Logical_Router).
index 4e5c1df..4704226 100644 (file)
@@ -222,16 +222,30 @@ consider_local_datapath(struct controller_ctx *ctx, struct shash *lports,
             }
             sbrec_port_binding_set_chassis(binding_rec, chassis_rec);
         }
-    } else if (!strcmp(binding_rec->type, "l2gateway")
-               && binding_rec->chassis == chassis_rec) {
-        /* A locally bound L2 gateway port.
-         *
-         * ovn-controller does not bind gateway ports itself.
-         * Choosing a chassis for a gateway port is left
-         * up to an entity external to OVN. */
-        sset_add(&all_lports, binding_rec->logical_port);
-        add_local_datapath(local_datapaths, binding_rec,
-                           &binding_rec->header_.uuid);
+    } else if (!strcmp(binding_rec->type, "l2gateway")) {
+        const char *chassis_id = smap_get(&binding_rec->options,
+                                          "l2gateway-chassis");
+        if (!chassis_id || strcmp(chassis_id, chassis_rec->name)) {
+            if (binding_rec->chassis == chassis_rec && ctx->ovnsb_idl_txn) {
+                VLOG_INFO("Releasing l2gateway port %s from this chassis.",
+                          binding_rec->logical_port);
+                sbrec_port_binding_set_chassis(binding_rec, NULL);
+            }
+            return;
+        }
+
+        if (binding_rec->chassis == chassis_rec) {
+            return;
+        }
+
+        if (!strcmp(chassis_id, chassis_rec->name) && ctx->ovnsb_idl_txn) {
+            VLOG_INFO("Claiming l2gateway port %s for this chassis.",
+                      binding_rec->logical_port);
+            sbrec_port_binding_set_chassis(binding_rec, chassis_rec);
+            sset_add(&all_lports, binding_rec->logical_port);
+            add_local_datapath(local_datapaths, binding_rec,
+                               &binding_rec->header_.uuid);
+        }
     } else if (chassis_rec && binding_rec->chassis == chassis_rec
                && strcmp(binding_rec->type, "gateway")) {
         if (ctx->ovnsb_idl_txn) {
index ff2e695..5542ea4 100644 (file)
           uses its local configuration to determine exactly how to connect to
           this network.
         </column>
+
+        <column name="options" key="l2gateway-chassis">
+          Required. The chassis on which the <code>l2gateway</code> logical
+          port should be bound to. <code>ovn-controller</code> running on the
+          defined chassis will connect this logical port to the physical network.
+        </column>
+
       </group>
 
       <group title="Options for vtep ports">
index 759513f..9628256 100644 (file)
@@ -1476,8 +1476,8 @@ tcp.flags = RST;
           <dd>
             The physical location of this L2 gateway.  To successfully identify a
             chassis, this column must be a <ref table="Chassis"/> record.
-            This is populated by an entity external to OVN, either manually or by
-            a CMS.
+            This is populated by <code>ovn-controller</code> based on the value
+            of the <code>options:l2gateway-chassis</code> column in this table.
           </dd>
         </dl>
 
@@ -1657,6 +1657,10 @@ tcp.flags = RST;
         </p>
       </column>
 
+      <column name="options" key="l2gateway-chassis">
+        Required. The <code>chassis</code> in which the port resides.
+      </column>
+
       <column name="tag">
         If set, indicates that the gateway is connected to a specific
         VLAN on the physical network. The VLAN ID is used to match
index 3f2e779..b28c90e 100644 (file)
@@ -1325,7 +1325,7 @@ ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02
 
 ovn-nbctl lsp-add lsw0 lp-gw
 ovn-nbctl lsp-set-type lp-gw l2gateway
-ovn-nbctl lsp-set-options lp-gw network_name=physnet1
+ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw
 ovn-nbctl lsp-set-addresses lp-gw unknown
 
 net_add n1               # Network to connect hv1, hv2, and gw
@@ -1355,9 +1355,6 @@ ovs-vsctl add-br br-phys2
 net_attach n2 br-phys2
 ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2"
 
-# Bind our gateway port to the hv_gw chassis
-ovn-sbctl lsp-bind lp-gw hv_gw
-
 # Add hv3 on the other side of the GW
 sim_add hv3
 as hv3