This patch adds a new function flow_unildcard_tp_ports() which doesn't
unwildcard the upper half of tp_src and tp_dst with ICMP packets.
Unfortunately, this matters in future patches when we compare masks
carefully to determine if flows should be evicted from the datapath.

Signed-off-by: Ethan Jackson <et...@nicira.com>
---
 lib/flow.c        | 15 +++++++++++++--
 lib/flow.h        |  1 +
 ofproto/netflow.c |  3 +--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 3633dff..8f80f88 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -519,6 +519,18 @@ flow_zero_wildcards(struct flow *flow, const struct 
flow_wildcards *wildcards)
     }
 }
 
+void
+flow_unwildcard_tp_ports(const struct flow *flow, struct flow_wildcards *wc)
+{
+    if (flow->nw_proto != IPPROTO_ICMP) {
+        memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
+        memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+    } else {
+        wc->masks.tp_src = htons(0xff);
+        wc->masks.tp_dst = htons(0xff);
+    }
+}
+
 /* Initializes 'fmd' with the metadata found in 'flow'. */
 void
 flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd)
@@ -922,8 +934,7 @@ flow_mask_hash_fields(const struct flow *flow, struct 
flow_wildcards *wc,
         }
         if (is_ip_any(flow)) {
             memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
-            memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
-            memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+            flow_unwildcard_tp_ports(flow, wc);
         }
         wc->masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
         break;
diff --git a/lib/flow.h b/lib/flow.h
index 44d96ad..a828b66 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -174,6 +174,7 @@ void flow_extract(struct ofpbuf *, uint32_t priority, 
uint32_t mark,
                   struct flow *);
 
 void flow_zero_wildcards(struct flow *, const struct flow_wildcards *);
+void flow_unwildcard_tp_ports(const struct flow *, struct flow_wildcards *);
 void flow_get_metadata(const struct flow *, struct flow_metadata *);
 
 char *flow_to_string(const struct flow *);
diff --git a/ofproto/netflow.c b/ofproto/netflow.c
index 7b9e0e6..f79ad6a 100644
--- a/ofproto/netflow.c
+++ b/ofproto/netflow.c
@@ -98,8 +98,7 @@ netflow_mask_wc(struct flow *flow, struct flow_wildcards *wc)
     memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
     memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
     memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
-    memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
-    memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+    flow_unwildcard_tp_ports(flow, wc);
     wc->masks.nw_tos |= IP_DSCP_MASK;
 }
 
-- 
1.8.1.2

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to