[ovs-dev] [classifier-opt 17/28] flow: Ensure that padding is always zeroed.
Ben Pfaff
blp at nicira.com
Fri Jul 20 23:25:14 UTC 2012
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
lib/flow.h | 2 +-
lib/ofp-util.c | 1 +
tests/test-bundle.c | 1 +
tests/test-classifier.c | 1 +
tests/test-multipath.c | 1 +
5 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/flow.h b/lib/flow.h
index 7a40475..39f1f77 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. The masks are used to
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 665b0da..d7e383b 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -137,6 +137,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 f2d9b82..aa8b6f0 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 baa4cc1..da72d91 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 8a35567..b990c13 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);
--
1.7.2.5
More information about the dev
mailing list