Re: [PATCH net-next 2/2] ipv6: allocate the flush serial under each table's lock

From: netdev-bot+sashiko

Date: Sat Dec 05 2026 - 06:47:37 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] ipv6: __fib6_clean_all() bumps fib6_sernum per table,
thrashing nexthop dsts

--

> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -2344,8 +2347,10 @@ static void __fib6_clean_all(struct net *net,
> head = &net->ipv6.fib_table_hash[h];
> hlist_for_each_entry_rcu(table, head, tb6_hlist) {
> spin_lock_bh(&table->tb6_lock);
> - fib6_clean_tree(net, &table->tb6_root,
> - func, sernum, arg, skip_notify);
> + if (sernum == FIB6_NEW_SERNUM)
> + table_sn = fib6_new_sernum(net);
> + fib6_clean_tree(net, &table->tb6_root, func,
> + table_sn, arg, skip_notify);
> spin_unlock_bh(&table->tb6_lock);
> }
> }

[Severity: Medium]
This now advances net->ipv6.fib6_sernum once per table in
fib_table_hash, where before it advanced once per flush. That counter
is not only used for node stamps. rt_genid_ipv6() returns it directly,
and nexthop-backed routes (f6i->nh != NULL) record it in
pcpu_rt->sernum in ip6_rt_pcpu_alloc(). rt6_is_valid() then checks it
with exact equality.

So a single fib6_flush_trees() call can now invalidate every
nexthop-backed dst up to T times, with a full fib6_clean_tree() walk
between each bump.

A CPU that hits rt6_get_pcpu_route() during the flush can drop its
pcpu_rt with dst_dev_put() and dst_release(), then reallocate it in
rt6_make_pcpu_route(). That new dst goes stale again as soon as the
walk moves on to the next table. Likewise, ip6_dst_check() keeps
failing for connected sockets for the whole flush.

fib6_link_table() never unlinks tables, so empty tables in a VRF or
policy routing setup add to the count for the lifetime of the netns.

On a default setup with only main and local this is minor. With many
tables, though, one global invalidation turns into many.
rt_genid_bump_ipv6() is called from addrconf, fib rules, nexthop
replace and xfrm, so routine control plane events reach this path.

Could the per-table allocation be skipped for tables that have nothing
to stamp? Alternatively, fib6_flush_trees() could keep a single serial
and have fib6_clean_node() leave alone nodes that already carry a
newer one, once the age comparison lands later in the series. Either
way, it would be good to mention the effect on nexthop dsts in the
changelog.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796382778.git.ralf%40mandelbit.com