diff mbox

[ovs-dev,5/6] Update ovn-controller flow generation to use physical endpoints encap

Message ID 1458159951-21345-6-git-send-email-dball@vmware.com
State Deferred
Headers show

Commit Message

Darrell Ball March 16, 2016, 8:25 p.m. UTC
Signed-off-by: Darrell Ball <dball@vmware.com>
---
 ovn/controller/physical.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index 657c3e2..5156a9b 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -231,6 +231,7 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
     /* Set up flows in table 0 for physical-to-logical translation and in table
      * 64 for logical-to-physical translation. */
     const struct sbrec_port_binding *binding;
+    const struct sbrec_physical_endpoint * phys_endpt_rec;
     SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) {
         /* Find the OpenFlow port for the logical port, as 'ofport'.  This is
          * one of:
@@ -267,8 +268,28 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
         } else {
             ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
                                           binding->logical_port));
-            if (!strcmp(binding->type, "localnet") && ofport && binding->tag) {
-                tag = *binding->tag;
+
+            /* For localnet and gw logical ports without phys_endpt
+             * binding, a tag of 0 is the default */
+
+            /* gw logical port type added for illustrative purposes
+             * in this patch  */
+
+            if ((!strcmp(binding->type, "localnet") ||
+                (!strcmp(binding->type, "gw"))) && ofport &&
+                 binding->phys_endpts) {
+
+                /* Use any phys_endpt for localnet if shared port
+                 * name; if localnet port is unique name, then there is a
+                 * single phys_endpt.
+                 * gw logical ports have a single phys_endpt */
+                phys_endpt_rec = binding->phys_endpts[0];
+
+                /* only single vlan encap is supported initially */
+                if (phys_endpt_rec && (!strcmp(phys_endpt_rec->type, "vlan"))) {
+                    /* valid values verified on configuration */
+                    (void) str_to_int(phys_endpt_rec->ingress_encap, 10, &tag);
+                }
             }
         }
 
@@ -326,7 +347,13 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
             /* Match a VLAN tag and strip it, including stripping priority tags
              * (e.g. VLAN ID 0).  In the latter case we'll add a second flow
              * for frames that lack any 802.1Q header later. */
-            if (tag || !strcmp(binding->type, "localnet")) {
+
+            /* gw logical port type added for illustrative purposes
+             * in this patch */
+            if (tag ||
+                (!strcmp(binding->type, "localnet")) ||
+                (!strcmp(binding->type, "gw"))) {
+
                 match_set_dl_vlan(&match, htons(tag));
                 ofpact_put_STRIP_VLAN(&ofpacts);
             }
@@ -350,7 +377,13 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
             ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG,
                             tag ? 150 : 100, &match, &ofpacts);
 
-            if (!tag && !strcmp(binding->type, "localnet")) {
+            /* gw logical port type added for illustrative purposes
+             * in this patch
+             */
+            if (!tag &&
+                    ((!strcmp(binding->type, "localnet")) ||
+                     (!strcmp(binding->type, "gw")))) {
+
                 /* Add a second flow for frames that lack any 802.1Q
                  * header.  For these, drop the OFPACT_STRIP_VLAN
                  * action. */
@@ -648,6 +681,7 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
      * xxx Due to resubmitting to table 16, broadcasts will be re-sent to
      * xxx all logical ports, including non-local ones which could cause
      * xxx duplicate packets to be received by multiply-connected gateways. */
+
     HMAP_FOR_EACH (tun, hmap_node, &tunnels) {
         if (tun->type != VXLAN) {
             continue;