From: David Ahern <dsahern@kernel.org>
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 <dahern@nvidia.com>,
"Claude Sonnet 5.5" <noreply@anthropic.com>
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 [thread overview]
Message-ID: <20261201174021.7211-14-dsahern@kernel.org> (raw)
In-Reply-To: <20261201174021.7211-1-dsahern@kernel.org>
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)
next prev parent reply other threads:[~2026-12-01 17:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:40 [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
2026-12-01 17:40 ` David Ahern [this message]
2026-12-01 17:43 ` [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201174021.7211-14-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noreply@anthropic.com \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox