From: Ralf Lici <ralf@mandelbit.com>
To: David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, ja@ssi.bg, David Ahern <dahern@nvidia.com>
Subject: Re: [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation
Date: Tue, 1 Dec 2026 09:32:52 +0100 [thread overview]
Message-ID: <20261201083252.37868-1-ralf@mandelbit.com> (raw)
In-Reply-To: <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org>
On Mon, 30 Nov 2026 12:31:58 -0700, David Ahern <dsahern@kernel.org> wrote:
> On 11/27/26 4:03 AM, Ralf Lici wrote:
> > On Wed, 25 Nov 2026 18:33:32 -0700, David Ahern <dsahern@kernel.org> wrote:
> >> @@ -1476,7 +1483,11 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
> >>
> >> pcpu_rt = this_cpu_read(*res->nh->rt6i_pcpu);
> >>
> >> - if (pcpu_rt && READ_ONCE(pcpu_rt->sernum) && !rt6_is_valid(pcpu_rt)) {
> >> + /* A dst stamped with an older genid stays stale for everyone still
> >> + * holding it, as in IPv4. Never re-stamp it; drop it and build a
> >> + * new one.
> >> + */
> >> + if (pcpu_rt && !rt6_is_valid(pcpu_rt)) {
> >> struct rt6_info *prev, **p;
> >
> > This now evicts the pcpu dst of every route after any generation change,
> > and the eviction still drops the slot's reference right away
> > (rt6_uncached_list_add and dst_release from 02/13). A reader that took
> > the dst from the slot without a reference can then see it freed, when
> > the only other reference is the child reference of an xfrm bundle:
> >
> > 1. Bundle X, whose child is the pcpu dst P of CPU0, drops its last
> > reference, and dst_release queues dst_destroy_rcu.
> > 2. After that grace period has started, a lookup with
> > RT6_LOOKUP_F_DST_NOREF on CPU0 gets P from the slot inside its RCU
> > section, and is preempted (PREEMPT_RCU) before dst_hold_safe.
> > 3. A lookup on CPU0 after a generation change evicts P and drops the
> > slot's reference, so X's child reference is the last one.
> > 4. X's grace period ends without waiting for the first lookup, and
> > dst_destroy(X) frees P with dst_release_immediate.
> >
> > Mainline only evicts nexthop-object dsts this way, and
> > fib6_nh_release_dsts has the same pattern, as Sashiko pointed out on my
>
> I do not recall that being intentional. If anything we want consistency
> across built-in nexthops and separate nexthop objects.
>
Ok but the objection is not about the eviction itself. The issue is how
the slot's reference is dropped: lookups with RT6_LOOKUP_F_DST_NOREF
rely on RCU to keep the pcpu dst alive, and dropping the slot's
reference right away breaks that when the only other reference is an
xfrm bundle's child, since dst_destroy releases the child with
dst_release_immediate. Dropping the slot's reference after a grace
period, from a call_rcu callback, would fix it for both kinds of
nexthops, and in fib6_nh_release_dsts as well.
--
Ralf Lici
Mandelbit Srl
next prev parent reply other threads:[~2026-12-01 8:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 1:33 [PATCH net-next v2 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-11-27 11:03 ` Ralf Lici
2026-11-30 19:31 ` David Ahern
2026-12-01 8:32 ` Ralf Lici [this message]
2026-11-26 1:33 ` [PATCH net-next v2 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
2026-11-27 10:47 ` [PATCH net-next v2 00/13] ipv6: validate cached dsts against the netns route generation Ralf Lici
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=20261201083252.37868-1-ralf@mandelbit.com \
--to=ralf@mandelbit.com \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--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