[ovs-dev] [PATCH 2/3] datapath: flow hash

Pravin B Shelar pshelar at nicira.com
Fri Dec 2 19:00:38 UTC 2011


Following patch keeps raw hash value (derived from key) in
sw_flow. So that new seed value can be used to find hash bucket.

This patch is required for next patch related to hash-table
re-hashing.

Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
---
 datapath/flow.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/datapath/flow.c b/datapath/flow.c
index c6f591a..a357077 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -290,6 +290,7 @@ struct sw_flow *ovs_flow_alloc(void)
 
 static struct hlist_head *find_bucket(struct flow_table *table, u32 hash)
 {
+	hash = jhash_1word(hash, hash_seed);
 	return flex_array_get(table->buckets,
 				(hash & (table->n_buckets - 1)));
 }
@@ -813,7 +814,7 @@ out:
 
 u32 ovs_flow_hash(const struct sw_flow_key *key, int key_len)
 {
-	return jhash2((u32 *)key, DIV_ROUND_UP(key_len, sizeof(u32)), hash_seed);
+	return jhash2((u32 *)key, DIV_ROUND_UP(key_len, sizeof(u32)), 0);
 }
 
 struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *table,
-- 
1.7.1




More information about the dev mailing list