Article View: linux.kernel.netdev
Article #21319[RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop
From: David Ahern
Date: Mon, 23 Nov 2026 21:26
Date: Mon, 23 Nov 2026 21:26
158 lines
13138 bytes
13138 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>
---
Changes since v1:
- None.
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 a132d33259a2..38d5f3bc85bb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1717,6 +1717,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)
{
@@ -1791,10 +1813,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:
<20261123212623.106153-6-dsahern@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369782-linux-kernel-netdev=dewy.ruReferences:
<20261123212623.106153-1-dsahern@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369782-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop Date: Mon, 23 Nov 2026 14:26:07 -0700 Organization: Usenet Network Message-ID: <20261123212623.106153-6-dsahern@kernel.org> References: <20261123212623.106153-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3988514"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:TWNzWz6BC8GXu4nTwg6ED8IjDRQ= sha256:gbwx2tKjVZB0+60e3VMY42T7hoWbc9HnGjpswgMEnN0= sha1:h7bVqh2Q6iH5KK30LBrvPx/sisE= sha256:q29/owptdZnktzk2ebYVf6JoblucbKCxOqc/33nKdTQ= 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 32E4D125DC6; Tue, 24 Nov 2026 00:26:52 +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 cgIZrRO4bOAN; Tue, 24 Nov 2026 00:26:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-369782-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id CBE6F125DC8; Tue, 24 Nov 2026 00:26:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 38A1F24FA9; Mon, 23 Nov 2026 21:26:37 +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=1795469193; b=eH+IG1LxpPIMQV9lSQLH2yUE3qXZogagBlx23rSp7vbPwedVSzQU9H0hM+MDgBFIHHDW KUI3nxxu53EVpQCGMekPIBgubu16z2WUZyN1LAI89uhdXqCZFMn8O45ehzSRb8pxxt7RV EpMS2+C7ElH5ZJfgkRJ3dDuk5W48LFYMZ3mJTmmyjY/3TBgfJZi8Qc62IyCqsd+QoVE/V Z+n0jVBdvN1rt42Jj5DuUTe83taU2kB7Oo0eydfe4q7gq4xaO5bbHSMbpoGyEDZVGo4zp +mDxxmnvb4HShRnZCzE9J10Yhz3ia+WY9vodcgY6Ohc+3kAQlRcrbtsoKvDZCZHDyLQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795469193; 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=0XNXqikktmro8BSaMXi6gVfIL79lfS7VSfdwQmtku7A=; b=KAYbj9OEh1bYaQ8LKI8CmEsspfAJdXFjrcLJTx86ZR7YSZ4+/qO9wxqctVRFQAciPhEj HUO06g0wxgaIzkF+sKkrtTR5IqiIUEQtAbHXfi5hHd11AN+XUpQ7/3PQVrHwmLkrXkie6 BD6IdHeUrmRjJxksmaca0Oi68PaeOdY6yq52z77LvmbxLPD6rNp/6zytL6oR3m7ORJC6P xuo9x+momRKfJ8SpmpVseJFEpDwlxuEj35KWx002lA6KT7p6ZsqvcKBXuCtDI9LAFUO5T wIDWD08f5QqF1GrD3Su+/Qfz/kRVgrfh3g4FHY7Cq8HW8I2ZMtUrFr0jcOW71I5EVEQ== 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=offhgGL3; 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 226B7606A330; Mon, 23 Nov 2026 21:26:33 +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=offhgGL3 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=1795469192; b=zSjCmPcSSRQMFpa1C0wzsTtriti4vKH47miZjBrSlqLc/PZelS2+LaK4KOckIYpmQeEU mtbH8y0SOohB+1xvHNEsAafNorMYxLh2GVLj3RKGlU5agDRoJB/wT0Bdi0CR5f+fS2wMB bN1QU9cTbQUIM6zLJRCxEVRKFmHtHICQRYqKFo1k0D3QFMoVX7f/70GjwCU05ASlCXmhp 6o4DEsc+DgOPaFUQnIInpjnXf9920Q3Y+F8bRLtPGVKYBtGKuNWXLrss1+7W0UbT2cPAJ 5WA3cnjYVR4YibIHzUq00TsrX2aI/HBEbcSyL49Xz7sppH4tZlr49nUYzk03XHkeVHg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795469192; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=0XNXqikktmro8BSaMXi6gVfIL79lfS7VSfdwQmtku7A=; b=B8rSWLRWZzz0qhW7KZDoUWFb09OGyMQy2Mbdz9HoLmFyLlrHE53iX+iIEzxDO0aG11Yx 3V4s3omFe771XNEt+0Uz5dopTuuTo4ftqLeRKlA5Npf99ehaxoBMZOb4dtK4v9eZitZIr 13wOxDAeCZAi57HN9gWqDfW1SI+N/GstEUsGBTLR+uNaYXW4+f/k+gjkLJBJO1D2k9UZV MVSTuCFXq22eYsYY4/I3B5xPT5HmrjBTXTSD6Tf3IwMU/M88ZSAEEqLiWkeCnQ2eZ2gYs /GUxVyGoHQrnNosiazggWPlXnHdIwM273T0JHggeoabLL1zZuvNpWMd3CIcGLM7KnJA== 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=offhgGL3; 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 447BE606A690 for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 21:26:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F191F00A03; Mon, 23 Nov 2026 21:26:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795469192; bh=0XNXqikktmro8BSaMXi6gVfIL79lfS7VSfdwQmtku7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=offhgGL3dH+RaWwGK5yee2co/WXcitshY3wlmepfejwdlXBgJkK74Yn3X2ebL1Bqq G2XhxDcv0Qoqt4XXmEXeeulLnfCDhybFCwFBBDzyvE9vPQk1x7TmFtYVuRnRssdfcF g/ZTpBcQ6daCSxr5lBxt6DqgJeKmy37U2ZDUS6YouctFE7AKpLnFSPGlnFo7SptuGx ThOqalNkseLs87XwJVatG20WOzo77HgEqSu+Ul3hPvirD257toqcyyw1LKFF6+akNQ tTHeQdPhKsEwTTixj298YZ6kCHw4q7mnff+JSxuCr36MrdJytZL04Vx/DpGqKp4KK+ 3kRnrH0h3I5fw== X-Cc: ralf@mandelbit.com, David Ahern <dahern@nvidia.com> X-Mailer: git-send-email 2.43.0 X-In-Reply-To: <20261123212623.106153-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