Netdev List
 help / color / mirror / Atom feed
From: Ralf Lici <ralf@mandelbit.com>
To: David Ahern <dsahern@kernel.org>
Cc: Antonio Quartulli <antonio@openvpn.net>,
	netdev@vger.kernel.org, Sabrina Dubroca <sd@queasysnail.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH net 1/1] ovpn: avoid caching stale IPv6 dst after FIB changes
Date: Tue, 20 Oct 2026 15:27:51 +0200	[thread overview]
Message-ID: <20261020132817.468329-1-ralf@mandelbit.com> (raw)
In-Reply-To: <76f16ff2-3102-44e9-b4e0-5818044bbc75@kernel.org>

Hi David,

On Tue, 13 Oct 2026 07:52:29 -0600, David Ahern <dsahern@kernel.org> wrote:
> On 10/8/26 6:33 PM, Antonio Quartulli wrote:
> > You're right that a cached dst can go stale later and that reuse-time
> > validation handles that. This case is different, because it breaks
> > reuse-time validation.
> > 
> > dst_cache_set_ip6() samples the cookie itself:
> > 
> >         dst_cache_per_cpu_dst_set(idst, dst,
> >                                   rt6_get_cookie(dst_rt6_info(dst)));
> > 
> > rt6_get_cookie() only returns a route-tied value when rt->sernum is
> > non-zero, which happens in ip6_rt_pcpu_alloc() and only for nexthop
> > routes. Everything else reads the current node generation:
> > 
> >         *cookie = READ_ONCE(fn->fn_sernum);
>
> Have you tried setting sernum for all dst_entry when they are created?
>

We have considered that, but the existing field cannot simply be
populated for every dst. A nonzero rt6_info->sernum currently selects
global validation: ip6_dst_check and rt6_get_pcpu_route compare it with
rt_genid_ipv6. It is populated only for external nexthop objects, while
ordinary routes leave it zero and validate through their
fib6_node->fn_sernum, as commit 8f34e53b60b3 ("ipv6: Use global sernum
for dst validation with nexthop objects") explains.

If by setting it for every dst you mean assigning the global
rt_genid_ipv6 value, that would fix the race, but it would turn ordinary
IPv6 dst validation from per-node invalidation into namespace-wide
invalidation, similarly to IPv4.

> This deferred reading of fn_sernum seems to be the problem. fib entries
> have sernum set. dst_entries are created from the fib entries and should
> carry the sernum from the fib entry at that moment.
>

Yes, that is precisely the core issue. The candidate node's fn_sernum
must be sampled as part of route selection and preserved together with
the selected dst, rather than recovered from the dst's fib6_node later.

So there seems to be two possible solutions:

1. add a separate lookup-time cookie to rt6_info, while retaining the
   existing sernum as the external nexthop / global validation marker;
2. have cache-producing lookup APIs return the explicit (dst, cookie)
   pair proposed in the RFC.

The former keeps existing cache users unchanged, but the stored cookie
would have to remain immutable, and reusable per-CPU or exception dsts
would need to be replaced when their node serial changes. The latter
keeps provenance per lookup but requires propagating the pair through
cache-producing callers. What would you prefer?

Thanks!

-- 
Ralf Lici
Mandelbit Srl

      reply	other threads:[~2026-10-20 13:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 10:09 [PATCH net 0/1] ovpn: avoid caching stale IPv6 dst after FIB changes Ralf Lici
2026-09-17 10:09 ` [PATCH net 1/1] " Ralf Lici
2026-09-17 19:09   ` David Ahern
2026-09-18  6:51     ` Ralf Lici
2026-09-18 18:42       ` David Ahern
2026-09-18 20:27         ` Ralf Lici
2026-09-28  8:56           ` Ralf Lici
2026-09-29 14:09             ` David Ahern
2026-09-29 15:04               ` Ralf Lici
2026-10-09  0:33                 ` Antonio Quartulli
2026-10-13 13:52                   ` David Ahern
2026-10-20 13:27                     ` Ralf Lici [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=20261020132817.468329-1-ralf@mandelbit.com \
    --to=ralf@mandelbit.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=antonio@openvpn.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    /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