From: Ben Pfaff Date: Mon, 18 Jun 2012 22:09:49 +0000 (-0700) Subject: flow: Ensure that padding is always zeroed. X-Git-Tag: sliver-openvswitch-1.8.90-0~15^2~35 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=51c14ddd8df9617e641748a98ac52b78fd19290a;p=sliver-openvswitch.git flow: Ensure that padding is always zeroed. Signed-off-by: Ben Pfaff --- diff --git a/lib/flow.h b/lib/flow.h index 406324ad7..30cd044d8 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -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. */ diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 026152921..c120e0b69 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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); diff --git a/tests/test-bundle.c b/tests/test-bundle.c index f2d9b8245..aa8b6f0f4 100644 --- a/tests/test-bundle.c +++ b/tests/test-bundle.c @@ -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; } diff --git a/tests/test-classifier.c b/tests/test-classifier.c index baa4cc1a2..da72d9102 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -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)]; diff --git a/tests/test-multipath.c b/tests/test-multipath.c index 8a355677d..b990c1338 100644 --- a/tests/test-multipath.c +++ b/tests/test-multipath.c @@ -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);