Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tcp: use __jhash_final() in inet6_ehashfn()

I misread jhash2() implementation.

Last round should use __jhash_final() instead of __jhash_mix().

Using __jhash_mix() here leaves entropy distributed across a, b, and c,
which might lead to incomplete diffusion of the faddr and fport bits
into the bucket index. Replacing this last __jhash_mix() with
__jhash_final() provides the correct avalanche properties
for the returned value in c.

$ scripts/bloat-o-meter -t vmlinux.0 vmlinux
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-4 (-4)
Function old new delta
inet6_ehashfn 306 302 -4
Total: Before=25155089, After=25155085, chg -0.00%

Fixes: 854587e69ef3 ("tcp: improve inet6_ehashfn() entropy")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260327040646.3849503-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
02d0e59e 30fcf28d

+2 -2
+2 -2
net/ipv6/inet6_hashtables.c
··· 42 42 * Hash laddr + faddr + lport/fport + net_hash_mix. 43 43 * Notes: 44 44 * We combine laddr[0] (high order 32 bits of local address) 45 - * with net_hash_mix() to avoid using __jhash_final(a, b, c). 45 + * with net_hash_mix() to hash a multiple of 3 words. 46 46 * 47 47 * We do not include JHASH_INITVAL + 36 contribution 48 48 * to initial values of a, b, c. ··· 63 63 a += (__force u32)faddr->s6_addr32[2]; 64 64 b += (__force u32)faddr->s6_addr32[3]; 65 65 c += (__force u32)fport; 66 - __jhash_mix(a, b, c); 66 + __jhash_final(a, b, c); 67 67 68 68 /* Note: We need to add @lport instead of fully hashing it. 69 69 * See commits 9544d60a2605 ("inet: change lport contribution