Article View: linux.kernel.netdev
Article #25400[PATCH net-next v3 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached
From: David Ahern
Date: Tue, 01 Dec 2026 17:40
Date: Tue, 01 Dec 2026 17:40
152 lines
13263 bytes
13263 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.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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:
<20261201174021.7211-14-dsahern@kernel.org>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-375265-linux-kernel-netdev=dewy.ruReferences:
<20261201174021.7211-1-dsahern@kernel.org>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-375265-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v3 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached Date: Tue, 1 Dec 2026 10:40:14 -0700 Organization: Usenet Network Message-ID: <20261201174021.7211-14-dsahern@kernel.org> References: <20261201174021.7211-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1780419"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zPQ6MmPugx/UigZ2WiQRfoXE5cc= sha256:wuqbW/rtgAL/r9zLJFlPp5nHPRXZRPvAs3NW2REPo+g= sha1:Nz+tq4G0LmKei/tOIKMhwB5XTiI= sha256:FlusCSMvSqHnpCQ+2qeDn8cJ3qGY0XBlMTVDbouJhpk= 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 AD860117440; Tue, 1 Dec 2026 20:41:46 +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 0QQJ9MokOYrb; Tue, 1 Dec 2026 20:41:44 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375265-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 ABD1411743F; Tue, 1 Dec 2026 20:41:35 +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 E26882916A; Tue, 1 Dec 2026 17:41:27 +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=1796146870; b=vPbf1YCdEIqTNkp8ehepGp7FkZndR96wgwAA/LRQiDvGnz+9kWPbh5q+786Sn5WazPMq aeJ9Qdi32hXrt9r4u8WPDPsWeG+geeb3QHFqkw2WjJl4zG/ZsDLIpJPol454nqntnlGCn Y9dmOlEfxBvgIVQaVQH3ITZOTyFsHmxIX6QCLgsLklrY+aIXZVtHv5dXnqeOuRTXksPlg Qs3T1FLLjAUDcCgEJ/A3YWis00ff3+LXAn1W0NNg0c1+E0oxHccntO4sdpgSRBMEmKPzI Gw/y+eiRi3zQXr3t/BwNgRtJ6SEUahtA7LGePaRNc/VGEqtbV1SR9DHkbs8CwMpKwyg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146870; 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=zivqMP76TTlRSyIe8lascsZfO5V55wHfOf1lIazg/CA=; b=5lEDQ6VpJBHS2TBM3WLOm7SqPugT9Z7b6DQjQWBw4p0uQ5Ec/Vc5B3ojeZN0i8G+t+12 33YQUibGzJfi8VfH2sUJG9RNDg0DkaqSurGBYKbDQHeIRjO5FH5teRlJbSYRQJ+xFHL2d D/e7GQn9drajGjV/3nlymfsNldd7Caj68LtV8k+9zQoFTFqNf7b6UHxuR+ps8IKXWvRq4 TBWkqIFnlw8Gayrd87Tvl+ORQGdba2Gn1fvm1dTkRvvPWzbwojdNPM8eZLtrlmryzx03g 56LgYk7O74Rw+n9zGMK+rJbbwDl5acPDFHLrUfGrEWsgvu7lJJlqG/Pf9H3ygFm1Ggg== 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=nyyxojz0; 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 38110606A698; Tue, 1 Dec 2026 17:41:10 +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=nyyxojz0 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=1796146869; b=Lg62O/TaJcvD4MVdf1EcI3jtmYzPkNJziIcq/FVLHQIZcuxAhaIuAWAcBVhwDQaRUUO1 gdg6Rgclkwy4GEX8Pmaz2D3bemt5oL770qnYvWbO5CZ/9ovRRIRVRxG7do4k+wMi/I8Gf NcMt6sVAAIBNQofK7eS4bPcYeR6WkRf9MfCUq1ijILfObhqs2oxKyXFAGSWWS3OQDqcgO 7I/LG/Vjg5IeL21XdAm+YuqLw7IuMsktE1LPKU2q6nRECWSsK199vU/pG1uxPQm156eZ0 eBiJxxiBSbmppyBZuiOxAK1NcC9aNqJnNVeiwLE+2A/84hCCoLF2Q3pPM0/dzWDAduA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146869; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=zivqMP76TTlRSyIe8lascsZfO5V55wHfOf1lIazg/CA=; b=vAYaiq/tmDLmyBKNgukK/YE2JFauKN8L0qdb7/KpKyPYTnFtQP/lJYDRkRD4JWirdJEi P0HF9l60MQjzjTkFhXBwlL0cgci5tDCl5BOfKW0FL/GFWUa32XFgdY6a9pnl1PM109og6 z47ftVHJj08HsrLfp1blCa3T2pE0a2vprdm9lT1lXAyPOUHh8g3Jid2q5GRxdAdG8jBl0 xrpkLo3Sb9pNVD88Z3+Guz3eNeyAX5AXK0c7XL4xIFPVPlrVNE88DciKoYwgeQ2x+ONmd 0WNHoIDMiZ+OFyAG+lTmMDHwuObbvBot8vkWjlfydz/WB6OHTYHNu2fCbBnHtetfB8Q== 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=nyyxojz0; 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 59ED3606A680 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 17:41:09 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C761F00A1A; Tue, 1 Dec 2026 17:41:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796146868; bh=zivqMP76TTlRSyIe8lascsZfO5V55wHfOf1lIazg/CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nyyxojz0kupL4ywQDdvmGHPZWrMxhaEPzCuwoIhcgCmRjlN1kMT4d+7+AeWBPMW8o EzzVJHA5q1EZn4gn9DQhzNoDeXogdFg0Au3c2bauhQPLJImY9r6zMZUwHY57uKHfom VhHBHgH3DxS8DhTqDl5K0YbjNdXZd8MibIzBk+OJqL/cHEq+r0gjC2h3/rYjeDpLUJ WhLZKdiBm5BazzijiBVFvoBX+JUaqieGyHYDubY8Q9nPTQMX5pviY0bUwpddCE8KE4 xxvX0G8+uww4T7UZo7XniE3gyva/l7PgpDc1NIV6fzY8fdCUVkzZ/+Iq8FIdoLVcWS +H7dsFn09KycA== 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>, "Claude Sonnet 5.5" <noreply@anthropic.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