public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next] tcp: use __jhash_final() in inet6_ehashfn()
@ 2026-03-27  4:06 Eric Dumazet
  2026-03-29 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2026-03-27  4:06 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
	eric.dumazet, Eric Dumazet

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>
---
v2: also update the comment (Jakub)

 net/ipv6/inet6_hashtables.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 109fbf620ad7cde54300b937db58ada0d5c80664..b111b51d69fc9b77ac6ea2576c1b553c74bb139d 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -42,7 +42,7 @@ u32 inet6_ehashfn(const struct net *net,
 	 * Hash laddr + faddr + lport/fport + net_hash_mix.
 	 * Notes:
 	 * We combine laddr[0] (high order 32 bits of local address)
-	 * with net_hash_mix() to avoid using __jhash_final(a, b, c).
+	 * with net_hash_mix() to hash a multiple of 3 words.
 	 *
 	 * We do not include JHASH_INITVAL + 36 contribution
 	 * to initial values of a, b, c.
@@ -63,7 +63,7 @@ u32 inet6_ehashfn(const struct net *net,
 	a += (__force u32)faddr->s6_addr32[2];
 	b += (__force u32)faddr->s6_addr32[3];
 	c += (__force u32)fport;
-	__jhash_mix(a, b, c);
+	__jhash_final(a, b, c);
 
 	/* Note: We need to add @lport instead of fully hashing it.
 	 * See commits 9544d60a2605 ("inet: change lport contribution
-- 
2.53.0.1018.g2bb0e51243-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 net-next] tcp: use __jhash_final() in inet6_ehashfn()
  2026-03-27  4:06 [PATCH v2 net-next] tcp: use __jhash_final() in inet6_ehashfn() Eric Dumazet
@ 2026-03-29 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-29 18:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, horms, ncardwell, kuniyu, netdev,
	eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 27 Mar 2026 04:06:46 +0000 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [v2,net-next] tcp: use __jhash_final() in inet6_ehashfn()
    https://git.kernel.org/netdev/net-next/c/02d0e59e36e0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-29 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27  4:06 [PATCH v2 net-next] tcp: use __jhash_final() in inet6_ehashfn() Eric Dumazet
2026-03-29 18:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox