From: David Ahern <dsahern@kernel.org>
To: Ralf Lici <ralf@mandelbit.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup
Date: Tue, 24 Nov 2026 10:15:40 -0700 [thread overview]
Message-ID: <72ade685-ecce-4215-a30b-25be7666e299@kernel.org> (raw)
In-Reply-To: <20261124163553.783988-1-ralf@mandelbit.com>
On 11/24/26 9:35 AM, Ralf Lici wrote:
> Hi David,
>
> On Mon, 23 Nov 2026 14:26:02 -0700, David Ahern <dsahern@kernel.org> wrote:
>> Known trade-off: any FIB change in a netns now invalidates every cached
>> IPv6 dst in it, not just those under the affected node; stale dsts are
>> rebuilt lazily on their next use.
> [...]
>> Ralf: Patch 7 is alternative to your patch that adds the cookie to the
>> APIs. Instead the result struct contains the genid before the lookup is
>> done. Adding it to the fib6_result seems simpler and accomplishes the
>> end goal everywhere.
>>
>
> Carrying the sample in fib6_result avoids growing the API, but
> validating against the netns generation also changes what a FIB change
> invalidates: every route added or removed anywhere in the netns
> invalidates every cached IPv6 dst in it. I considered this before the
> RFC and discarded it as a potential regression against the current
> model, since the IPv6 FIB was designed to limit invalidations to the
> affected nodes, as 8f34e53b60b3 ("ipv6: Use global sernum for dst
> validation with nexthop objects") puts it:
>
> With the per-node counter only dst_entries based on fib entries under
> the node are invalidated when changes are made to the routes -
> limiting the scope of invalidations.
>
> On v1 you wrote [1]:
>
>> That said, I have very limited time to work on a proposal. If this set
>> cannot converge on an acceptable solution in a few days, then I will
>> have to move on.
>
> I hope v5 [2] (that I just sent) is the convergence we were both looking
> for. It follows your direction, with validity in the dst, the sample
> carried in fib6_result and every holder covered without changes, but
> stamps the dst with the fn_sernum of the route's node, sampled during
> the lookup, and keeps the netns generation only for nexthop-object dsts,
> as today.
>
> It also avoids three problems I found in v2: a lookup can reuse a pcpu
> or exception dst that another lookup rebuilt after the route it selected
> changed, a stale exception is treated as a miss (so any FIB change in
> the netns stops learned PMTUs and redirects from being used), and
> fib6_ifup and fib6_ifdown still advance the generation before
> rt6_multipath_rebalance (which 2/4 of [2] fixes).
>
> But moving validity into the dst also raises lifetime questions that any
> version of this approach has to answer: pcpu dsts replaced while still
> held, including as children of xfrm bundles, and exceptions, which can
> neither be re-stamped nor be kept valid as they are. v5 covers the
> validation of pcpu dsts, still releases replaced ones with dst_dev_put
> and leaves exceptions on the holder's cookie for now. I'd welcome your
> input on how to take the rest further.
>
> [1] https://lore.kernel.org/netdev/2354d63e-1ba5-4655-8cea-2918fa0ee51f@kernel.org/
> [2] https://lore.kernel.org/netdev/cover.1795537128.git.ralf@mandelbit.com/
>
IPv6's finer grained invalidation of fib changes is why this whole
cookie caching mess exists. It is a performance optimization that to me
has gotten out of hand and as you reported is the cause of functional
incorrectness with both xfrm and other caching.
I spent the morning doing a deep dive on the claude assisted patches and
really like the direction. Making ipv6 fib management and invalidation
align with ipv4 should remove the need for all of the cookie stashing on
sockets and elsewhere plus remove the cookie argument to the dst APIs
including sockets. ie., it is a good cleanup and simplification of the
code base with the cost of more invalidations on ipv6 fib changes.
prev parent reply other threads:[~2026-11-24 17:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
2026-11-23 21:26 ` [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation David Ahern
2026-11-23 21:26 ` [RFC net-next v2 2/7] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-23 21:26 ` [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i() David Ahern
2026-11-23 21:26 ` [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-23 21:26 ` [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop David Ahern
2026-11-23 21:26 ` [RFC net-next v2 6/7] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-11-23 21:26 ` [RFC net-next v2 7/7] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-11-24 16:35 ` [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup Ralf Lici
2026-11-24 17:15 ` David Ahern [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=72ade685-ecce-4215-a30b-25be7666e299@kernel.org \
--to=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ralf@mandelbit.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