Netdev List
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@openvpn.net>
To: Ralf Lici <ralf@mandelbit.com>, David Ahern <dsahern@kernel.org>
Cc: 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: Fri, 9 Oct 2026 02:33:17 +0200	[thread overview]
Message-ID: <375bc468-fb28-4620-a5c8-0f7ba9e693d6@openvpn.net> (raw)
In-Reply-To: <20260929150454.466148-1-ralf@mandelbit.com>

On 29/09/2026 17:04, Ralf Lici wrote:
> On Tue, 29 Sep 2026 08:09:46 -0600, David Ahern <dsahern@kernel.org> wrote:
>> On 9/28/26 3:56 AM, Ralf Lici wrote:
>>> Hi David,
>>>
>>> Just following up on this. Does my previous example clarify why storing
>>> an old dst with a new cookie defeats reuse-time validation?
>>>
>>> If so, would you prefer that I pursue the kernel-wide lookup-provenance
>>> approach described in the RFC, or keep the fix self-contained in ovpn?
>>> The same late-cookie-sampling pattern is used by several drivers and
>>> callers in the networking core, so I think fixing it generically is the
>>> better architectural choice.
>>>
>>> If changing the generic interfaces is not acceptable, I can rework the
>>> patch as an ovpn-local fix, although that would duplicate IPv6 routing
>>> details in the driver and leave the equivalent pattern elsewhere
>>> unchanged.
>>>
>>
>> dst's are cached in lots of places. Why does ovpn need internal routing
>> details that the other places do not?
>>
>>
> 

Hi David,

ovpn maintainer here: I wanted to back this patch.

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);

So if the FIB changes between ip6_dst_lookup_flow() returning D0 and
dst_cache_set_ip6() reading the cookie, we cache D0 with cookie C1. At
reuse dst_check() compares C1 against the node's current C1, they match,
and the stale route is used until the next FIB change.

Which invariant stops that cookie read from seeing a generation newer
than the one the lookup used? If there is one, we'll drop both the patch
and the RFC.

Regarding the layering, I agree. rt_genid_ipv6() does not belong in a 
driver.
That's exactly what the RFC [1] was for, but it's had no feedback so 
far, hence I suggested Ralf to pursue this other path.
The late sampling lives in dst_cache_set_ip6(), not in ovpn.

Happy to confine the IPv6 bits to a helper, or to revive the RFC if
you'd like review it.

Please also note that the workaround we're looking at is already 
implemented by other drivers, which they all could drop if we'd be able 
to provide an IPv6-generic solution.


Please let us know!


[1] 
https://lore.kernel.org/netdev/20260901122501.482920-1-ralf@mandelbit.com/

Thanks,
         Antonio


> Because, as explained in this thread and in the RFC, there is enough
> evidence that the current IPv6 dst-caching pattern is racy. If other
> kernel users are expected to live with that race, I cannot force a
> generic fix, but I do not think that is a good reason to require ovpn to
> do the same.
> 
> If you believe the sequence I described is safe, please explain which
> invariant makes it so.
> 

-- 
Antonio Quartulli
OpenVPN Inc.


      reply	other threads:[~2026-10-09  0:33 UTC|newest]

Thread overview: 10+ 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 [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=375bc468-fb28-4620-a5c8-0f7ba9e693d6@openvpn.net \
    --to=antonio@openvpn.net \
    --cc=andrew+netdev@lunn.ch \
    --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=ralf@mandelbit.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