From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Tue, 1 Dec 2026 17:41:09 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C761F00A1A; Tue, 1 Dec 2026 17:41:08 +0000 (UTC) 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== From: David Ahern To: netdev@vger.kernel.org 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 , "Claude Sonnet 5.5" 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 Message-ID: <20261201174021.7211-14-dsahern@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261201174021.7211-1-dsahern@kernel.org> References: <20261201174021.7211-1-dsahern@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Ahern 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 Signed-off-by: David Ahern --- 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)