flow: Zero tun_id if wildcarded.
authorJesse Gross <jesse@nicira.com>
Tue, 11 May 2010 01:23:18 +0000 (18:23 -0700)
committerJesse Gross <jesse@nicira.com>
Tue, 11 May 2010 01:23:18 +0000 (18:23 -0700)
Normally match fields are zeroed if they are wildcarded in
normalize_match().  However, tun_id isn't part of struct ofp_match
so do it when we convert to a flow instead.

lib/flow.c

index 38ad72abcb5906f20383fa23af4bf17a06df5f70..7ae90d2b56f8c7210238aeaf4cbc33ca11f800fa 100644 (file)
@@ -273,20 +273,16 @@ flow_to_match(const flow_t *flow, uint32_t wildcards, bool tun_id_from_cookie,
 
 void
 flow_from_match(const struct ofp_match *match, bool tun_id_from_cookie,
-                uint64_t cookie, flow_t *flow, uint32_t *wildcards)
+                uint64_t cookie, flow_t *flow, uint32_t *flow_wildcards)
 {
-    if (wildcards) {
-        *wildcards = ntohl(match->wildcards);
+       uint32_t wildcards = ntohl(match->wildcards);
 
-        if (!tun_id_from_cookie) {
-            *wildcards |= NXFW_TUN_ID;
-        }
-    }
     flow->nw_src = match->nw_src;
     flow->nw_dst = match->nw_dst;
-    if (tun_id_from_cookie) {
+    if (tun_id_from_cookie && !(wildcards & NXFW_TUN_ID)) {
         flow->tun_id = htonl(ntohll(cookie) >> 32);
     } else {
+        wildcards |= NXFW_TUN_ID;
         flow->tun_id = 0;
     }
     flow->in_port = (match->in_port == htons(OFPP_LOCAL) ? ODPP_LOCAL
@@ -301,6 +297,10 @@ flow_from_match(const struct ofp_match *match, bool tun_id_from_cookie,
     flow->nw_tos = match->nw_tos;
     flow->nw_proto = match->nw_proto;
     memset(flow->reserved, 0, sizeof flow->reserved);
+
+    if (flow_wildcards) {
+        *flow_wildcards = wildcards;
+    }
 }
 
 char *