Re: [PATCH net] ipv6: advance the serial after rebalancing in fib6_ifup and fib6_ifdown
From: Ralf Lici
Date: Fri Nov 27 2026 - 07:10:27 EST
On Thu, 26 Nov 2026 09:13:51 +0100, Ralf Lici <ralf@xxxxxxxxxxxxx> wrote:
> fib6_ifup and fib6_ifdown update the node serial before calling
> rt6_multipath_rebalance. A lookup that runs between the two can select a
> nexthop using the old ECMP upper bounds and read the new serial as its
> cookie. The cached dst then passes dst_check although it was selected
> from the old state, until the next relevant change.
>
> Update the serial after rt6_multipath_rebalance, so that it is published
> only after the routing state it describes. fib6_new_sernum allocates the
> serial with a fully ordered atomic_try_cmpxchg, which orders the
> rebalance before the serial update. The invalidation scope is unchanged:
> fib6_ifup still updates the node and its ancestors, fib6_ifdown only the
> node.
>
> Validating dsts against the generation sampled before the lookup, as
> proposed in "ipv6: validate cached dsts against the netns route
> generation", relies on this order as well: a lookup that reads the new
> generation must also observe the routing change it describes.
>
> Reported by Sashiko while reviewing an earlier version of this change.
>
> Fixes: d7dedee184e7 ("ipv6: Calculate hash thresholds for IPv6 nexthops")
> Fixes: 4bc852006b62 ("ipv6: update route serial number on NETDEV_CHANGE")
> Link: https://lore.kernel.org/netdev/cover.1795642432.git.dahern@xxxxxxxxxx/
> Signed-off-by: Ralf Lici <ralf@xxxxxxxxxxxxx>
> Reviewed-by: Xia Yan <yanxia@xxxxxxxxxxxxxxxxxxxx>
Didn't receive Sashiko's review [1] by email this time and it's not on
the list either, not sure why.
Sashiko asks whether the reorder closes the race or only narrows it.
It closes the case described in the commit message: a lookup that runs
entirely between the serial update and the rebalance. A lookup that
selects its nexthop before both writes and reads the cookie after them
is the late cookie sampling race in general, which this patch does not
address on its own. The series in the Link closes it by sampling the
generation before the lookup, and relies on this order to do so, as the
third paragraph says.
I don't think this needs a respin, but I can send a v2 if you'd prefer
the commit message to say this explicitly.
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126081353.55240-1-ralf%40mandelbit.com
--
Ralf Lici
Mandelbit Srl