diff mbox

[net-next,2/6] flow_dissector: Include ip_proto in hash computation

Message ID 1425093109-1077-3-git-send-email-therbert@google.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Tom Herbert Feb. 28, 2015, 3:11 a.m. UTC
Fold ip_proto into dst when computing hash. This provides a more
standard 5-tuple hash.

Signed-off-by: Tom Herbert <therbert@google.com>
---
 net/core/flow_dissector.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 2c35c02..f73a248 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -276,6 +276,7 @@  static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
 static inline u32 __flow_hash_from_keys(struct flow_keys *keys)
 {
 	u32 hash;
+	u32 extra;
 
 	/* get a consistent hash (same value on both flow directions) */
 	if (((__force u32)keys->dst < (__force u32)keys->src) ||
@@ -285,7 +286,8 @@  static inline u32 __flow_hash_from_keys(struct flow_keys *keys)
 		swap(keys->port16[0], keys->port16[1]);
 	}
 
-	hash = __flow_hash_3words((__force u32)keys->dst,
+	extra = keys->ip_proto;
+	hash = __flow_hash_3words((__force u32)keys->dst ^ extra,
 				  (__force u32)keys->src,
 				  (__force u32)keys->ports);
 	if (!hash)