🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25398

[PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted

#25398
From: David Ahern
Date: Tue, 01 Dec 2026 17:40
141 lines
13115 bytes
From: David Ahern <dahern@nvidia.com>

Add a test that learns a PMTU from a packet too big message, changes
the FIB with a route that has nothing to do with the destination, and
deletes the cached exception without looking the destination up in
between. After a FIB change the exception's dst is stale, and a lookup
that handed it out would replace it with a current copy: deleting it
must work on a stale exception too, and nothing may then bring it back.

Check that neither a route lookup nor a packet that fits, which looks
the route up as well, creates the exception again, and that a packet
that exceeds the PMTU does, through a new packet too big message. The
cache is dumped to see the exception, as that does not look the
destination up and so does not refresh it.

The test is run again with nexthop objects like the other exception
tests, which takes the deletion through the nexthop path.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
 tools/testing/selftests/net/pmtu.sh | 90 +++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index c7cd271714ef..5e44ff3a6515 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -198,6 +198,14 @@
 # - pmtu_ipv6_route_change
 #	Same as above but with IPv6
 #
+# - pmtu_ipv6_cached_del
+#	Use the same topology as in pmtu_ipv6. Learn a PMTU from a packet too big
+#	message, change the FIB with an unrelated route add and, without looking
+#	the destination up in between, delete the cached exception. Check that
+#	neither a route lookup nor a packet that does not exceed the PMTU
+#	brings the exception back, and that a packet that does exceed it
+#	creates a new one
+#
 # - pmtu_ipv4_mp_exceptions
 #	Use the same topology as in pmtu_ipv4, but add routeable addresses
 #	on host A and B on lo reachable via both routers. Host A and B
@@ -272,6 +280,7 @@ tests="
 	list_flush_ipv6_exception	ipv6: list and flush cached exceptions	1
 	pmtu_ipv4_route_change		ipv4: PMTU exception w/route replace	1
 	pmtu_ipv6_route_change		ipv6: PMTU exception w/route replace	1
+	pmtu_ipv6_cached_del		ipv6: delete a cached PMTU exception after a FIB change	1
 	pmtu_ipv4_mp_exceptions		ipv4: PMTU multipath nh exceptions	1"
 
 # Addressing and routing for tests with routers: four network segments, with
@@ -2377,6 +2386,87 @@ test_pmtu_ipv6_route_change() {
 	test_pmtu_ipvX_route_change 6
 }
 
+# Is there a cached exception for ${2} in the namespace ${1}? Dumping the cache
+# does not look the destination up, so it does not touch the exception
+cached_exception_exists() {
+	ns_cmd="${1}"
+	dst="${2}"
+
+	${ns_cmd} ip -oneline -6 route list cache | grep -qw -- "${dst}"
+}
+
+test_pmtu_ipv6_cached_del() {
+	setup namespaces routing || return $ksft_skip
+	trace "${ns_a}"  veth_A-R1    "${ns_r1}" veth_R1-A \
+	      "${ns_r1}" veth_R1-B    "${ns_b}"  veth_B-R1 \
+	      "${ns_a}"  veth_A-R2    "${ns_r2}" veth_R2-A \
+	      "${ns_r2}" veth_R2-B    "${ns_b}"  veth_B-R2
+
+	dst="${prefix6}:${b_r1}::1"
+
+	# Set up initial MTU values
+	mtu "${ns_a}"  veth_A-R1 2000
+	mtu "${ns_r1}" veth_R1-A 2000
+	mtu "${ns_r1}" veth_R1-B 1400
+	mtu "${ns_b}"  veth_B-R1 1400
+
+	mtu "${ns_a}"  veth_A-R2 2000
+	mtu "${ns_r2}" veth_R2-A 2000
+	mtu "${ns_r2}" veth_R2-B 1500
+	mtu "${ns_b}"  veth_B-R2 1500
+
+	# Learn a PMTU from a packet too big message
+	run_cmd ${ns_a} ${ping6} -q -M want -i 0.1 -w 1 -s 1800 ${dst}
+
+	pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+	check_pmtu_value "1400" "${pmtu}" "exceeding MTU" || return 1
+
+	# Change the FIB with a route that has nothing to do with ${dst}. Any
+	# FIB change makes the cached dsts of the namespace stale. Do not look
+	# ${dst} up from here to the deletion: that would refresh the
+	# exception
+	run_cmd ${ns_a} ip -6 route add unreachable "${prefix6}:ff::/64"
+
+	if ! cached_exception_exists "${ns_a}" ${dst}; then
+		err "  PMTU exception disappeared after an unrelated route add"
+		return 1
+	fi
+
+	# Delete the cached exception
+	run_cmd ${ns_a} ip -6 route flush cached ${dst}
+
+	if cached_exception_exists "${ns_a}" ${dst}; then
+		err "  PMTU exception still there after deleting it"
+		return 1
+	fi
+
+	# A lookup must not bring it back
+	run_cmd ${ns_a} ip -6 route get ${dst}
+
+	if cached_exception_exists "${ns_a}" ${dst}; then
+		err "  PMTU exception came back after a route lookup"
+		return 1
+	fi
+
+	# Neither must a packet that fits, which looks the route up as well
+	run_cmd ${ns_a} ${ping6} -q -c 1 -w 1 -s 1000 ${dst}
+
+	pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+	check_pmtu_value "" "${pmtu}" "deleting the exception and a lookup" || return 1
+
+	if cached_exception_exists "${ns_a}" ${dst}; then
+		err "  PMTU exception came back after a packet that fits"
+		return 1
+	fi
+
+	# A packet that exceeds the PMTU does, through a new packet too big
+	# message. This is what learning it again looks like
+	run_cmd ${ns_a} ${ping6} -q -M want -i 0.1 -w 1 -s 1800 ${dst}
+
+	pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+	check_pmtu_value "1400" "${pmtu}" "exceeding MTU after the deletion" || return 1
+}
+
 test_pmtu_ipv4_mp_exceptions() {
 	setup namespaces routing multipath || return $ksft_skip
 
-- 
2.54.0 (Apple Git-157)
Technical Details
Message-ID: <20261201174021.7211-12-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375263-linux-kernel-netdev=dewy.ru
References: <20261201174021.7211-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375263-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted
Date: Tue,  1 Dec 2026 10:40:12 -0700
Organization: Usenet Network
Message-ID: <20261201174021.7211-12-dsahern@kernel.org>
References: <20261201174021.7211-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1780317"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3OFQgHNg+Lef6Or8VjrfAMMxhik= sha256:DtRli/mhyGlB0Ug8tYZ476QVU/lwjLiO+NROZNdMjbo=
	sha1:DXYtpEaBSFdYaTYZQkqnMOsXCiA= sha256:YVWavHbUFLqtXSgr7zzCu7w2fiZx+JeKQWW9s16QrQg=
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 BABC211743F; Tue,  1 Dec 2026 20:41:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[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 S1PWuVhFx3Cl;
	Tue,  1 Dec 2026 20:41:34 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375263-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 9A0A1117442; Tue,  1 Dec 2026 20:41:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 20858283CC; Tue,  1 Dec 2026 17:41:21 +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=1796146868;
	b=b8whfBIZxFcLFJqLfaflFq1PHzuUFR2dWDn0g1uwXHcKTuwvfrtC1Dv4/vqrCkvGL2NC
	 HAPtPvtQjd5f+NPin6Q07haQdM7zuwIvfXy3onXgy9rq91sEP+CJyddEEy/VVkPwxANaM
	 9bS0/FjPdU/aWebEnsl7OlU5kW+6gEjxKre/k9/COIh32ZK7f72R+YCctM2XYkOTV/+4B
	 Bk5YXrCqSEy5Og2r54RCpC2Ky9gq1cu1zdBmX0w/a3w7tEuJhd+Gi8qNpo4FwwmTUnAKc
	 W2EdyvDRdUvMN0LT/ama1eTNibmO2cIIwdGsm2kVtXDU/MS5nnlzxxt62qoXVTHZI2w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796146868;
	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=VQYnJLnWH7S2BjMZDCUYIDIybgaJuYkxv1LZSLJO9LI=;
	b=ksjUuviMBt425f6yrK/KVw6+AFngNo2iiDo/qyV7xaE4LU0TPCYkd16wZn9xu7Ku5c4g
	 enlJEeqJgrCqaut4k6xqjn1AVO1RTH04D59e/Ot/drug/O5/eFLtqQ976rXQd63nYaiOw
	 psR2puloxvNeF3iQ0GWKXZstWvd6CP8SRvBDRg5iBJBP+fqlYCStw9HjP/DrC52dG8HBl
	 iRN2KqwDv5cyhpB+kmbHM4DAIuD1juSbi/5DeIHgG5lxThKIJehhEuPBc2JN6sAL2uvM9
	 7wkO3d8dVOpRrJ4d59fHP/lI8p9QimTIuRC8A831c5UnKlL1U3ehwsotiIq/JXe0AzQ==
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=Z8TYPsow;
	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 29925606A686;
	Tue,  1 Dec 2026 17:41:08 +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=Z8TYPsow
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=1796146867;
	b=wU+t99WefiNYUqgsbejZtKEXesIlm9zqo3aFsVt8RCkIyiEuBlxuArFOq6b4G/PZQM5f
	 KYiSos9DGjF3HcMqOoDjgaPV6lvT4cUYkTP24L0e/jauTce9V7VRnlItXkCmnxMYD/ryj
	 Bek8wsUvN8Q91muw4z/XDGST1gFd217gMjEjXmomRYpevdp1wjRzq7GO26PXCyZtzbICy
	 xX7mAUQcVzC/YuUA5Kme2s5jzczDXpD60O+Ug3aBxwbLqXZ2IoH70zM4cI2WvjWwZJt7H
	 61clBgy3uRXTfgxHyaMKRdgVI8yb+JjSef58g7wDMAWNokIW2SHCUl/gsQkB3JO9c5g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796146867;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=VQYnJLnWH7S2BjMZDCUYIDIybgaJuYkxv1LZSLJO9LI=;
	b=LfW/0YgvM5kDKRGP092jt/fhIutGas+c2ihj4rc+1Zse9kY5l8gi0YalcGYGUWH9elae
	 Ec6OOpvwOp20ESpxB7/yp6TiatS3bleEZCEJrvNrLvA2o6WV8Ab0oWX/kCBz1N13jG+mg
	 rtkMLzqnqmMz7C8bxJtXE5N7w/YJ1mGzYay6Wmm/VHXpJ6+ms08YQzqqXQWvQNGal43n8
	 wX07TNryOPajZNea4T6oeQmQKmjIbGng22WFoR3U6ZFvG0I8lEiXUAiyn9/h5mZnL+LP4
	 /3/g5JO/PiJyBk65gn7XuzGWsPQh8DOFc73fqS0DGb/4nCZo54UfZO8cOMPXhiCFstA==
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=Z8TYPsow;
	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 4BBF8606A6B9
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 17:41:07 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B18F1F0089A;
	Tue,  1 Dec 2026 17:41:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796146866;
	bh=VQYnJLnWH7S2BjMZDCUYIDIybgaJuYkxv1LZSLJO9LI=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=Z8TYPsowL3sKScc/I1RvnvgsNhnnYMNtsudIdgryX9yVyOrTD+Sakvl8c+Zke1uuy
	 oRioG2Xv2KPFRpPYIQgNGdWRXytXnSBp589UtDtageokE/VDbaxHsrGZa7rNhTWUwX
	 8AqBzPscoFst6YpfZ1arKa0KNWkqdBu42O2wnQWWmiLubaqNwalrU9ghMqustKaRdQ
	 w8cOdjpN8kl2qY8w7/3lX/SeUqf6crGHeiJnUgMqATA7pWcYORfFP4eQdC7BIcAyHa
	 xz1jhSZ2HhKiVVBorOA5RDVXTjysqlpebEa993RTUXAgsRMKFQ3dQUPw5ESV8KKfO+
	 oVgZfYmPmhZZA==
X-Cc: dsahern@kernel.org,
	idosch@nvidia.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	ralf@mandelbit.com,
	ja@ssi.bg,
	David Ahern <dahern@nvidia.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261201174021.7211-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