[ovs-dev,04/10] userspace: Handling of versatile tunnel ports

Submitted by Zoltán Balogh on April 18, 2017, 11:20 a.m.

Details

Message ID AM2PR07MB1042EE3CDCA287FC533E6EDC8A190@AM2PR07MB1042.eurprd07.prod.outlook.com
State Deferred
Headers show

Commit Message

Zoltán Balogh April 18, 2017, 11:20 a.m.
From: Jan Scheurich <jan.scheurich@ericsson.com>

Not yet fully functional in this commit.

Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
---
 ofproto/ofproto-dpif-xlate.c |  2 +-
 ofproto/tunnel.c             | 21 ++++++++++++++++-----
 ofproto/tunnel.h             |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 6dd8a07..5039758 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -6162,7 +6162,7 @@  xlate_wc_init(struct xlate_ctx *ctx)
         netflow_mask_wc(&ctx->xin->flow, ctx->wc);
     }
 
-    tnl_wc_init(&ctx->xin->flow, ctx->wc);
+    tnl_wc_init(&ctx->xin->flow, ctx->wc, ctx->xbridge->packet_type_aware);
 }
 
 static void
diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c
index 0da4f42..0aca81f 100644
--- a/ofproto/tunnel.c
+++ b/ofproto/tunnel.c
@@ -361,7 +361,8 @@  tnl_process_ecn(struct flow *flow)
 }
 
 void
-tnl_wc_init(struct flow *flow, struct flow_wildcards *wc)
+tnl_wc_init(struct flow *flow, struct flow_wildcards *wc,
+            bool packet_type_aware)
 {
     if (tnl_port_should_receive(flow)) {
         wc->masks.tunnel.tun_id = OVS_BE64_MAX;
@@ -386,8 +387,10 @@  tnl_wc_init(struct flow *flow, struct flow_wildcards *wc)
             && IP_ECN_is_ce(flow->tunnel.ip_tos)) {
             wc->masks.nw_tos |= IP_ECN_MASK;
         }
-        /* Match on packet_type for tunneled packets.*/
-        wc->masks.packet_type = OVS_BE32_MAX;
+        if (!packet_type_aware) {
+            /* Match on packet_type for tunneled packets.*/
+            wc->masks.packet_type = OVS_BE32_MAX;
+        }
     }
 }
 
@@ -566,8 +569,16 @@  tnl_find(const struct flow *flow) OVS_REQ_RDLOCK(rwlock)
                     match.in_key_flow = in_key_flow;
                     match.ip_dst_flow = ip_dst_flow;
                     match.ip_src_flow = ip_src == IP_SRC_FLOW;
-                    match.is_layer3 = flow->packet_type != htonl(PT_ETH);
-
+                    if (pt_ns(flow->packet_type) == OFPHTN_ETHERTYPE) {
+                        /* Try to find a layer3 port first. */
+                        match.is_layer3 = true;
+                        tnl_port = tnl_find_exact(&match, map);
+                        if (tnl_port) {
+                            return tnl_port;
+                        }
+                    }
+                    /* Check for a non-layer3 or versatile tunnel port. */
+                    match.is_layer3 = false;
                     tnl_port = tnl_find_exact(&match, map);
                     if (tnl_port) {
                         return tnl_port;
diff --git a/ofproto/tunnel.h b/ofproto/tunnel.h
index b0ec67c..dc004cc 100644
--- a/ofproto/tunnel.h
+++ b/ofproto/tunnel.h
@@ -39,7 +39,7 @@  int tnl_port_add(const struct ofport_dpif *, const struct netdev *,
 void tnl_port_del(const struct ofport_dpif *);
 
 const struct ofport_dpif *tnl_port_receive(const struct flow *);
-void tnl_wc_init(struct flow *, struct flow_wildcards *);
+void tnl_wc_init(struct flow *, struct flow_wildcards *, bool);
 bool tnl_process_ecn(struct flow *);
 odp_port_t tnl_port_send(const struct ofport_dpif *, struct flow *,
                          struct flow_wildcards *wc);