Netdev List
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: ralf@mandelbit.com, David Ahern <dahern@nvidia.com>,
	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>,
	Simon Horman <horms@kernel.org>,
	"Claude Sonnet 5 . 5" <noreply@anthropic.com>
Subject: [RFC net-next 2/6] ipv6: invalidate the failing dst in ip6_link_failure()
Date: Sun, 22 Nov 2026 15:27:00 -0700	[thread overview]
Message-ID: <20261122222717.126333-4-dsahern@kernel.org> (raw)
In-Reply-To: <20261122222717.126333-1-dsahern@kernel.org>

From: David Ahern <dahern@nvidia.com>

When a default route's neighbour fails, ip6_link_failure() wrote -1
to the fn_sernum of the route's node so that users of dsts under that
node would look the route up again and let router selection pick
another default router.

dsts are now validated against the netns route generation, so that
write no longer invalidates anything. Clear the sernum of the failing
dst instead; 0 never matches the generation, so its users do the
lookup again. Only that dst is invalidated, which for a pcpu dst is
one CPU's copy, rather than every dst under the node. Bumping the
netns generation here would be much costlier, since a failing router
can trigger this for every packet sent through it.

Signed-off-by: David Ahern <dahern@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
---
 net/ipv6/route.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1f7b2cdc1d9f..d355652a0520 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2885,14 +2885,13 @@ static void ip6_link_failure(struct sk_buff *skb)
 			rt6_remove_exception_rt(rt);
 		} else {
 			struct fib6_info *from;
-			struct fib6_node *fn;
 
+			/* Force sockets using this dst to look the route up
+			 * again; 0 never matches the netns generation.
+			 */
 			from = rcu_dereference(rt->from);
-			if (from) {
-				fn = rcu_dereference(from->fib6_node);
-				if (fn && (rt->rt6i_flags & RTF_DEFAULT))
-					WRITE_ONCE(fn->fn_sernum, -1);
-			}
+			if (from && (rt->rt6i_flags & RTF_DEFAULT))
+				WRITE_ONCE(rt->sernum, 0);
 		}
 		rcu_read_unlock();
 	}
-- 
2.43.0


  parent reply	other threads:[~2026-11-22 22:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 22:26 David Ahern
2026-11-22 22:26 ` [RFC net-next 0/6] ipv6: validate dsts against the netns route generation David Ahern
2026-11-22 22:30   ` David Ahern
2026-11-22 22:26 ` [RFC net-next 1/6] " David Ahern
2026-11-22 22:27 ` David Ahern [this message]
2026-11-22 22:27 ` [RFC net-next 3/6] nexthop: factor out nh_has_f6i() David Ahern
2026-11-22 22:27 ` [RFC net-next 4/6] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-22 22:27 ` [RFC net-next 5/6] ipv6: scope exception invalidation to the affected nexthop David Ahern
2026-11-22 22:27 ` [RFC net-next 6/6] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern

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=20261122222717.126333-4-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=dahern@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=noreply@anthropic.com \
    --cc=pabeni@redhat.com \
    --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