From: Ben Pfaff Date: Wed, 6 May 2009 22:40:21 +0000 (-0700) Subject: datapath: Compare entire flow during lookup, not just first 4 or 8 bytes. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5addd28fde5440310629724cb363abb4595ba8e0;p=openvswitch datapath: Compare entire flow during lookup, not just first 4 or 8 bytes. The size of a pointer is not the size of the referent. Only God knows how much havoc this was wreaking. (The change in dp_table_lookup is for conformance with kernel style only.) --- diff --git a/datapath/table.c b/datapath/table.c index 88aa7d2a..c0885b70 100644 --- a/datapath/table.c +++ b/datapath/table.c @@ -96,7 +96,9 @@ static struct sw_flow *lookup_table(struct dp_table *table, { struct sw_flow **bucket = find_bucket(table, flows, hash); struct sw_flow *flow = rcu_dereference(*bucket); - return flow && !memcmp(&flow->key, key, sizeof key) ? flow : NULL; + if (flow && !memcmp(&flow->key, key, sizeof(struct odp_flow_key))) + return flow; + return NULL; } static u32 flow_hash0(const struct odp_flow_key *key) @@ -213,7 +215,7 @@ dp_table_lookup_for_insert(struct dp_table *table, for (i = 0; i < 2; i++) { struct sw_flow *f = rcu_dereference(*buckets[i]); if (f) { - if (!memcmp(&f->key, target, sizeof f->key)) + if (!memcmp(&f->key, target, sizeof(struct odp_flow_key))) return buckets[i]; } else if (!empty_bucket) empty_bucket = buckets[i];