From: Justin Pettit Date: Tue, 19 Aug 2008 05:23:03 +0000 (-0700) Subject: Fix problem where packets never matched in hash table and flows always added regardle... X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3be2832bf4b26cac30cb4d14d25b91774db5908a;p=openvswitch Fix problem where packets never matched in hash table and flows always added regardless of whether they currently exist. --- diff --git a/datapath/table-hash.c b/datapath/table-hash.c index 26db5229..d87b5104 100644 --- a/datapath/table-hash.c +++ b/datapath/table-hash.c @@ -31,7 +31,8 @@ static struct sw_flow **find_bucket(struct sw_table *swt, const struct sw_flow_key *key) { struct sw_table_hash *th = (struct sw_table_hash *) swt; - unsigned int crc = crc32_calculate(&th->crc32, key, sizeof *key); + unsigned int crc = crc32_calculate(&th->crc32, key, + offsetof(struct sw_flow_key, wildcards)); return &th->buckets[crc & th->bucket_mask]; } @@ -58,7 +59,7 @@ static int table_hash_insert(struct sw_table *swt, struct sw_flow *flow) retval = 1; } else { struct sw_flow *old_flow = *bucket; - if (!flow_keys_equal(&old_flow->key, &flow->key)) { + if (flow_keys_equal(&old_flow->key, &flow->key)) { rcu_assign_pointer(*bucket, flow); flow_deferred_free(old_flow); retval = 1; diff --git a/switch/table-hash.c b/switch/table-hash.c index 014529b8..3e3cb768 100644 --- a/switch/table-hash.c +++ b/switch/table-hash.c @@ -52,7 +52,8 @@ static struct sw_flow **find_bucket(struct sw_table *swt, const struct sw_flow_key *key) { struct sw_table_hash *th = (struct sw_table_hash *) swt; - unsigned int crc = crc32_calculate(&th->crc32, key, sizeof *key); + unsigned int crc = crc32_calculate(&th->crc32, key, + offsetof(struct sw_flow_key, wildcards)); return &th->buckets[crc & th->bucket_mask]; }