提交 515b65a4 编写于 作者: T Tonghao Zhang 提交者: David S. Miller

net: openvswitch: simplify the flow_hash

Simplify the code and remove the unnecessary BUILD_BUG_ON.
Signed-off-by: NTonghao Zhang <xiangxia.m.yue@gmail.com>
Tested-by: NGreg Rose <gvrose8192@gmail.com>
Acked-by: NWilliam Tu <u9012063@gmail.com>
Acked-by: NPravin B Shelar <pshelar@ovn.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册