From: netdev-bot+sashiko@kernel.org
To: ralf@mandelbit.com
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org,
sharmasagarika@google.com, kuniyu@google.com,
yanxia@cmss.chinamobile.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] ipv6: advance the serial after rebalancing in fib6_ifup and fib6_ifdown
Date: Fri, 27 Nov 2026 08:15:15 +0000 [thread overview]
Message-ID: <179576731529.3135.10238815120466881443@kernel.org> (raw)
In-Reply-To: <20261126081353.55240-1-ralf@mandelbit.com>
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] Moving fib6_update_sernum()/fib6_update_sernum_upto_root()
after rt6_multipath_rebalance() in fib6_ifup() and fib6_ifdown() makes…
--
ipv6: advance the serial after rebalancing in fib6_ifup and fib6_ifdown
This patch moves the fn_sernum update in fib6_ifup() and fib6_ifdown() so
it happens after rt6_multipath_rebalance(). The new serial is then
published only after the ECMP upper bounds it describes. The fully ordered
atomic_try_cmpxchg() in fib6_new_sernum() orders the rebalance before the
serial store.
Link: https://lore.kernel.org/netdev/cover.1795642432.git.dahern@nvidia.com/
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 1b2dcc066e198..194432f1fd66b 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
[ ... ]
> @@ -5015,8 +5015,8 @@ static int fib6_ifdown(struct fib6_info *rt, void *p_arg)
> }
> rt6_multipath_nh_flags_set(rt, dev, RTNH_F_DEAD |
> RTNH_F_LINKDOWN);
> - fib6_update_sernum(net, rt);
> rt6_multipath_rebalance(rt);
> + fib6_update_sernum(net, rt);
> }
> return -2;
[Severity: Medium]
Does this reorder close the race, or does it only make the window smaller?
Some multipath routes do not use nexthop objects (rt->nh == NULL). For
those, ip6_rt_pcpu_alloc() leaves pcpu_rt->sernum at 0:
net/ipv6/route.c:ip6_rt_pcpu_alloc() {
...
if (f6i->nh)
pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));
...
}
The cookie therefore comes from fn->fn_sernum through
rt6_get_cookie()->fib6_get_cookie_safe(). It is read only after the lookup
has finished, for example in ip6_dst_store():
np->dst_cookie = rt6_get_cookie(dst_rt6_info(dst));
inet6_sk_rx_dst_set(), udp6_sk_rx_dst_set() and xfrm6_fill_dst() also read
the cookie after the dst has been selected.
Before that, the lookup reads the nexthop state without the lock, in
fib6_select_path() and in rt6_score_route():
if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound)) {
So the reader reads upper_bound and flags first, then fn_sernum. With this
patch the writer stores flags and upper_bound, issues a full barrier, then
stores fn_sernum. That order only pairs with a reader that reads the
serial first.
The smp_rmb() in fib6_get_cookie_safe() comes after the fn_sernum read.
It cannot order the earlier upper bound reads.
Can this interleaving still happen?
CPU0 (connect()) CPU1 (fib6_ifdown(), NETDEV_DOWN)
fib6_select_path()
selects sibling A with
old upper bounds/flags
rt6_multipath_nh_flags_set()
A |= RTNH_F_DEAD | RTNH_F_LINKDOWN
rt6_multipath_rebalance()
fib6_update_sernum()
fn_sernum = N + 1
ip6_dst_store()
np->dst_cookie = N + 1
Later, ip6_dst_check()->rt6_dst_from_check()->fib6_check() compares N + 1
with N + 1. It accepts the cached dst for the dead nexthop A.
The NETDEV_CHANGE path in fib6_ifdown() has the same ordering. So does
fib6_ifup() with fib6_update_sernum_upto_root().
The commit message says:
The cached dst then passes dst_check although it was selected
from the old state, until the next relevant change.
That outcome looks reachable whenever a lookup overlaps both writes. The
patch only removes the case where the whole lookup falls between the
serial bump and the rebalance.
A full fix seems to need the reader to sample the generation before the
lookup. The separately proposed "ipv6: validate cached dsts against the
netns route generation" series does that.
This patch carries Fixes: tags and may be backported without that series.
Could the commit message say that the patch narrows the window rather
than closes it?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126081353.55240-1-ralf%40mandelbit.com
next prev parent reply other threads:[~2026-11-27 8:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 8:13 [PATCH net] ipv6: advance the serial after rebalancing in fib6_ifup and fib6_ifdown Ralf Lici
2026-11-26 8:18 ` netdev-bot+sinfo
2026-11-26 8:24 ` Ralf Lici
2026-11-26 15:40 ` David Ahern
2026-11-27 8:15 ` netdev-bot+sashiko [this message]
2026-11-27 10:07 ` Ralf Lici
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179576731529.3135.10238815120466881443@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.com \
--cc=sharmasagarika@google.com \
--cc=willemb@google.com \
--cc=yanxia@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox