Article View: linux.kernel.netdev
Article #20556[RFC net-next 0/6] ipv6: validate dsts against the netns route generation
From: David Ahern
Date: Sun, 22 Nov 2026 22:26
Date: Sun, 22 Nov 2026 22:26
63 lines
10736 bytes
10736 bytes
From: David Ahern <dahern@nvidia.com>
An IPv6 dst has never carried the fib6 serial number it was created
under. rt6_get_cookie() reads fn->fn_sernum through rt->from when a
socket, dst_cache or xfrm bundle stores its cookie, so a FIB change
that lands between the route lookup and the cookie capture is folded
into the cookie and a stale dst looks valid. The only dsts stamped at
creation are pcpu dsts of nexthop-object routes, which store the netns
genid in rt->sernum.
Looking at this I found that rt_genid_ipv6() and the fib6 serial
number are already the same counter: net->ipv6.fib6_sernum, which
fib6_new_sernum() advances on every FIB change. fn_sernum is a per-node
copy of it. So this series moves dst validation onto that counter, the
way IPv4 uses rt_genid, instead of adding another one:
1. Stamp every dst with the counter in ip6_dst_alloc() and validate by
comparison in ip6_dst_check(). Long-lived dsts (pcpu dsts of routes
with an embedded fib6_nh, and exception dsts) are re-stamped when a
lookup finds them again, otherwise they would stay invalid.
2. ip6_link_failure() forced a new lookup by writing -1 to fn_sernum.
That no longer invalidates anything, so clear the failing dst's
sernum instead.
3-4. Nexthop objects: factor out nh_has_f6i(), then bump the counter
when a nexthop used through a group is replaced, and when a member
is removed from a group.
5. A new PMTU or redirect exception used to bump the counter, which
with (1) would invalidate every dst in the namespace. Do what IPv4
does in update_or_create_fnhe() and invalidate only the pcpu dsts
of the affected fib6_nh. Route dumps still need to see that an
exception was added to the root node, so add a per-table sequence
for that rather than inventing fn_sernum values the counter could
later issue again.
6. Since nothing validates against fn_sernum any more,
rt_genid_bump_ipv6() no longer needs to walk every node of every
table. Make it an atomic increment like rt_genid_bump_ipv4(), and
drop the __fib6_flush_trees pointer. fn_sernum remains only for
route dump consistency, so nexthop, address and rule changes no
longer restart in-progress dumps.
David Ahern (6):
ipv6: validate dsts against the netns route generation
ipv6: invalidate the failing dst in ip6_link_failure()
nexthop: factor out nh_has_f6i()
nexthop: bump the IPv6 route generation on group changes
ipv6: scope exception invalidation to the affected nexthop
ipv6: make rt_genid_bump_ipv6() a plain counter increment
include/net/ip6_fib.h | 45 +++-------------
include/net/net_namespace.h | 26 ++++++---
net/ipv4/nexthop.c | 42 ++++++++++++---
net/ipv6/addrconf_core.c | 7 ---
net/ipv6/ip6_fib.c | 76 +++++++++++---------------
net/ipv6/route.c | 104 ++++++++++++++++++++++++------------
6 files changed, 162 insertions(+), 138 deletions(-)
--
2.43.0
Technical Details
Message-ID:
<20261122222717.126333-2-dsahern@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368855-linux-kernel-netdev=dewy.ruReferences:
<20261122222717.126333-1-dsahern@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368855-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [RFC net-next 0/6] ipv6: validate dsts against the netns route generation Date: Sun, 22 Nov 2026 15:26:58 -0700 Organization: Usenet Network Message-ID: <20261122222717.126333-2-dsahern@kernel.org> References: <20261122222717.126333-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3737351"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:n7pFRglmD8D1N+96cL/gB7sUgmw= sha256:CRoXnfYf2aHnO0M3lC7g9PXr2D/MyKKiF6pgeMatSKs= sha1:ST1VdW5mJ2jeRKpgmCVul9Ecd60= sha256:t00pTJBtRJerd8RRnil4vGdr0iemO2E4pgbQYSePMd4= 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 4974B125D8C; Mon, 23 Nov 2026 01:27:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 IivtBISJMcLs; Mon, 23 Nov 2026 01:27:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-368855-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 91267125D8A; Mon, 23 Nov 2026 01:27:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 4A3F221B3D; Sun, 22 Nov 2026 22:27:28 +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=1795386444; b=wRhDoFaCBNFHZGN1pkE+zHjQ5KoWGLkKyo6zHzQHmXlS4W7NwMOODqfQg4V7a5LNic0n dnm81YS0sxIj4jdHOkMpBBIm89Mzu//HoamuSqTi0lVueTC8k+NILfmX+RbOsRFXjlKOx 8rcmat/b4fMFT13MdrgwId4MIF7XeQXyxSqAPrD2j/74rqwSkVa2uYymUTxqsPZYHu3ro KJ4kC65kbxlGySNwapx+F/nJgOX6jVtYu82gCQD9bKpCsZkCtG5lv6P7u/riTIIYmpPkp OqRRJcp9hc8j5BmjyznRIhfzKsnyw5TNaLC7tyxDrumTDYJ53dlnh28qd07kWAYf+/Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795386444; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=qbRXlVCB7D5FhRXLboUHrGkLQd1PO+KQDpMzjFFF044=; b=LHJX27p6UVjsrfHm4A7R6oNEPeZX3SiGbmJiyr1pIy/xCXRHIN0qbj+mLrZX3IMtiyZq W4nuxKl/5tX8mWHRt0mIA4LOA6ocspNCJanoqMoyRMVJtfEUgDhhj9V8BGEvFUB6AdNwv u7u7PPHV32xBnWclYmHR9eBGQApPL1Vr7hdiWfySMRcJcDanKDLAY+tIlcAyD0houF/PT plPFPkgvOnF8HGXsIlOlH0GYi9aXx1VIqFgP5+muEAMoM3EB54EZqV0TTckwVhCyH3dQg wqdVqiM5SMuu5RYE7aJmMfLMvwAos5apDkrPt/zlFjV0XQLUuCYWrR7f/ChBss4MW4A== 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=iqiYGH3R; 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 33AB8606A33A; Sun, 22 Nov 2026 22:27:24 +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=iqiYGH3R 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=1795386443; b=Q5DbybhRUhMSCvN2s8QQGZsMWkrRdiH4ysMBJZGfKaF9kqYoQIeyhA7jJtv/A+9tD4E5 JNUPjA4hL2tlM9q2PMfa3APo3Ro8oENF+eRGkxgdLHwNQ+uUjPwkeTgy6XyU1q+tR2X6z 09QfAWGdkDI2bWZQNWxSeqIUI/f8ts69oc3CO+CIah9uj9/Le/Jh0LsgwlCJpfWUv4ndf ze/6RLthjAWHmZL5w62euDxqrPLcNVTuQ7FvoiiJSOVWneSaQnToRXAhddcMXPRFSgDJh WU4d/FF29G64dXV6fSM+4TcmcBGS4po2REbVlclKNCrXnUekYGCii7N1j7PVhyFVkMQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795386443; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=qbRXlVCB7D5FhRXLboUHrGkLQd1PO+KQDpMzjFFF044=; b=NXE9OVAC30bEFPbPCsMMz03Vw2FwyAaMZbIDTcO0ut7YLcCEomIgPDy5XXzb+HrwKwtr P8lYfpDOvfoD/rQpAwT/15CZ2Umfg3KIfNrfr0E3RM4gfjIDnTKMicsIUiQSFgIUax0fY icZ0kfDcNgR96jZ3HB0/FV2Wm+z75TDcPgOM/ubnLTzZAr4tq74rWcSP+G6twCJvVmOhc djhZqo3/qZOhZoKsW7S6nLDe8NdOdGupbisEjmlRSkFNlsjUJpBE7nuSnQJzT+QLjtzgP 3QVhhFMph63+dKtNzjKMfAd7tXoNpuFwQf/Q3DSlt0Fg9PP51dhThLjkxx39cSqqG/A== 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=iqiYGH3R; 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 4F2F1606A32A for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 22:27:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6003B1F000C0; Sun, 22 Nov 2026 22:27:22 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795386442; bh=qbRXlVCB7D5FhRXLboUHrGkLQd1PO+KQDpMzjFFF044=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iqiYGH3RVB7PaeSCwaWvKP8XkNhX9KJXRAooY1n6rRLLLshdosbgfZcP4E9GmW5Mm R40y3MmScXTHT7Y0K1tULvpRPACmfLl3E1g5pwE1qS74NIQWh5Wipj7ZB63zNWpP7S 27Y+ThrCNNxi96U+B76G1Aym2qM1AIEijBJBPPEu+EzQeF9annpfJmRSDZxbm03VPo fOeOo7pjtapy+EWXCQQEUOba2IE2/wEUzAZ4BtY21CVCPDyppG0jziIB7C8tAyAzzH 5s7wlxTNhTQD4iGe3pWGc1av7iJJgzr6B8y4k7zTjvjhHHqVoLMG4au7k3/gGeVnA1 cbtohM0ouHgUQ== X-Cc: ralf@mandelbit.com, David Ahern <dahern@nvidia.com>, David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org> X-Mailer: git-send-email 2.43.0 X-In-Reply-To: <20261122222717.126333-1-dsahern@kernel.org> 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