diff options
author | Eric Dumazet <edumazet@google.com> | 2012-07-18 04:11:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-18 14:28:46 -0400 |
commit | ddbe503203855939946430e39bae58de11b70b69 (patch) | |
tree | 1605a8d3b14a92819eb8ed47ae5a84c1b66e12f8 /net/core/flow_dissector.c | |
parent | dc9059512c09d09b99de6cd3a8bc842507934cbb (diff) |
ipv6: add ipv6_addr_hash() helper
Introduce ipv6_addr_hash() helper doing a XOR on all bits
of an IPv6 address, with an optimized x86_64 version.
Use it in flow dissector, as suggested by Andrew McGregor,
to reduce hash collision probabilities in fq_codel (and other
users of flow dissector)
Use it in ip6_tunnel.c and use more bit shuffling, as suggested
by David Laight, as existing hash was ignoring most of them.
Use it in sunrpc and use more bit shuffling, using hash_32().
Use it in net/ipv6/addrconf.c, using hash_32() as well.
As a cleanup, use it in net/ipv4/tcp_metrics.c
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Andrew McGregor <andrewmcgr@gmail.com>
Cc: Dave Taht <dave.taht@gmail.com>
Cc: Tom Herbert <therbert@google.com>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/flow_dissector.c')
-rw-r--r-- | net/core/flow_dissector.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index a225089df5b6..466820b6e344 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/ipv6.h> | 4 | #include <linux/ipv6.h> |
5 | #include <linux/if_vlan.h> | 5 | #include <linux/if_vlan.h> |
6 | #include <net/ip.h> | 6 | #include <net/ip.h> |
7 | #include <net/ipv6.h> | ||
7 | #include <linux/if_tunnel.h> | 8 | #include <linux/if_tunnel.h> |
8 | #include <linux/if_pppox.h> | 9 | #include <linux/if_pppox.h> |
9 | #include <linux/ppp_defs.h> | 10 | #include <linux/ppp_defs.h> |
@@ -55,8 +56,8 @@ ipv6: | |||
55 | return false; | 56 | return false; |
56 | 57 | ||
57 | ip_proto = iph->nexthdr; | 58 | ip_proto = iph->nexthdr; |
58 | flow->src = iph->saddr.s6_addr32[3]; | 59 | flow->src = (__force __be32)ipv6_addr_hash(&iph->saddr); |
59 | flow->dst = iph->daddr.s6_addr32[3]; | 60 | flow->dst = (__force __be32)ipv6_addr_hash(&iph->daddr); |
60 | nhoff += sizeof(struct ipv6hdr); | 61 | nhoff += sizeof(struct ipv6hdr); |
61 | break; | 62 | break; |
62 | } | 63 | } |