Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by David Ahern
Tue, 01 Dec 2026 17:40
[PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence
Author: 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)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads