flow: Ensure that padding is always zeroed.
authorBen Pfaff <blp@nicira.com>
Mon, 18 Jun 2012 22:09:49 +0000 (15:09 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 4 Sep 2012 18:19:15 +0000 (11:19 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/flow.h
lib/ofp-util.c
tests/test-bundle.c
tests/test-classifier.c
tests/test-multipath.c

index 406324a..30cd044 100644 (file)
@@ -75,7 +75,7 @@ struct flow {
     uint8_t arp_tha[6];         /* ARP/ND target hardware address. */
     uint8_t nw_ttl;             /* IP TTL/Hop Limit. */
     uint8_t nw_frag;            /* FLOW_FRAG_* flags. */
-    uint8_t reserved[2];        /* Reserved for 64-bit packing. */
+    uint8_t zeros[2];           /* Must be zero. */
 };
 
 /* Represents the metadata fields of struct flow. */
index 0261529..c120e0b 100644 (file)
@@ -138,6 +138,7 @@ ofputil_cls_rule_from_ofp10_match(const struct ofp10_match *match,
     uint32_t ofpfw = ntohl(match->wildcards) & OFPFW10_ALL;
 
     /* Initialize rule->priority, rule->wc. */
+    memset(rule->flow.zeros, 0, sizeof rule->flow.zeros);
     rule->priority = !ofpfw ? UINT16_MAX : priority;
     ofputil_wildcard_from_ofpfw10(ofpfw, &rule->wc);
 
index f2d9b82..aa8b6f0 100644 (file)
@@ -136,6 +136,7 @@ main(int argc, char *argv[])
     flows = xmalloc(N_FLOWS * sizeof *flows);
     for (i = 0; i < N_FLOWS; i++) {
         random_bytes(&flows[i], sizeof flows[i]);
+        memset(flows[i].zeros, 0, sizeof flows[i].zeros);
         flows[i].regs[0] = OFPP_NONE;
     }
 
index baa4cc1..da72d91 100644 (file)
@@ -379,6 +379,7 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls)
         unsigned int x;
 
         x = rand () % N_FLOW_VALUES;
+        memset(&flow, 0, sizeof flow);
         flow.nw_src = nw_src_values[get_value(&x, N_NW_SRC_VALUES)];
         flow.nw_dst = nw_dst_values[get_value(&x, N_NW_DST_VALUES)];
         flow.tun_id = tun_id_values[get_value(&x, N_TUN_ID_VALUES)];
index 8a35567..b990c13 100644 (file)
@@ -60,6 +60,7 @@ main(int argc, char *argv[])
             struct flow flow;
 
             random_bytes(&flow, sizeof flow);
+            memset(flow.zeros, 0, sizeof flow.zeros);
 
             mp.max_link = n - 1;
             multipath_execute(&mp, &flow);