Re: [PATCH net-next v4 1/5] ipv6: stamp the default route node with a fresh serial on link failure

From: netdev-bot+sashiko

Date: Tue Nov 24 2026 - 05:27:12 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch makes ip6_link_failure() (net/ipv6/route.c) do much
more work for an RTF_DEFAULT, non-RTF_CACHE dst.

--

ipv6: stamp the default route node with a fresh serial on link failure

This commit changes ip6_link_failure() so that it no longer writes -1 into
fn_sernum of an RTF_DEFAULT route's node. It now calls fib6_update_sernum()
under tb6_lock, which allocates a fresh serial and advances the netns-wide
fib6_sernum generation. The changelog says the extra cost happens once per
queued skb when the neighbour of the default router fails.

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 4a4c5ace63c54..bbe6d67bb6964 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c

[ ... ]

> @@ -2873,13 +2875,13 @@ static void ip6_link_failure(struct sk_buff *skb)
> rt6_remove_exception_rt(rt);
> } else {
> struct fib6_info *from;
> - struct fib6_node *fn;
>
> from = rcu_dereference(rt->from);
> - if (from) {
> - fn = rcu_dereference(from->fib6_node);
> - if (fn && (rt->rt6i_flags & RTF_DEFAULT))
> - WRITE_ONCE(fn->fn_sernum, -1);
> + if (from && from->fib6_table &&
> + (rt->rt6i_flags & RTF_DEFAULT)) {
> + spin_lock_bh(&from->fib6_table->tb6_lock);
> + fib6_update_sernum(rt6_exception_net(rt), from);
> + spin_unlock_bh(&from->fib6_table->tb6_lock);

[Severity: Low]
Is the cost of this path limited to neighbour failure, as the commit
message says?

This happens once per ip6_link_failure call, so once per queued skb
when the neighbour of the default router fails.

Several tunnel transmit error paths call dst_link_failure(skb) once per
packet. For an IPv6 inner packet the inner route's dst is still attached,
so they reach ip6_link_failure():

ipip6_tunnel_xmit() in net/ipv6/sit.c:
tx_error_icmp:
dst_link_failure(skb);

This one is taken when ip_route_output_flow() fails or when the underlay
route is not unicast or local.

ip6_tnl_xmit() in net/ipv6/ip6_tunnel.c:
tx_err_link_failure:
DEV_STATS_INC(dev, tx_carrier_errors);
dst_link_failure(skb);

This one is taken when ip6_route_output() returns dst->error, when
xfrm_lookup() fails, or when ip6_tnl_xmit_ctl() fails. skb_dst_set() runs
later than this, so skb_dst is still the inner IPv6 route here.

ip_tunnel_xmit() in net/ipv4/ip_tunnel.c also reaches tx_error_icmp in the
NBMA case when the IPv6 next hop is not v4-compatible.

There are also the err_count paths in ip_tunnel_xmit(),
ipip6_tunnel_xmit() and ip6_tnl_xmit():

WRITE_ONCE(tunnel->err_count, err_count - 1);
dst_link_failure(skb);

These run once per ICMP error received for the tunnel, so a remote host
can drive them.

RA-learned default routes carry RTF_DEFAULT, for example a default router
learned over ISATAP/sit, gretap or ip6gretap. pcpu copies keep the flag
through ip6_rt_copy_init().

While the underlay is broken, wouldn't every IPv6 packet sent through
such a route take tb6_lock with BH disabled? Each one would also run
fib6_new_sernum()'s atomic_try_cmpxchg on net->ipv6.fib6_sernum.

tb6_lock is the same lock that route insert/delete, GC and PMTU exception
insertion use. Each generation bump also invalidates every nexthop-object
dst in the netns, because rt6_is_valid() checks those against the netns
generation. Later in the series, ip6_dst_lookup_flow_cookie() returns
cookie 0 to socket lookups that race with a bump.

These are error paths where the traffic is already being dropped. Also,
rt6_insert_exception() already takes tb6_lock and bumps the generation on
remotely triggered PMTU exceptions. Still, the cost here seems to scale
with packets on these tunnel paths, not with neighbour queue length.

Could the changelog mention these callers? Would it be worth
rate-limiting the bump, or skipping it when the node's serial has already
moved past the one the dst cached?

> }
> }
> rcu_read_unlock();

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