]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tcp: improve inet6_ehashfn() entropy
authorEric Dumazet <edumazet@google.com>
Fri, 13 Mar 2026 12:03:46 +0000 (12:03 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 17 Mar 2026 02:27:41 +0000 (19:27 -0700)
commit854587e69ef3b7a14b4380d9b99e18693bb9a07b
treefd4188543efb968e75ca0c8f0ae219bf8b1133e2
parent6a33a706265daa3a0d92fece0baf6f2c3915f1cd
tcp: improve inet6_ehashfn() entropy

Instead of only using the 32 low order bits of the local address,
use all of them.

Xor net_hash_mix(net) with the 32 high order bits of the local address
so that we can use __jhash_mix() three times.

If we were hashing 4 extra bytes, we would need one __jhash_final()
which is a bit expensive.

Using net_hash_mix() at the beginning allows better register allocation.

We no longer use a cascade of two jhash and inet6_ehash_secret,
this was dubious/weak.

Add a comment explaining why @lport is not part of the jhash computation.

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

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260313120346.3378811-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/inet6_hashtables.c