🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20561

[RFC net-next 5/6] ipv6: scope exception invalidation to the affected nexthop

#20561
From: David Ahern
Date: Sun, 22 Nov 2026 22:27
156 lines
13470 bytes
From: David Ahern <dahern@nvidia.com>

rt6_insert_exception() bumped the netns route generation, which with
generation-based dst validation invalidates every dst in the
namespace each time a PMTU or redirect exception is created. A burst
of packet-too-big messages would make all sockets and dst_caches look
their routes up again.

IPv4 limits this to the nexthop: update_or_create_fnhe() marks only
that nexthop's cached dsts stale. Do the same here by clearing the
sernum of the fib6_nh's pcpu dsts, so their users look the route up
once and find the exception.

Route dumps notice a changed tree through the root node's fn_sernum,
and the exception dump relies on that changing when an exception is
inserted on the root. A fresh fn_sernum can only come from the netns
counter, which must not be bumped here, and a locally made-up value
could later be issued by the counter to the same node and go
unnoticed. Add a per-table tb6_excp_seq, bumped for exceptions on the
root node, and have fib6_dump_table() restart when either it or the
root's fn_sernum has changed.

Signed-off-by: David Ahern <dahern@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
---
 include/net/ip6_fib.h |  3 +++
 net/ipv6/ip6_fib.c    | 25 ++++++++++++++++++++++++-
 net/ipv6/route.c      | 27 +++++++++++++++++++++++++--
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index ecce7ab007a5..92fed30a7418 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -329,6 +329,7 @@ struct fib6_walker {
 	unsigned int skip;
 	unsigned int count;
 	unsigned int skip_in_node;
+	unsigned int excp_seq;	/* tb6_excp_seq seen by a partial dump */
 	int (*func)(struct fib6_walker *);
 	void *args;
 };
@@ -362,6 +363,7 @@ struct fib6_table {
 	struct inet_peer_base	tb6_peers;
 	unsigned int		flags;
 	unsigned int		fib_seq; /* writes protected by rtnl_mutex */
+	unsigned int		tb6_excp_seq;	/* writes under tb6_lock */
 	struct hlist_head       tb6_gc_hlist;	/* GC candidates */
 #define RT6_TABLE_HAS_DFLT_ROUTER	BIT(0)
 };
@@ -583,6 +585,7 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb,
 		     struct netlink_ext_ack *extack);
 
 void fib6_update_sernum(struct net *net, struct fib6_info *rt);
+void fib6_update_excp_seq(struct fib6_info *rt);
 #if IS_ENABLED(CONFIG_IPV6)
 void fib6_update_sernum_upto_root(struct net *net, struct fib6_info *rt);
 #else
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index d465ac6ffbc6..266370e15774 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -148,6 +148,25 @@ void fib6_update_sernum(struct net *net, struct fib6_info *f6i)
 		WRITE_ONCE(fn->fn_sernum, fib6_new_sernum(net));
 }
 
+/* Tell route dumps that an exception was added under @f6i without
+ * invalidating cached dsts: those follow the netns generation, which this
+ * leaves alone. A dump notices a changed tree through the root node, so
+ * only an exception on the root needs to be visible. Fresh fn_sernum values
+ * can only come from the netns counter, so use a table sequence rather than
+ * a made-up fn_sernum that the counter could later issue again.
+ * Caller holds tb6_lock.
+ */
+void fib6_update_excp_seq(struct fib6_info *f6i)
+{
+	struct fib6_table *table = f6i->fib6_table;
+	struct fib6_node *fn;
+
+	fn = rcu_dereference_protected(f6i->fib6_node,
+				       lockdep_is_held(&table->tb6_lock));
+	if (fn == &table->tb6_root)
+		WRITE_ONCE(table->tb6_excp_seq, table->tb6_excp_seq + 1);
+}
+
 /*
  *	Auxiliary address test functions for the radix tree.
  *
@@ -637,12 +656,16 @@ static int fib6_dump_table(struct fib6_table *table, struct sk_buff *skb,
 		if (res > 0) {
 			cb->args[4] = 1;
 			cb->args[5] = READ_ONCE(w->root->fn_sernum);
+			w->excp_seq = READ_ONCE(table->tb6_excp_seq);
 		}
 	} else {
 		int sernum = READ_ONCE(w->root->fn_sernum);
-		if (cb->args[5] != sernum) {
+		unsigned int excp_seq = READ_ONCE(table->tb6_excp_seq);
+
+		if (cb->args[5] != sernum || w->excp_seq != excp_seq) {
 			/* Begin at the root if the tree changed */
 			cb->args[5] = sernum;
+			w->excp_seq = excp_seq;
 			w->state = FWS_INIT;
 			w->node = w->root;
 			w->skip = w->count;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d355652a0520..ee7a62dc16c4 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1732,6 +1732,28 @@ struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
 	return bucket;
 }
 
+/* A new exception may apply to dsts already cached on @nh. Make them fail
+ * ip6_dst_check() once so their users look the route up again and find it;
+ * dsts of other routes are left alone.
+ */
+static void fib6_nh_invalidate_pcpu(const struct fib6_nh *nh)
+{
+	int cpu;
+
+	if (!nh->rt6i_pcpu)
+		return;
+
+	rcu_read_lock();
+	for_each_possible_cpu(cpu) {
+		struct rt6_info *pcpu_rt;
+
+		pcpu_rt = READ_ONCE(*per_cpu_ptr(nh->rt6i_pcpu, cpu));
+		if (pcpu_rt)
+			WRITE_ONCE(pcpu_rt->sernum, 0);
+	}
+	rcu_read_unlock();
+}
+
 static int rt6_insert_exception(struct rt6_info *nrt,
 				const struct fib6_result *res)
 {
@@ -1806,10 +1828,11 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 out:
 	spin_unlock_bh(&rt6_exception_lock);
 
-	/* Update fn->fn_sernum to invalidate all cached dst */
 	if (!err) {
+		fib6_nh_invalidate_pcpu(nh);
+
 		spin_lock_bh(&f6i->fib6_table->tb6_lock);
-		fib6_update_sernum(net, f6i);
+		fib6_update_excp_seq(f6i);
 		fib6_add_gc_list(f6i);
 		spin_unlock_bh(&f6i->fib6_table->tb6_lock);
 		fib6_force_start_gc(net);
-- 
2.43.0
Technical Details
Message-ID: <20261122222717.126333-7-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368860-linux-kernel-netdev=dewy.ru
References: <20261122222717.126333-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368860-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [RFC net-next 5/6] ipv6: scope exception invalidation to the affected nexthop
Date: Sun, 22 Nov 2026 15:27:03 -0700
Organization: Usenet Network
Message-ID: <20261122222717.126333-7-dsahern@kernel.org>
References: <20261122222717.126333-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3737607"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:02uc+3vyeBKMepRJorNSfAiZGNU= sha256:4VY+jwmnkS1u+8hi9oBr0WOYzlnDsQPLqRinL7iqOeU=
	sha1:j0SRYrx0hR6fe3avkZvyRexLkTA= sha256:4QBvl7iBmee5LIM7JNMQwV+oD62JlfEbnEj86Ksou1A=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B95D8125D88; Mon, 23 Nov 2026 01:27:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id s8rExh4sjmwd;
	Mon, 23 Nov 2026 01:27:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368860-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 8575D125D89; Mon, 23 Nov 2026 01:27:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id E88FA2945E; Sun, 22 Nov 2026 22:27:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795386448;
	b=RIRt50P03eSvYATn/GdD4bBSAzLnckVrSrzDdOg1FslyGQPB3G+NC34pl1hV73oRAbhy
	 MmTbeQJl8L0ftK6DQtOM+IdoypOHPLjCa6chNUe7vbJw6L6G0ET12DsyCO3sB3yjwTAtp
	 4fjlQ0MuEdyU9KIA0m7adCQb7kAnOF6BmMoPmlJc/xLXHLI1eLWhKsXtehZszigUE/hpx
	 JFbEwjSFMItZYg/lA7W57P8W5uygYmQ+c2JfWQrUowre5/pEA/CUs9oZIs/EqXuj0ADPn
	 F6b6+aRp+rbZ3BuBBKSLSccSeepzeKR6/4ls+vx74dTBA/zVt5ibfkCz9DpAupLMI1g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795386448;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=jziZq71BsQdh8V46JE5I+Pj3nE5V7tKmxYbCw2mn1nw=;
	b=0zJv6NSUzTzXd0yB1T4rNukfRhobaUo7c9je2io/CoK7HBAOGN9DT3h03/YNk5gpmTkk
	 VnaRUMLGNVhUcVq2ypSr5GQSVza0sCfIIND8coOVFDGwGnKDXHRWlmBXyfEY2O1Z6rHdQ
	 Zlkpt8JQ1nvB7KecS3e+FzoWZrc1+fV++gqwbOdXKfkQNylNyN3iIJ3lzoIY7kA9mm6vL
	 CsleUFk5dw8r+AczG55sxNAyCpHlYoXIOm82b5tzZ4LpowxQU3/taa/f73a8chci1bfOg
	 JsFAiIlcdFZPlcW6I99111wvFrh5xsckAuruDDq/lggpo+8S5eWny5neujMCmrSfdJQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oJLy7WC8;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DA736606A32C;
	Sun, 22 Nov 2026 22:27:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oJLy7WC8
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795386448;
	b=u82BGpRDIPkZIXoDthY3LTORMemw9amzTX91D3leV+6q8D1voGz0MMNtMcZV2aeqVfUd
	 XB6GJ/35tFwSG4X3U3jr8j6VV6qtHvHTQROIUGfJROpw56yagwkujaW5Ybi3i686bnjGZ
	 09TpEFQvyEdP8/PzHYe8j3UnkNocgNqQW5TumUwMQnZe9qFI+yBsvgdXuU7tGIhRvGykm
	 8PgUwrDThJr/3H7MxbgLg8TNCyxhRnY+fFUlb52iO1LYKsnY1drhY9iBnW6RkjqLxIfsl
	 Zq9ooI3zBEeSCisJ0oNeDp2vqdRZqmqWfpoV1sdNuUnkSo9PfWYh5kB1mr6mpj7y7Iw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795386448;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=jziZq71BsQdh8V46JE5I+Pj3nE5V7tKmxYbCw2mn1nw=;
	b=b6GWWA5/xGAs34x0JOrh/sgssYs/IiBMKhSe7jWBY0fTy7/cEUMcNahFB1NWXIp3z6mq
	 OBzj4NuR0eWyIIorXGgrA3JynuaI2k1zXcyM+1QDccD4ceQUgLyUPgUvlyfRThTMAIKSu
	 kLO7Ia3urwyOZphGoFLQlOMMf8SkNis8iRRKoy+b+S6DTABUKQo7kFg4MWB+tBYJcR3+G
	 ZUUrNbQok9eU3MavEZtCyTmbVYhHEuvCjsCM1qnBz0k1anyfFPCyyv5xyQl/WAVXjkLwl
	 el4daZ7kH1mCDTR0+ulNaL0zlU4EOOFn0iMLv5tHg+gnnUhHfPohHX0FjueGxGO7KjQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oJLy7WC8;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06D19606A334
	for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 22:27:28 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 585881F00AD4;
	Sun, 22 Nov 2026 22:27:27 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795386447;
	bh=jziZq71BsQdh8V46JE5I+Pj3nE5V7tKmxYbCw2mn1nw=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=oJLy7WC8lSdCxIdMMMYezYt9pHFkYB31HigH9NqipWyMaRkIbKM93HQc9rLxAMZvW
	 2H3vr1K/9V4vQpXhBcML0iMFPSkF4Y2LrCnM8bi4ULEsJA1vl4FtEaXklL7mTNl7S8
	 /bLwTDZks7Wm6LQji7CMd/AAKM1LprS2GkfWA7vdg4SXuQFH4pDl7g2OLSpYGXMWGD
	 L7bfvJ6BA2EnmzH9EhY8SEDFpf4HzgJmWgBa50hjVO1hrrNcKxN1R0RZP0b4LhHV+7
	 bEPUoIhtemb6eCKT8x6UChw6BI/MUPcuwlUuEtLT5l2HVjz6KF+OJLfJC9d5Er59de
	 CTyCtTH97l5iw==
X-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>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261122222717.126333-1-dsahern@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list