🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22842

[PATCH net-next v2 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached

#22842
From: David Ahern
Date: Thu, 26 Nov 2026 01:33
151 lines
13205 bytes
From: David Ahern <dahern@nvidia.com>

In IPv6 DR mode the director keeps its route to the real server in
dest->dst_cache and revalidates it with ip6_dst_check(). The route is a
FLOWI_FLAG_KNOWN_NH clone that is not cached on the nexthop, so a PMTU
learned for the real server afterwards is not applied to it unless
ip6_dst_check() notices the new exception.

Cache the route with a small datagram, give the director a PMTU for the
real server with a forged packet too big message, then send a datagram
that exceeds it. The director must answer with a packet too big message,
which the client learns as a PMTU for the service.

Add the IPv6 and UDP ipvs options the test needs to the config.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
 tools/testing/selftests/net/netfilter/config  |  2 +
 tools/testing/selftests/net/netfilter/ipvs.sh | 81 +++++++++++++++++++
 2 files changed, 83 insertions(+)

diff --git a/tools/testing/selftests/net/netfilter/config b/tools/testing/selftests/net/netfilter/config
index 629b2b29ed1a..d237f8651111 100644
--- a/tools/testing/selftests/net/netfilter/config
+++ b/tools/testing/selftests/net/netfilter/config
@@ -36,7 +36,9 @@ CONFIG_IPV6=y
 CONFIG_IPV6_MULTIPLE_TABLES=y
 CONFIG_IPV6_TUNNEL=m
 CONFIG_IP_VS=m
+CONFIG_IP_VS_IPV6=y
 CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
 CONFIG_IP_VS_RR=m
 CONFIG_MACVLAN=m
 CONFIG_NAMESPACES=y
diff --git a/tools/testing/selftests/net/netfilter/ipvs.sh b/tools/testing/selftests/net/netfilter/ipvs.sh
index 9c9d5b38ab71..556ce071035e 100755
--- a/tools/testing/selftests/net/netfilter/ipvs.sh
+++ b/tools/testing/selftests/net/netfilter/ipvs.sh
@@ -40,6 +40,12 @@ readonly dip_v4=172.16.0.1
 readonly rip_v4=172.16.0.2
 readonly sip_v4=10.0.0.3
 
+readonly vip_v6=fd00:3::1
+readonly cip_v6=fd00:1::2
+readonly gip_v6=fd00:1::1
+readonly dip_v6=fd00:2::1
+readonly rip_v6=fd00:2::2
+
 readonly infile="$(mktemp)"
 readonly outfile="$(mktemp)"
 readonly datalen=32
@@ -54,6 +60,7 @@ fi
 
 checktool "ipvsadm -v" "run test without ipvsadm"
 checktool "socat -h" "run test without socat"
+checktool "python3 -c pass" "run test without python3"
 
 setup() {
 	setup_ns ns0 ns1 ns2
@@ -169,6 +176,74 @@ test_tun() {
 	test_service
 }
 
+# Send one UDP datagram of ${2} bytes from the client to the IPv6 service and
+# keep the socket open for a moment, so that a packet too big message for it
+# is accepted.
+udp_send_v6() {
+	ip netns exec "${ns0}" python3 -c '
+import socket, sys, time
+s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
+s.bind((sys.argv[1], 0))
+s.sendto(b"x" * int(sys.argv[3]), (sys.argv[2], int(sys.argv[4])))
+time.sleep(0.5)
+' "${cip_v6}" "${vip_v6}" "${1}" "${port}"
+}
+
+# Send a packet too big message with MTU ${1} for ${dip_v6} -> ${rip_v6} from
+# the real server to the director. The director sees what a router on the path
+# to the real server would tell it, and learns a PMTU exception for ${rip_v6}.
+send_ptb_v6() {
+	ip netns exec "${ns2}" python3 -c '
+import socket, struct, sys
+src, dst, mtu = sys.argv[1], sys.argv[2], int(sys.argv[3])
+inner = struct.pack("!IHBB", 6 << 28, 8, 58, 64)
+inner += socket.inet_pton(socket.AF_INET6, src)
+inner += socket.inet_pton(socket.AF_INET6, dst)
+inner += struct.pack("!BBHHH", 128, 0, 0, 0, 0)
+msg = struct.pack("!BBHI", 2, 0, 0, mtu) + inner
+s = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.IPPROTO_ICMPV6)
+s.sendto(msg, (src, 0))
+' "${dip_v6}" "${rip_v6}" "${1}"
+}
+
+# The director keeps the route to a real server for as long as it passes
+# ip6_dst_check(). In DR mode that is a FLOWI_FLAG_KNOWN_NH clone, which is not
+# cached on the nexthop. A PMTU learned for the real server after the route was
+# cached must still reach it: packets that exceed the PMTU must get a packet
+# too big message back to the client.
+test_dr_v6_pmtu() {
+	ip netns exec "${ns0}" ip addr add "${cip_v6}/64" dev br0 nodad
+	ip netns exec "${ns0}" ip route add "${vip_v6}/128" via "${gip_v6}" dev br0
+
+	ip netns exec "${ns1}" ip addr add "${gip_v6}/64" dev veth10 nodad
+	ip netns exec "${ns1}" ip addr add "${dip_v6}/64" dev veth12 nodad
+	ip netns exec "${ns1}" ip addr add "${vip_v6}/128" dev lo nodad
+	ip netns exec "${ns1}" ipvsadm -A -u "[${vip_v6}]:${port}" -s rr
+	ip netns exec "${ns1}" ipvsadm -a -u "[${vip_v6}]:${port}" \
+		-r "[${rip_v6}]:${port}" -g
+
+	ip netns exec "${ns2}" ip addr add "${rip_v6}/64" dev veth21 nodad
+	ip netns exec "${ns2}" ip addr add "${vip_v6}/128" dev lo nodad
+
+	# Let the director cache its route to the real server
+	udp_send_v6 100
+
+	send_ptb_v6 1280
+	sleep 0.2
+	if ! ip netns exec "${ns1}" ip -6 route get "${rip_v6}" | grep -q "mtu 1280"; then
+		echo "FAIL: director did not learn the PMTU of the real server"
+		return 1
+	fi
+
+	# A datagram that exceeds the PMTU must be answered with a packet too
+	# big message, which gives the client a PMTU for the service
+	udp_send_v6 1400
+	if ! ip netns exec "${ns0}" ip -6 route get "${vip_v6}" | grep -q "mtu 1280"; then
+		echo "FAIL: director kept using a route that bypasses the learned PMTU"
+		return 1
+	fi
+}
+
 run_tests() {
 	local errors=
 
@@ -190,6 +265,12 @@ run_tests() {
 	test_tun
 	errors=$(( $errors + $? ))
 
+	echo "Testing IPv6 DR mode PMTU..."
+	cleanup
+	setup
+	test_dr_v6_pmtu
+	errors=$(( $errors + $? ))
+
 	return $errors
 }
 
-- 
2.54.0 (Apple Git-157)
Technical Details
Message-ID: <54d8eada69c6793d4761274f9c2878c0d284fe8b.1795642478.git.dahern@nvidia.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371796-linux-kernel-netdev=dewy.ru
References: <cover.1795642478.git.dahern@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371796-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached
Date: Wed, 25 Nov 2026 18:33:39 -0700
Organization: Usenet Network
Message-ID: <54d8eada69c6793d4761274f9c2878c0d284fe8b.1795642478.git.dahern@nvidia.com>
References: <cover.1795642478.git.dahern@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="353434"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uczPSPz63dU+PtysjoQq/JYumR0= sha256:2VptQcR476dwZH4diEPy7vN92MWahp7+yh5Qwlegpo4=
	sha1:HiC/fmqSpE/0u+xOcf33QxpwKNM= sha256:nb9H4wI+Ymcgyp0KWNCSLX1/kmnHn5syHl4hldiCaS4=
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 007B3125EA1; Thu, 26 Nov 2026 04:34:26 +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 Zfy004BBAhLV;
	Thu, 26 Nov 2026 04:34:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371796-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 52663125EAD; Thu, 26 Nov 2026 04:34:07 +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 403BD32197; Thu, 26 Nov 2026 01:34:01 +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=1795656841;
	b=Tj7nzMYByuhgercjiCbtsgzvB3hXNJ9NSX+TFB/lpX8hBqb1CulG/hyZ77181ZAT5g1V
	 9ec6VpeQXuoxF3AQN5+yUoC1emmt89sCmZeBwa/qkFJ5dcn8cqBRyv0rrIbv2bIVqt3tv
	 F2zDynzfUXbCDC5d6KadXiFvj582BxLExONkKw2dDSEB60dQIJgYbfzDsSfR4dbBlL8cV
	 k9VXyfzKdi7YGGy/AvRUE9w7bYFVdgPntdqReQ27Fg2mJ4VPNStCGOGqAH6s0hcXTTkq1
	 WAdhaQ6C4itBUmC1w1bfzZlBoH6tDFePqxpkyWFm+Dj55UHgfLHsFhNdfc9kmTNZgVw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795656841;
	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=O6X4JKbQfXXurLGaHrznyWnrE06kPkdHh7Wd9DV1C0s=;
	b=fIRLuccBGkDtdt8tSYU7wdQqicU+n3UCQGZTDERqPXeHCuPuSmJYLcPCvMniMGWuml0e
	 oS9VqLmC8XI0Qe5/GwYzlAsBP+xliPdlv8O8eXN3NXX4AR6JeCFqzp+3J/66Jy+cbYdLY
	 xg4Ss1uGlIq6vQUzly+GP3+Uojxox817yaxoak4n/bbCPWU/4ZfkQMLgFCuA1TKDqMY6D
	 KCgPEoREr04etk0CZv9HRv4twifbOvMRK7WHhfp2p/FbPs8UB5fzrMGwqdMw9+UY1+r0/
	 zINpNH8GxhaAiSe2LQGoS3Vi+Q1WpJPHi0kNrhu6FJORk0goCKECXlBzU7P2CBEhzww==
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=k3j5u+7H;
	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 049D6606A327;
	Thu, 26 Nov 2026 01:34:01 +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=k3j5u+7H
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=1795656840;
	b=5SuRMrHRmh9Yg4f0431obeQs2jpN76yepLudvdTElViyBIoIjOY1Z9N5kH23AiZDGyYm
	 DdLMavwWuBzlBlvWGZA1HUtHZxfuoqcOOmb9z2UnbTGmZnYJlvg0V5efUXwTamfd2Xc/4
	 2fK96BgN90n7W0TuwsAc0F7Cv+hVA2NogK5Wk8cty+U0E+Jp1U111zv5lGLCvlQp4GfEG
	 CoiWlS6pZTRgG0FF1WQC1VkJ7Bp66aPdjwSIlOeI/RZrgmLQwgWzgBxnUhioMTv+QKKuY
	 j7RRv7oH0rDYi1wdH9eXclgUCqo+jyL6NK6/2paBzj5cv7ZdzzRR9LGjU7qxgHkUyYA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795656840;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=O6X4JKbQfXXurLGaHrznyWnrE06kPkdHh7Wd9DV1C0s=;
	b=2HjBnlqV1TKTQEDQ7Z2UO2+xhJc1q+nsTjFSQdJpMHoYUHHGWONvgVPYBeKYZYt6djkj
	 Ve+XozIh84I6Tra18+SRsQE4gnVvL5fDt3rpnyY7nbF6aePylXGdf4o4Wkoa3kea3kThb
	 y44CUiCMb8nCCf1yiiMsSUndaiqog1qGT3KK66hCogjr4aZMWNdx6MH00RiPHfqGIUwxt
	 1XIwJONhihtDoU/TQ09uQHZalp7ho+db50xSkf0JIVrYn9bshix0H1DiXHrvD3r9Sn9p9
	 iwI7tHoF6jGkTWi7CCWqsa17WLVZp8slAPJhUYgulri2Z6ka9bQqeyNtrwbrmnjHnxA==
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=k3j5u+7H;
	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 281E9606A331
	for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 01:33:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 345351F000EE;
	Thu, 26 Nov 2026 01:33:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795656839;
	bh=O6X4JKbQfXXurLGaHrznyWnrE06kPkdHh7Wd9DV1C0s=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=k3j5u+7H5QbejIvHUuy1BLEQvEBkGc0DNLqKG04tSoqyEGbyBx3/sYt9AyxymLWz3
	 TAuapVJVxTqcrR75le/+6uZrKGelSEpynWDhZ7ydnmCsq8a/pfDPwRMFqb/dn3zg4/
	 kpmVQ+/HtF4aNtr1D8A/xKSzRVAFecdjjmYuoNyzhOoA7qjXKMdoaNXOImSLw06Vw4
	 L/lQcUVCePLwqW6sLW0sO0fNEqyxGgBrAtmfiCd2zGQFMRG/TfBmPHxGNIu2/j7x4P
	 TBdWjpog7gMr+aXQkbTC+M1467gEwQnrH1fLGdyG24nWS0MT6BfziwCtz2NZZfl+FZ
	 n/YJv+0aJCygg==
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: <cover.1795642478.git.dahern@nvidia.com>
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