🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20577

Re: [PATCH net-next v5 3/4] nexthop: release cached routes when a nexthop leaves a group

#20577
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 00:25
178 lines
14516 bytes
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
Technical Details
Message-ID: <179539354580.3135.4168319613426691276@kernel.org>
Path: mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368880-linux-kernel-netdev=dewy.ru
References: <20261121-bug-net-netns-move-rcu-barrier-v5-3-100a3b5d9090@linux.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368880-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179539354580.3135.4168319613426691276@kernel.org>
References: <20261121-bug-net-netns-move-rcu-barrier-v5-3-100a3b5d9090@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3752839"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:v0XWCIekNsQJGzW8tNNF4N8rKks= sha256:/QTjVdL8bFUu/iZLdO+b5/7Ikha4ozXA3tB1UiB2KAE=
	sha1:N9wxVwkJMua9WeZWK6jpl6xGxNY= sha256:sItKkKUJpfBgjOMTRVayt2ShQKmncuV0TgQqyrxAlPI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DE395125D88; Mon, 23 Nov 2026 03:26:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id cfpY41qGxcGb;
	Mon, 23 Nov 2026 03:26:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368880-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id ED8CA125D83; Mon, 23 Nov 2026 03:25:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 712462BC7F; Mon, 23 Nov 2026 00:25:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795393548;
	b=jkGyBE9nQy+xjsehDlp3dDTseB3xhF9Qtv3vZWlyY8AU+sVF61ZCstcUp0zsHVYzv7Ly
	 Gwow8FGttwAlvtPf6FtLBwbbUXkxkzLA5xespplBfJLpd3i8iEbaq95B0OoaFZCAa1zJC
	 mmQ83icjXWMk9O+Ek5jytbgw3fSeUhbeM/O7YHBt2FoG2JwGrunKxfjFJt9yzzEJoVpr0
	 Wir+LEIwdKiYSNbPziYNgSvgrS+vxdYkd8Lx3r8nTVG/8aY4mE7pn54scUQzY8BInPt8y
	 WX4P6LE/tnL1ybO6mVOsKnzecaCRUT+CvlS/Rig5wzBkpeziaHEh3zG1qD/BF5+km5g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795393548;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=TZ0rpHy2ujwVMpfaHpoxQQNYlgDHNkNxkEJF98FFsmc=;
	b=oIIidgihqszpHea9VgrALMkRFdRSUhYdAt7Y8X/SW0LTUtklCd4OiQqXZAAxIC+7eZzL
	 pSfbc8HyeujNbagKcqNs0NM5+3Lui78HLXdmuhoqywwthAgNqSpR4TsLgk1CiKjCEyzGz
	 MybhP8psD4o6eCSvyJ8wAwpLin+mtCfFH3ZlcjLUhLK2ORSUl1FHtXyWuGsRdTEfoKVf3
	 sufw1wNOPa3mvP0e2UYII8GLdw3hmRHJLZxgcsBXxS/eeWfm+/Pbh5lWLmhCk2HpktKnd
	 N9NtniciKxueJcHitrIU7/jN9FrCaRQg8T12LWZ2Ms7Qh/q75MlQ/0d81B5pNONP6Qw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="ASoP2Te/";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1122B606A331;
	Mon, 23 Nov 2026 00:25:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ASoP2Te/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795393547;
	b=0/Z8bb1MmK0SSPqz0Ab1u+hpKTeC8fsP9WvW0ZoQd6d9E1dp3am9M3cMLIxFWW/f92v2
	 gaNRDR7LiuRqVjWfu5vmonbhDtYU9+fwuw9eycNqhfU9O+7q0ZZ7knFVyykQYUX4pa6Y4
	 6SQzhdA1C49SP4JmsW5qmZs3Oxo6+wk/2a3VGuultXxVEK26VJx+QL9KFyJCrBanY/UMs
	 mAEFDB2Xqe7K+yE8yLeUyY8trMGRa0hJo+lHdg5DaSd9uRlvOYEFJAv4HaptYvT7dTIXE
	 YamVPGzcPpW8eseWp03FPwsXj1+MeMfjX3lcixvJtRPBebsqmxHkuGzoQW5DLBE6JRQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795393547;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=TZ0rpHy2ujwVMpfaHpoxQQNYlgDHNkNxkEJF98FFsmc=;
	b=kRh0XwbG116XDTVgjGDaA5XAihr+D9S+uDnfBpytv6KiD1SWbJQjKFidc6miwX4HoGCF
	 FN+n+BBwydO6zdLX9PnI9+oihmis9w5ODDe79rqmRZ93ebt7Z6qzDzRKk4WTCw5qTZjB3
	 u17kitfv4rXU+cC+wL1pQKe88POE6szGkLRqkPBYMY7NmVshGgGW8Fh0nA357+9cxG8T7
	 zDrXfi81V4munaQTqIWZyH1jz8iJE7nedo2hX3lphdAOuNfkC/ga6NxmFMatkPpzfWUG2
	 FimOwB6MDLl/qVDXbGxZwYyFo6u8BU/IDz0PazhXNeQ4fj+00mgwZE9poJa/ed3YEYQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="ASoP2Te/";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30F13606A333;
	Mon, 23 Nov 2026 00:25:47 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 381821F000D3;
	Mon, 23 Nov 2026 00:25:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795393546;
	bh=TZ0rpHy2ujwVMpfaHpoxQQNYlgDHNkNxkEJF98FFsmc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ASoP2Te/0ariVjgsd04Nzl6wIkNiGiKQPudHfxhzn4GdcKMwY5ksurj/epOR92qJ+
	 4Jkt7XvGwiMVUKBl0QPsRlFo/80oPD5/tDOShvlgecMDgDCVs5T7NRP6ilV8XKz7h5
	 Tbgf+RvmdYmB6kDntD/bSFl2LcJRFFgXRLH+uCsa0+XDg3SblzV5IM+w2G2VVE3sEn
	 YsjGZHbaiBR9YWWD0uX1Pj7fnQ39gza4BYPh66h4tAXNNcWb9L2MyDBxYYdN+In1Ng
	 0E3DPFf9PnjrhNbeT/5XZ5e80GsrlPP1B2xJIv9r2KEEoBTH+33B6ESKNsxrCRB7LZ
	 CTp/cavMGYbNw==
X-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
X-In-Reply-To: <20261121-bug-net-netns-move-rcu-barrier-v5-3-100a3b5d9090@linux.dev>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list