From 3be2832bf4b26cac30cb4d14d25b91774db5908a Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Mon, 18 Aug 2008 22:23:03 -0700 Subject: [PATCH] Fix problem where packets never matched in hash table and flows always added regardless of whether they currently exist. --- datapath/table-hash.c | 5 +++-- switch/table-hash.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) 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]; } -- 2.30.2