Article View: linux.kernel.netdev
Article #25392[PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence
From: David Ahern
Date: Tue, 01 Dec 2026 17:40
Date: Tue, 01 Dec 2026 17:40
140 lines
13397 bytes
13397 bytes
From: David Ahern <dahern@nvidia.com>
A route dump that is suspended and later resumed restarts from the
root if the root node's fn_sernum changed, and the exception dump
relies on that happening when an exception is inserted on the root:
rt6_insert_exception() calls fib6_update_sernum(), which among other
things gives the node a new fn_sernum.
That ties dump consistency to what a change to fn_sernum otherwise
means. A fresh fn_sernum can only come from the netns counter, 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 under
tb6_lock when an exception is inserted on the root node, and have
fib6_dump_table() restart when either it or the root's fn_sernum has
changed. The set of inserts a dump notices is the same as before.
Also correct the comment in rt6_nh_dump_exceptions(): only changes to
the root's exceptions are noticed, not those under other nodes, where
a dump suspended in the middle of a route's exceptions can skip or
repeat some of them.
Signed-off-by: David Ahern <dahern@nvidia.com>
---
include/net/ip6_fib.h | 3 +++
net/ipv6/ip6_fib.c | 25 ++++++++++++++++++++++++-
net/ipv6/route.c | 15 ++++++++++-----
3 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index bfc1895e8591..af2a17945011 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -386,6 +386,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;
};
@@ -419,6 +420,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)
};
@@ -640,6 +642,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 e1d49897d6ab..4da83c22bbde 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. A dump notices
+ * a changed tree through the root node, so only an exception on the root
+ * needs to be visible. Use a table sequence for that, rather than a fresh
+ * fn_sernum, so that it does not depend on what else a change to fn_sernum
+ * does: fresh values can only come from the netns counter, and a made-up
+ * one could later be issued by the counter to the same node.
+ * 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 5af0f26332ff..836bd7aa05cd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1832,6 +1832,7 @@ static int rt6_insert_exception(struct rt6_info *nrt,
if (!err) {
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);
@@ -6125,11 +6126,15 @@ static int rt6_nh_dump_exceptions(struct fib6_nh *nh, void *arg)
continue;
}
- /* Expiration of entries doesn't bump sernum, insertion
- * does. Removal is triggered by insertion, so we can
- * rely on the fact that if entries change between two
- * partial dumps, this node is scanned again completely,
- * see rt6_insert_exception() and fib6_dump_table().
+ /* Expiration of entries doesn't bump anything. An
+ * insertion on the root node changes the root's
+ * fn_sernum or tb6_excp_seq, and removal is triggered
+ * by insertion, so if entries of the root change
+ * between two partial dumps, the table is scanned
+ * again, see rt6_insert_exception() and
+ * fib6_dump_table(). A change under any other node is
+ * not noticed: a dump suspended in the middle of that
+ * route's exceptions can skip or repeat some of them.
*
* Count expired entries we go through as handled
* entries that we'll skip next time, in case of partial
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261201174021.7211-6-dsahern@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.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-375257-linux-kernel-netdev=dewy.ruReferences:
<20261201174021.7211-1-dsahern@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.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-375257-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence Date: Tue, 1 Dec 2026 10:40:06 -0700 Organization: Usenet Network Message-ID: <20261201174021.7211-6-dsahern@kernel.org> References: <20261201174021.7211-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1780010"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:J5iTixsSKaRJiK6c7U/IeZcME70= sha256:WXPNXZy5IQQiifptEp8XS7Cg+W6opakjdIOOYs51Js4= sha1:QujB0UoAQ0BgZDkgd/0vR13eJLs= sha256:HCdzw3tNrMlwv3ljxDMrtyZ1rkmG2XtvBxAX1+1uxcI= 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 0192311743D; Tue, 1 Dec 2026 20:41:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 Qf4U2_HYGEEP; Tue, 1 Dec 2026 20:41:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375257-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 A6944117436; Tue, 1 Dec 2026 20:41:13 +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 610D528295; Tue, 1 Dec 2026 17:41:10 +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=1796146862; b=eICvqG91jwnr6bmig+J9vqwlZm2inhUE3qekmbHXQ6z8gvqxDF9nDwEKchojToDpbA7a Nbzy9C5sEvNQMafLSrMPKQCPll1saBIkw51ykMwH8f85THs3CxhMqIYoEcpS4DmK+MLCC mVZSyGHzov1qz/7bhQcQlB9ppjObwsfm/CWjP3pmKUt0wgyvcc3BpX6h0BHCU7vbJtMsE kxyEjEKJTIYPz7t5eRy+nRzmkjsnTD5H5ed/3DdvKAKT3EDRYYn5GSRfRYtHfprhJeOwL VqdbePXEzGzA7QYke6QISZ7LQjTnJDH1160ClsXoJ94PDpmRqi/UUFkQScbk9ey8hfw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146862; 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=Em1Dw7Gv+dWK9k7wMeevbakf7tHb0dlyYfzt38bD9Dc=; b=ASviCU5jxbECRJuf/tjesGPpDFUs1+RaOQXeJJLYx9M0/lmsYi4kDA+6qH/hiwUCsK/X JulYiZzZzDEkCoI+oZNgSkJoZNptuoREUCruLx/ZpINmfAQ3eU5/pBoZO9bK1wCVWkpf+ UaLLOIAd6x3ixOH05XQ1dduFZqHpdmmaMG6/Ev5gM3jp2vaJc4QGAcYecWyANCedcS/BB p7YVj2BHvD2uORTqPiEeyHQxRxzMHdg6aqngvhhG38JHc429wlH6j4oG23lOtGnGcbCmc TNd9bF5X+/g4XQoy2RvwgIAO92RXNX0arYlA8Ve7AVIdfazFEdXT4y1z8CzUs/rSItw== 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=UqkK5HNz; 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 C9381606A69B; Tue, 1 Dec 2026 17:41:02 +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=UqkK5HNz 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=1796146862; b=PMsIONKcPBG4wMrHLLAdxVlp95pl0ZmEfuRtDr9jcVQKVO7NzPAIDaOrgPLxq1wocfYL prw6qB0RN8/Z1eeA+eJnoVrM80gPlFwJ7vRPNsnj32AkHOHTJoYBRfM4cvw0UZmNJcuFe 3hUP2Zddd8wEuT1Eu8jCF33Kp3cN0HWYL1dBq2l1mzHA5mHcGsb/nh1ek38uSqWH7/nRR yJkknhdtFEfLgv+WZ7wOS8X8sj55z/nB/LaHlXh2ZdqzAz2f5J9S2ushdmpwyhjZWmcAo tkqhHIxmElgu/6IonYfIbjyCkrJTqWaftNm50/vqzn9vT3WyxjaLH1KMDibVDZXtxvA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146862; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Em1Dw7Gv+dWK9k7wMeevbakf7tHb0dlyYfzt38bD9Dc=; b=dlD2PIRLyBHRfpziIytEVU2R8VPWKzkRWPy7fuQ3aP2MgdoZV87A5I6GbPfzua9ln2/B Y8Kbreqcx1wzQPGCLZdRl7WKS3pOxUejevnbyJty/hWZIgFQUrhOBQSGpocHj/M+MxCcE PDT3hJ0gIecWWSd43BsazDoiElCy0QNifXDOmKFeh3N0Mc9vVAVYr1fy9DW+0+4dZC9gZ M/TylEXwnb7jCINqPSxz3/0GqpXUcN/yduHPfd5asA+4abdzi2IH2hCul7e8DQukhJrxx g9vArCLATxxZzFDZaG0DxJ06lBSoGtw/Q/4wfk0+QTa3GtCOj/WZjUKi9eTecenhIug== 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=UqkK5HNz; 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 EB259606A32E for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 17:41:01 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 886F71F0089C; Tue, 1 Dec 2026 17:41:00 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796146861; bh=Em1Dw7Gv+dWK9k7wMeevbakf7tHb0dlyYfzt38bD9Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UqkK5HNzDeCY8FGb1Fl/RxQyW+3iO0jD1Lv1TYx9Wzw5/A1yO64pu5fakBtC5gSEe flPtsl/SifX79kz2VGyuZTSNwVb/fKLFZDdN2o/8qNPlj3bGAYDqyEgocb7z7w+0Sv q0ucuGpbr98p8yvYez0V+8vF2PGG59Iplo+uW3S2ppoHEKhK4Bd41Ww7MAPrudYyLt 85VCLx/qjWa1XkMgI5sgk1esXvwqmXOuhBxaDa3nXkx9BMlYirSl5GVTWzomWwdzEw yFcyJsISaC27QIZCHYGPk/s8u+ieVKWQBEQEm5t2PFqBjWK1+OKPvac/psHtbohqzK ZTTyePbjKPsjw== X-Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, ralf@mandelbit.com, ja@ssi.bg, David Ahern <dahern@nvidia.com> X-Mailer: git-send-email 2.54.0 X-In-Reply-To: <20261201174021.7211-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