public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: edumazet@google.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	davem@davemloft.net, pabeni@redhat.com, kuniyu@google.com,
	horms@kernel.org, netdev@vger.kernel.org, eric.dumazet@gmail.com,
	ncardwell@google.com
Subject: Re: [net-next] tcp: use __jhash_final() in inet6_ehashfn()
Date: Mon, 23 Mar 2026 18:50:10 -0700	[thread overview]
Message-ID: <20260324015011.858344-1-kuba@kernel.org> (raw)
In-Reply-To: <20260323011816.3737155-1-edumazet@google.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
tcp: use __jhash_final() in inet6_ehashfn()

This commit fixes a bug in inet6_ehashfn() where the last round of
jhash incorrectly used __jhash_mix() instead of __jhash_final(),
which left entropy distributed incompletely and didn't provide proper
avalanche properties.

> diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
> index 109fbf620ad7..0a781cba4085 100644
> --- a/net/ipv6/inet6_hashtables.c
> +++ b/net/ipv6/inet6_hashtables.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

This isn't a bug, but the comment earlier in the function needs updating.
The comment currently says:

	/*
	 * Please look at jhash() implementation for reference.
	 * 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).
	 *

The line "to avoid using __jhash_final(a, b, c)" is now misleading since
the code was just changed to use __jhash_final() in the last round. Should
this comment be updated to explain that we combine laddr[0] with
net_hash_mix() to avoid an extra __jhash_mix() round, and that the final
round correctly uses __jhash_final() for proper avalanche properties?
-- 
pw-bot: cr

      parent reply	other threads:[~2026-03-24  1:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23  1:18 [PATCH net-next] tcp: use __jhash_final() in inet6_ehashfn() Eric Dumazet
2026-03-23  1:29 ` Kuniyuki Iwashima
2026-03-24  1:50 ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260324015011.858344-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox