mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: qiliang.yuan@linux.dev
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org,
	idosch@nvidia.com, razor@blackwall.org, kuniyu@google.com,
	ralf@mandelbit.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 3/4] nexthop: release cached routes when a nexthop leaves a group
Date: Mon, 23 Nov 2026 00:25:45 +0000	[thread overview]
Message-ID: <179539354580.3135.4168319613426691276@kernel.org> (raw)
In-Reply-To: <20261121-bug-net-netns-move-rcu-barrier-v5-3-100a3b5d9090@linux.dev>

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

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

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).

- [High] The patch adds IPv6 dst release to remove_nexthop_from_groups(),
  but it skips the IPv6 invalidation step that the group-replace path…
- [Medium] The same stale-dst window remains when a group member is
  replaced in place (RTM_NEWNEXTHOP with NLM_F_REPLACE on a non-group…
- [Low] The commit describes user-visible behaviour (a socket keeps
  sending through a deleted group member until the nexthop is freed from…

--

nexthop: release cached routes when a nexthop leaves a group

This patch changes remove_nexthop_from_groups() so that, once the new
group arrays are published, it releases the per-cpu routes and exceptions
of a removed IPv6 nexthop. It also flushes the IPv4 route cache if any of
the affected groups carries IPv4 routes. The aim is to stop sockets from
sending through a nexthop that has left a surviving group while they wait
for that nexthop to be freed from RCU.

> A connected UDP socket in netns A sends to a route through group {nh 1,
> nh 2}, on an IPv6 exception of nh 1 created by Packet Too Big, while nh 1
> is deleted.

[ ... ]

> Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>

[Severity: Low]
This isn't a bug, but the commit message describes a user-visible
behaviour: a socket keeps sending through a deleted group member until
the nexthop is freed. There is no Fixes: tag, though.

Should one be added if this is meant as a fix? Or is the patch only
net-next groundwork for the rest of the series?

> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 42e55b5a755ee..3fccd4f2f916b 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c

[ ... ]

> @@ -2130,6 +2131,20 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
>  	/* make sure all see the newly published array before releasing rtnl */
>  	synchronize_net();
>  
> +	/* Routes through the groups can still hold dsts cached through @nh,
> +	 * which are only released when @nh is freed. Release them now that
> +	 * no reader can pick @nh from the old groups any more.
> +	 */
> +	nhi = rtnl_dereference(nh->nh_info);
> +	if (nhi->family == AF_INET6)
> +		fib6_nh_release_dsts(&nhi->fib6_nh);

[Severity: High]
Does this also need an rt_genid_bump_ipv6()? The commit message says this
works "as replacing a group already does for its old members". However,
nh_rt_cache_flush() bumps the IPv6 genid before it releases the old dsts:

net/ipv4/nexthop.c:nh_rt_cache_flush() {
    ...
	if (have_f6i)
		rt_genid_bump_ipv6(net);
    ...
		if (nhi->family == AF_INET6)
			fib6_nh_release_dsts(&nhi->fib6_nh);
    ...
}

Without the bump, can the released per-cpu dsts still pass
ip6_dst_check()? A per-cpu route of a group route has a non-zero sernum.
That means ip6_dst_check() returns early and never looks at
dst->obsolete:

net/ipv6/route.c:ip6_dst_check() {
    ...
	if (rt->sernum)
		return rt6_is_valid(rt) ? dst : NULL;
    ...
}

rt6_is_valid() compares the sernum against
rt_genid_ipv6(dev_net(rt6->dst.dev)). fib6_nh_release_dsts() calls
dst_dev_put(), which does two things to the dst:

  - it moves the dst to blackhole_netdev, which lives in init_net
  - it sets dst->output to dst_discard_out

In init_net, the sernum still matches if no other IPv6 FIB change has
happened since the per-cpu route was created. Take a connected UDP
socket with no bound oif. Would it keep the dead dst through
ip6_sk_dst_check() and silently drop every datagram? It would never look
the route up again and move to the remaining members.

Before the patch the same thing happened one grace period later, in
nexthop_free_rcu(). The patch makes it happen immediately. The test in
the commit message ran in a non-init netns on a PMTU exception (sernum
0), so it would not show this.

There is a second case. When the nexthop has no gateway, ip6_pol_route()
builds uncached rt6_infos for FLOWI_FLAG_KNOWN_NH lookups. These users
take that path:

  - IPVS DR mode, through __ip_vs_route_output_v6() and
    __ip_vs_dst_check() with a stored cookie
  - nf_dup_ipv6
  - raw hdrincl

Those dsts are checked by rt6_dst_from_check() -> fib6_check() against
the group f6i and the cookie. fib6_nh_release_dsts() never reaches them,
and the node sernum does not change. Can they keep sending through the
removed nexthop with no time limit?

Would it cover both cases to bump the IPv6 genid when any
nhge->nh_parent->f6i_list is non-empty, like the fi_list check below?

> +	list_for_each_entry(nhge, &deferred_free, nh_list) {
> +		if (!list_empty(&nhge->nh_parent->fi_list)) {
> +			rt_cache_flush(net);
> +			break;
> +		}
> +	}

[Severity: Medium]
Is the same stale-dst window still open when a group member is replaced
in place? One example is "ip nexthop replace id N ...", where N belongs
to a multipath group and no route uses N directly.

replace_nexthop_single() swaps nh_info. After the swap, the old
fib6_nh/fib_nh and their cached dsts belong to the temporary new
nexthop:

net/ipv4/nexthop.c:replace_nexthop_single() {
    ...
	rcu_assign_pointer(old->nh_info, newi);
	rcu_assign_pointer(new->nh_info, oldi);
    ...
}

replace_nexthop() then does:

net/ipv4/nexthop.c:replace_nexthop() {
    ...
		nh_rt_cache_flush(net, old, new);

		WARN_ON_ONCE(__remove_nexthop(net, new, NULL));
		nexthop_put(new);
    ...
}

nh_rt_cache_flush() only checks old->fi_list and old->f6i_list. Those
lists hold routes that use old directly, not routes through the groups.
The function then returns at !replaced_nh->is_group without releasing
the old IPv6 dsts.

__remove_nexthop(net, new, NULL) does reach remove_nexthop_from_groups().
But new->grp_list is empty, so it returns early and the new release code
never runs. The per-group loop in replace_nexthop_single() only sends
hardware notifications.

So the per-cpu IPv6 dsts, the IPv6 exceptions and the IPv4 rtables built
on the old nh_info would stay valid until nexthop_free_rcu() frees new.

Should this path get the same treatment?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121-bug-net-netns-move-rcu-barrier-v5-0-100a3b5d9090%40linux.dev

  reply	other threads:[~2026-11-23  0:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 23:21 [PATCH net-next v5 0/4] net: make moving a device to another netns cheaper Qiliang Yuan
2026-11-21 23:21 ` [PATCH net-next v5 1/4] ipv4: draw rt_genid from a sequence shared by all netns Qiliang Yuan
2026-11-22  9:02   ` Ralf Lici
2026-11-23  0:25   ` netdev-bot+sashiko
2026-11-21 23:21 ` [PATCH net-next v5 2/4] ipv6: take fib6_sernum " Qiliang Yuan
2026-11-22  9:03   ` Ralf Lici
2026-11-23  0:25   ` netdev-bot+sashiko
2026-11-21 23:21 ` [PATCH net-next v5 3/4] nexthop: release cached routes when a nexthop leaves a group Qiliang Yuan
2026-11-23  0:25   ` netdev-bot+sashiko [this message]
2026-11-21 23:21 ` [PATCH net-next v5 4/4] net: remove rcu_barrier() from __dev_change_net_namespace() Qiliang Yuan
2026-11-23  0:25   ` netdev-bot+sashiko

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=179539354580.3135.4168319613426691276@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=qiliang.yuan@linux.dev \
    --cc=ralf@mandelbit.com \
    --cc=razor@blackwall.org \
    /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

all inboxes | Powered by JetHome®