From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Tue, 1 Dec 2026 17:41:01 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 886F71F0089C; Tue, 1 Dec 2026 17:41:00 +0000 (UTC) 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== From: David Ahern To: netdev@vger.kernel.org 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 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 Message-ID: <20261201174021.7211-6-dsahern@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261201174021.7211-1-dsahern@kernel.org> References: <20261201174021.7211-1-dsahern@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Ahern 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 --- 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)