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

From: Ralf Lici

Date: Sun Dec 06 2026 - 05:25:55 EST


On Sat, 05 Dec 2026 11:47:23 +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
> > 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.
>

Only lookups that run while the walk is in progress see the extra
advances. Holders check their dst lazily, so each one is invalidated once
per flush, and a lookup after the flush builds a dst that stays valid.

> 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's second suggestion needs comparing serials by age, which the
follow-up series using these serials introduces, so I can switch to that
there if the per-table advance turns out to matter.

--
Ralf Lici
Mandelbit Srl