Article View: linux.kernel.netdev
Article #13077[PATCH net-next v3 3/4] nexthop: flush cached routes when a nexthop leaves a group
From: Qiliang Yuan
Date: Mon, 09 Nov 2026 08:18
Date: Mon, 09 Nov 2026 08:18
61 lines
10861 bytes
10861 bytes
When a nexthop is removed while other members keep its group alive, only
the group array changes: the routes through the group stay in the FIB,
and the dsts they cached through the removed nexthop are released when
that nexthop is freed, from an RCU callback.
Until then those dsts stay valid. IPv6 route exceptions, such as the
ones created on Packet Too Big, are checked against the cookie of their
FIB node, which does not change, so a socket keeps sending through the
removed nexthop. When the nexthop goes away with its device, removing
the device's IPv6 addresses usually flushes the routing tree first, but
not when the device carries no IPv6 address.
Flush the cached routes of each affected group once all readers see its
new array, as replacing a group already does. 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.
Datagrams still sent through nh 1 after the new group is published and
before nh 1 is freed, 10 trials, the one or two left after the change
being sent between synchronize_net() returning and the flush:
before after
datagrams per trial 395-4423 1-2
Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
net/ipv4/nexthop.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 42e55b5a755ee..e0089a6450e75 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2109,6 +2109,9 @@ remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
return false;
}
+static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
+ struct nexthop *replaced_nh);
+
static bool __must_check
remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
struct nl_info *nlinfo)
@@ -2130,6 +2133,13 @@ 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. Invalidate them now that
+ * no reader can pick @nh from the old groups any more.
+ */
+ list_for_each_entry(nhge, &deferred_free, nh_list)
+ nh_rt_cache_flush(net, nhge->nh_parent, nh);
+
/* Now safe to free percpu stats — all RCU readers have finished */
list_for_each_entry_safe(nhge, tmp, &deferred_free, nh_list) {
list_del(&nhge->nh_list);
--
2.43.0
Technical Details
Message-ID:
<20261109-bug-net-netns-move-rcu-barrier-v3-3-6084b02610b3@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359123-linux-kernel-netdev=dewy.ruReferences:
<20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359123-linux-kernel-netdev=dewy.ru From: qiliang.yuan@linux.dev (Qiliang Yuan) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v3 3/4] nexthop: flush cached routes when a nexthop leaves a group Date: Mon, 09 Nov 2026 03:18:14 -0500 Organization: Usenet Network Message-ID: <20261109-bug-net-netns-move-rcu-barrier-v3-3-6084b02610b3@linux.dev> References: <20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="307196"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:/zavWJ1gNOAvDbZ9SmD3ZqHj1Ok= sha256:+kh8nnSLSW84v0bkSydT/Aaf/gird/VXPJeAS7XZ5vg= sha1:f811lYyzD2pcZOg8al6cgff3KMc= sha256:Ml7aLHXKYlcLPWu/GghodX0a4sZ29LkMs99/hW797NU= 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 3AA3A113741; Mon, 9 Nov 2026 11:22:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev 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 STl0uttjLhMs; Mon, 9 Nov 2026 11:21:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359123-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id DB894113730; Mon, 9 Nov 2026 11:21:48 +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 C1E8EE7B9F; Mon, 9 Nov 2026 08:18: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=1794212328; b=W/N6c5p6s1/N1i48cgN/Ip2anytIhClEyigDHuq7SE4aYiXwqeWzhtyRx16UX59+BS6Y FKb+2YX/hDaRAqmUQdVtG12GlMz6yjhNtM8I53rfnbkmnXMGzviuMcbVucGIbOruaoIV9 Y9cb/pAlovWcL2KiNJbFrGHbUOS3RWB/hIvIUVwgEzxcFSMDWbqjpBfbUri2ZNiXNS+84 cAvbM4b5YtixwOX9x2enjcBOFbxfgQ/SVreBX8lpX5/kH3Bidx5A/3r+PpWB3PZv+WN0K OUPTJM1pS/iWA72VH4vLzQmGfHjeQJJspn3qU7AT9JOm01vMCiZDX1tj71s8vy2ul2g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794212328; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer; bh=LbKm7kJZnVDCUFkPTQ8FL3AQnqnNWdJ/bsGB19ACkvg=; b=hgHDhGWWxkYJbwTvKbSHIIEMAp9iXvVMagyEwuCWosHKMbBdwDcX6uNq725QUVASZuGk R9DnWDCmkkgJ6YQPlxLGmShA/fx9YhOcseiSsj8+73IvVWGNII8bMjDgqiSAne8cUfu9Y xrN5D9jJbF1YvcfW4I+mNUGkAZfqBDYeXJcM/Z48GxomVT0f49mLRo8ps918lJDiQuR2i hVdixymen4jJDw/0WEj2d4MjBryVJWMT49JHHCcKY/+jV2i1BkDb0HDA1Yso3l7eVVBZI 8jY4K+BpP/pNSKxTWHnvdhEoDa3QrkaoqQ8+TvTB+rIuxCs1UuSZZJ/cxQapkBReYcg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vViUmp6G; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 82023606A338; Mon, 9 Nov 2026 08:18:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vViUmp6G X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.162 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794212327; b=WlLYiANdxe223OwM1xcXslIfJXY/0j3Naq2rdvKg3OSa4/Z41c4zJgqAjWeBMCE3/7jC UFCrNxDDIsEbZG48JWitF8jgM3EXTtqR1LDo7iprLku+HGNz0/66+fGGXhKYGKrPv7tZ+ Id3O/MQAvEH11q3ngTklO/6TMDtndIB0Pt2HUAAPRhMWnxwZPEPHoqNhNfYd5kL65cg6a 6RZF7F7MiWXEIE7JfcoDK56AMfi3LJHwhqb8GGuh14EXkYETZlT9dpTt9bWDA5kVF44kc UEL4854LxwIdJzTjg8ZUw/+Ldjs8150dgqW9zQzLt8e3YucKhdR+hdD8ljzFWJkXW2Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794212327; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=LbKm7kJZnVDCUFkPTQ8FL3AQnqnNWdJ/bsGB19ACkvg=; b=N1JgPiATOa+NQOF35mD2IJyoDj+6dwkDr/I5VS2LnMC7KI72sIQYRVt+OKiCo21YtFcQ ZGrY4dzGeZ5oYI9eLtGvf5NjWwiFaWr7O1skdA8aqSrqQ3TyaM36qQFImdgUTwsSO38oS 71tZWfxx+EbAti/QTvWwkai1RrbERbYzcnMoP7pkNxdyq2smS2NCm8dH3W//Ns/jQbEqI 0LGHekDbF9SYu+3PNBRQL/pjfMbihoZpmZN1sVjF1qt6EXZltpo08n3sKGDLIXPxgZwUV ViaF5OVlqgQ+BeQOej+Vr46crqvyTH4Cm6j3LAZ2ih6BwcTAG1vqRBPwpq/M/fq+YFg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vViUmp6G; arc=none smtp.remote-ip=91.218.175.162 X-Received: from mta0.migadu.com (out-162.mta0.migadu.com [91.218.175.162]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0D48606D804 for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 08:18:46 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0D48606D804 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=t6DAMmrQ/ek3RuXBK/3/jv3+3PoeJVRD8BaQxUbGh9k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794212324; v=1; x=1794817124; b=vViUmp6GQQzxbF06SbqFCg4FN8cnyjtfbKA/qfv4tMVNFZv3Ry/itrecCckfFyD+9u8qbKkZ 5pcvYu2PrEUgq+KlEIsC18B3JrKLefb0wOgJIZikAnNW362MDZERcRR0saj3SgILAube6Y1vW86 xzkfsYzhxuhEAif4RPGWu16U= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id cfebcddeb0e48edb; Mon, 09 Nov 2026 08:18:44 +0000 X-Mizu-Trace-ID: cfebcddeb0e48edb X-Migadu-Flow: FLOW_OUT 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 X-In-Reply-To: <20261109-bug-net-netns-move-rcu-barrier-v3-0-6084b02610b3@linux.dev> X-Cc: Kuniyuki Iwashima <kuniyu@google.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Qiliang Yuan <qiliang.yuan@linux.dev> X-Mailer: b4 0.13.0