Commit 515b65a4 authored by Tonghao Zhang's avatar Tonghao Zhang Committed by David S. Miller

net: openvswitch: simplify the flow_hash

Simplify the code and remove the unnecessary BUILD_BUG_ON.
Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
Tested-by: default avatarGreg Rose <gvrose8192@gmail.com>
Acked-by: default avatarWilliam Tu <u9012063@gmail.com>
Acked-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 57f7d7b9
...@@ -432,13 +432,10 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table) ...@@ -432,13 +432,10 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table)
static u32 flow_hash(const struct sw_flow_key *key, static u32 flow_hash(const struct sw_flow_key *key,
const struct sw_flow_key_range *range) const struct sw_flow_key_range *range)
{ {
int key_start = range->start; const u32 *hash_key = (const u32 *)((const u8 *)key + range->start);
int key_end = range->end;
const u32 *hash_key = (const u32 *)((const u8 *)key + key_start);
int hash_u32s = (key_end - key_start) >> 2;
/* Make sure number of hash bytes are multiple of u32. */ /* Make sure number of hash bytes are multiple of u32. */
BUILD_BUG_ON(sizeof(long) % sizeof(u32)); int hash_u32s = range_n_bytes(range) >> 2;
return jhash2(hash_key, hash_u32s, 0); return jhash2(hash_key, hash_u32s, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment