Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: netdev-bot+sashiko@kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	 willemb@google.com, kuniyu@google.com, horms@kernel.org,
	 netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net] udp: restore hlist_nulls for primary and secondary hash tables
Date: Wed, 23 Sep 2026 15:32:18 +0200	[thread overview]
Message-ID: <CANn89iKmREFPZLDXUUG7SV3qSHvXPW40eo7qWNN_Tu46CofLzA@mail.gmail.com> (raw)
In-Reply-To: <179016837127.2160803.11508533385406825812@kernel.org>

On Wed, Sep 23, 2026 at 2:59 PM <netdev-bot+sashiko@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 5 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 2 · Low: 2

Thanks for the review, comments below.

> [Severity: Medium]
> The pre-image here was an unconditional head insert.  Is the new IPv6 plus
> SO_REUSEPORT tail insert part of the hlist_nulls conversion?  The changelog
> only describes restoring hlist_nulls and adding the traversal restarts, so
> this chain ordering change is not mentioned.

No, it is not, and it should not have been there.  It was an attempt to
make udp_lib_rehash() consistent with udp_lib_get_port(), but it is not
needed for the hlist_nulls conversion and does not belong in this patch.

v2 keeps the unconditional head insert.  The CONFIG_BASE_SMALL
misdelivery you describe is a consequence of this hunk and goes away
with it.

> [Severity: Medium]
> Can this tail insertion defeat the nulls-value check added elsewhere in the
> patch?

Yes, and this is the better argument for dropping that hunk.

hlist_nulls_add_tail_rcu() sets n->next = last->next, that is the nulls
marker of the bucket itself, while hlist_nulls_add_head_rcu() sets
n->next = h->first.  Only the latter is compatible with the nulls
scheme: a reader parked on a node that leaves a bucket and comes back
must be sent to the head of the chain, not to its end marker.  With the
tail insert the reader stops with a matching nulls value, so the check
can not fire and the rest of the chain is silently skipped, exactly as
you describe.

v2 keeps head insertion at this site and says why.

Note I am keeping the tail insert in sk_nulls_add_node_rcu(): the
pre-image sk_add_node_rcu(), used by udp_lib_get_port(), already did
hlist_add_tail_rcu() for IPv6 SO_REUSEPORT sockets, see d894ba18d4e4
("soreuseport: fix ordering for mixed v4/v6 sockets").  udp_lib_get_port()
only inserts unhashed sockets, and for the same-bucket re-insert case it
behaves as before the conversion, since hlist_add_tail_rcu() left
n->next = NULL and readers stopped there as well.  No change in
behavior, so not something to address in a fix for net.

> [Severity: Low]
> This path now does an O(N) chain walk with softirqs disabled.

Goes away with the above.

> [Severity: High]
> Should this walk also validate the terminating nulls value?

I do not think so, and this is not a regression.

Before this patch the same loop walked a plain hlist.  A socket moved by
udp_lib_rehash() kept its ->next pointing into the new chain, so the
reader already wandered into the other bucket, stopped on that bucket's
NULL and missed the remaining listeners of the original chain, and the
hash2_any pass could already revisit sockets.  The conversion does not
make this worse, it only makes the condition detectable.

Detecting it does not help.  As you note, by the time we reach the end
of the chain skbs have been cloned and queued, so a "goto begin" restart
would deliver duplicates, which is worse than missing a listener during
a concurrent rehash.  Multicast delivery here is best effort.

v2 adds a comment at both mcast_deliver() sites to record this.

> For completeness, __udp4_lib_demux_lookup() and __udp6_lib_demux_lookup()
> were also converted to nulls iteration without the check.

These look at the first entry only and break out, and
inet_match()/inet6_match() validate the 4-tuple, so there is nothing to
restart.

> [Severity: Low]
> This isn't a bug, but .clang-format still lists only the old name in
> ForEachMacros:

Good catch, v2 renames the entry.

Thanks !

pw-bot: cr

      reply	other threads:[~2026-09-23 13:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  9:57 [PATCH net] udp: restore hlist_nulls for primary and secondary hash tables Eric Dumazet
2026-09-22 12:08 ` David Laight
2026-09-23 12:59 ` netdev-bot+sashiko
2026-09-23 13:32   ` Eric Dumazet [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=CANn89iKmREFPZLDXUUG7SV3qSHvXPW40eo7qWNN_Tu46CofLzA@mail.gmail.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.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