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>
This commit is contained in:
committed by
David S. Miller
parent
dc9059512c
commit
ddbe503203
@@ -211,10 +211,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
|
||||
break;
|
||||
case AF_INET6:
|
||||
*(struct in6_addr *)addr.addr.a6 = inet6_rsk(req)->rmt_addr;
|
||||
hash = ((__force unsigned int) addr.addr.a6[0] ^
|
||||
(__force unsigned int) addr.addr.a6[1] ^
|
||||
(__force unsigned int) addr.addr.a6[2] ^
|
||||
(__force unsigned int) addr.addr.a6[3]);
|
||||
hash = ipv6_addr_hash(&inet6_rsk(req)->rmt_addr);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
@@ -251,10 +248,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock
|
||||
case AF_INET6:
|
||||
tw6 = inet6_twsk((struct sock *)tw);
|
||||
*(struct in6_addr *)addr.addr.a6 = tw6->tw_v6_daddr;
|
||||
hash = ((__force unsigned int) addr.addr.a6[0] ^
|
||||
(__force unsigned int) addr.addr.a6[1] ^
|
||||
(__force unsigned int) addr.addr.a6[2] ^
|
||||
(__force unsigned int) addr.addr.a6[3]);
|
||||
hash = ipv6_addr_hash(&tw6->tw_v6_daddr);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
@@ -291,10 +285,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
|
||||
break;
|
||||
case AF_INET6:
|
||||
*(struct in6_addr *)addr.addr.a6 = inet6_sk(sk)->daddr;
|
||||
hash = ((__force unsigned int) addr.addr.a6[0] ^
|
||||
(__force unsigned int) addr.addr.a6[1] ^
|
||||
(__force unsigned int) addr.addr.a6[2] ^
|
||||
(__force unsigned int) addr.addr.a6[3]);
|
||||
hash = ipv6_addr_hash(&inet6_sk(sk)->daddr);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user