All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Eric Dumazet <edumazet@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
	netdev-bot+sashiko@kernel.org, davem@davemloft.net,
	kuba@kernel.org, willemb@google.com, horms@kernel.org,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH v2 net] udp: restore hlist_nulls for primary and secondary hash tables
Date: Tue, 3 Nov 2026 22:01:30 +0000	[thread overview]
Message-ID: <20261103220130.215f0000@pumpkin> (raw)
In-Reply-To: <CAL4WiiobvgoNp3Y-6qEh=OV9truPNn1v8-DoqFxR1rx=rpkZXA@mail.gmail.com>

On Tue, 3 Nov 2026 14:34:29 +0100
Eric Dumazet <edumazet@kernel.org> wrote:

> Le mar. 3 nov. 2026 à 09:40, Paolo Abeni <pabeni@redhat.com> a écrit :
> >
> > On 11/2/26 13:22, netdev-bot+sashiko@kernel.org wrote:  
> > > Thank you for your contribution! Sashiko AI review found 1 potential
> > > issue(s) to consider.
> > >
> > > Critical: 0 · High: 1 · Medium: 0 · Low: 0
> > >
> > > If you believe none of the issues are legitimate, please reply to each
> > > issue of Medium severity or higher and explain why the AI is wrong.
> > > If any of them are legitimate and you plan to respin, please let patchwork
> > > know by including "pw-bot: cr" as a separate line at the end of your reply
> > > (one such reply per series is enough).
> > >
> > > - [High] The hlist_nulls restart does not work when an IPv6 SO_REUSEPORT
> > >    socket is tail-inserted back into the bucket it was just removed from.  
> >
> > This look real to me. On the flip side the most straight forward fix - avoid
> > tail insertion in udp_lib_get_port() would re-introduce the issue addressed
> > by commit d894ba18d4e449b3a7f6eb491f16c9e02933736e. But rehash already avoids
> > tail insertion...  
> 
> Agreed, it is real, although not a regression: before this patch,
> hlist_add_tail_rcu() set n->next = NULL and a reader parked on the
> socket stopped there as well. v2 simply did not fix this case.
> 
> We still need the tail insertion: udp4_lib_lookup2() returns as soon
> as the first matching socket has a reuseport group without connections,
> so a dual-stack IPv6 group placed first would win over AF_INET sockets,
> despite their better score.
> 
> The problem only exists while a reader can still be parked on the
> socket, that is less than an RCU grace period after udp_lib_unhash().
> 
> v3 records get_state_synchronize_rcu() in udp_lib_unhash(), and
> udp_lib_get_port() only uses tail insertion if
> poll_state_synchronize_rcu() says the grace period has elapsed,
> otherwise it uses head insertion, as udp_lib_rehash() already does.
> The cookie fits in an existing hole of struct udp_sock.
> 
> The cost is that an IPv6 SO_REUSEPORT socket rebound within a grace
> period of its disconnect keeps its head position, so the v4/v6 ordering
> is not enforced for it, the same as after a rehash today. This needs
> disconnect() then bind() on the same port, with AF_INET and dual-stack
> AF_INET6 reuseport sockets sharing that port.
> 
> I also kept sk_nulls_add_node_rcu() unchanged, the tail insertion logic
> is now local to UDP.

Is there a different issue that is a socket is rehashed there is a chance
that it ends up back on the same list.
If that happens you need it to stay in the same place (if possible),
certainly moving it to the end would mean that a reader could miss out
some items but not see a different nulls value.

There is an even more unlikely possibility of a reader starting on chain A,
being moved to chain B, and then back to A - so missing some items on A.
Probably just worth noting that it is extremely unlikely.

David

> 
> Thanks !
> 
> pw-bot: cr


      reply	other threads:[~2026-11-03 22:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 12:20 [PATCH v2 net] udp: restore hlist_nulls for primary and secondary hash tables Eric Dumazet
2026-10-30 12:24 ` netdev-bot+sinfo
2026-10-30 16:21 ` Alexei Starovoitov
2026-10-31 12:20 ` sashiko-bot
2026-11-02 12:22 ` netdev-bot+sashiko
2026-11-03  8:40   ` Paolo Abeni
2026-11-03 13:34     ` Eric Dumazet
2026-11-03 22:01       ` David Laight [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=20261103220130.215f0000@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.