Netdev List
 help / color / mirror / Atom feed
From: Ralf Lici <ralf@mandelbit.com>
To: netdev@vger.kernel.org
Cc: David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, David Ahern <dahern@nvidia.com>,
	Andrea Mayer <andrea.mayer@uniroma2.it>,
	Antonio Quartulli <antonio@mandelbit.com>
Subject: [PATCH net-next 2/2] ipv6: keep a superseded pcpu dst working until its holders notice
Date: Fri,  4 Dec 2026 12:29:28 +0100	[thread overview]
Message-ID: <f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com> (raw)
In-Reply-To: <cover.1796382820.git.ralf@mandelbit.com>

From: David Ahern <dahern@nvidia.com>

When rt6_get_pcpu_route() finds that a pcpu dst of a route using a
nexthop object has been invalidated, it takes the dst out of its slot
and calls dst_dev_put() on it. That points the dst at the blackhole
device and makes its output a discard, although the dst may still be
held: by a socket, a tunnel dst_cache, an xfrm bundle, or an skb that
has not reached dst_output() yet (a queued or NFQUEUE reinjected
packet, async crypto). Those packets are dropped, where the holder
would have noticed that the dst is stale at its next check and looked
the route up again.

The dst does have to be detached from its device when the device is
unregistered: it is no longer reachable from the FIB, and a holder
such as an idle socket can keep it indefinitely, which would hold the
device. Put it on the uncached list instead. It keeps working until its
holders let go, and rt6_uncached_list_flush_dev() detaches it on
unregister like any other uncached dst.

Drop the slot's reference after a grace period too. A lookup with
RT6_LOOKUP_F_DST_NOREF may have taken the dst from the slot without a
reference, and when the only other reference is the child reference of
an xfrm bundle, dst_destroy releases it with dst_release_immediate and
frees the dst under that lookup.

A later change to dst validation replaces the per-CPU dsts of all
routes the same way.

Reported-by: Ralf Lici <ralf@mandelbit.com>
Closes: https://lore.kernel.org/netdev/20261124204623.45969-1-ralf@mandelbit.com/
Signed-off-by: David Ahern <dahern@nvidia.com>
Link: https://lore.kernel.org/netdev/20261201174021.7211-3-dsahern@kernel.org/
[ralf: drop the slot's reference after a grace period, drop the comment
 and the Fixes tag]
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
---
 net/ipv6/route.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 39bcfa1ce01b..df4d670bcfa6 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1499,8 +1499,8 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
 		/* Paired with READ_ONCE() in __fib6_drop_pcpu_from() */
 		prev = xchg(p, NULL);
 		if (prev) {
-			dst_dev_put(&prev->dst);
-			dst_release(&prev->dst);
+			rt6_uncached_list_add(prev);
+			rt6_dst_release_deferred(prev);
 		}
 
 		pcpu_rt = NULL;
-- 
2.56.1


      parent reply	other threads:[~2026-12-04 11:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:29 [PATCH net-next 0/2] ipv6: move superseded pcpu dsts to the uncached list Ralf Lici
2026-12-04 11:29 ` [PATCH net-next 1/2] ipv6: base dst ownership on RT6_LOOKUP_F_DST_NOREF only Ralf Lici
2026-12-04 11:29 ` 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=f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com \
    --to=ralf@mandelbit.com \
    --cc=andrea.mayer@uniroma2.it \
    --cc=antonio@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=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.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