From: Vladimir Vdovin <deliran@verdict.gg>
To: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
Vladimir Vdovin <deliran@verdict.gg>
Subject: [PATCH net-next v5 2/2] selftests: net: pmtu: Add IPv6 multipath tests
Date: Wed, 2 Dec 2026 21:25:45 +0300 [thread overview]
Message-ID: <20261202182545.19656-3-deliran@verdict.gg> (raw)
In-Reply-To: <20261202182545.19656-1-deliran@verdict.gg>
Share the IPv4 multipath PMTU tests with IPv6. With an MTU of 1500
behind both routers, check that one oversized ping creates a PMTU
exception of 1500 on both paths.
For the asymmetric case, use IPv6 flow labels to send one ping through
each router. R1 reports an MTU of 1400. Only the path through R1 should
cache that value because the link from the host to R2 has an MTU of
1350. R2 then reports an MTU of 1300, which both paths should cache.
Use ICMP datagram sockets for ping. With a raw socket, rawv6_err() can
process the same Packet Too Big a second time. Its lookup can select the
other path and make the test pass without the fix.
Without the preceding fix, both IPv6 tests fail with legacy nexthops and
with nexthop objects.
Signed-off-by: Vladimir Vdovin <deliran@verdict.gg>
---
tools/testing/selftests/net/pmtu.sh | 253 +++++++++++++++++++++-------
1 file changed, 194 insertions(+), 59 deletions(-)
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index a5d602a453c9..9403e87ee608 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -204,12 +204,18 @@
# addresses have multipath routes to each other, b_r1 mtu = 1500.
# Check that PMTU exceptions are created for both paths.
#
+# - pmtu_ipv6_mp_exceptions
+# Same as above but with IPv6
+#
# - pmtu_ipv4_mp_asym_exceptions
# Same topology as pmtu_ipv4_mp_exceptions, with b_r1 mtu = 1400,
# a_r2 mtu = 1350 and b_r2 mtu = 1300. Pick a flow through each router
# and check that a Fragmentation Needed from R1 creates a PMTU
# exception on the path via R1 only, as the path via R2 can't carry
# 1400, then that a flow through R2 lowers the PMTU of both paths
+#
+# - pmtu_ipv6_mp_asym_exceptions
+# Same as above but with IPv6
source lib.sh
@@ -280,7 +286,9 @@ tests="
pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1
pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1
pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1
- pmtu_ipv4_mp_asym_exceptions ipv4: PMTU multipath exceptions, asym MTU 1"
+ pmtu_ipv6_mp_exceptions ipv6: PMTU multipath nh exceptions 1
+ pmtu_ipv4_mp_asym_exceptions ipv4: PMTU multipath exceptions, asym MTU 1
+ pmtu_ipv6_mp_asym_exceptions ipv6: PMTU multipath exceptions, asym MTU 1"
# Addressing and routing for tests with routers: four network segments, with
# index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
@@ -361,6 +369,9 @@ host4_a_addr="192.168.99.99"
host4_a_net="192.168.97"
host4_b_addr="192.168.88.88"
+host6_a_addr="fc00:1000::a"
+host6_b_addr="fc00:1001::b"
+
dummy6_0_prefix="fc00:1000::"
dummy6_1_prefix="fc00:1001::"
dummy6_mask="64"
@@ -1003,49 +1014,119 @@ setup_ovs_bridge() {
}
setup_multipath_new() {
- # Set up host A with multipath routes to host B host4_b_addr
- run_cmd ${ns_a} ip addr add ${host4_a_addr} dev lo
- run_cmd ${ns_a} ip nexthop add id 401 via ${prefix4}.${a_r1}.2 dev veth_A-R1
- run_cmd ${ns_a} ip nexthop add id 402 via ${prefix4}.${a_r2}.2 dev veth_A-R2
- run_cmd ${ns_a} ip nexthop add id 403 group 401/402
- run_cmd ${ns_a} ip route add ${host4_b_addr} src ${host4_a_addr} nhid 403
+ family=${1}
- # Set up host B with multipath routes to host A host4_a_addr
- run_cmd ${ns_b} ip addr add ${host4_b_addr} dev lo
- run_cmd ${ns_b} ip nexthop add id 401 via ${prefix4}.${b_r1}.2 dev veth_B-R1
- run_cmd ${ns_b} ip nexthop add id 402 via ${prefix4}.${b_r2}.2 dev veth_B-R2
- run_cmd ${ns_b} ip nexthop add id 403 group 401/402
- run_cmd ${ns_b} ip route add ${host4_a_addr} src ${host4_b_addr} nhid 403
+ if [ ${family} -eq 4 ]; then
+ host_a_addr=${host4_a_addr}
+ host_b_addr=${host4_b_addr}
+ nodad=""
+ nh_a_r1=${prefix4}.${a_r1}.2
+ nh_a_r2=${prefix4}.${a_r2}.2
+ nh_b_r1=${prefix4}.${b_r1}.2
+ nh_b_r2=${prefix4}.${b_r2}.2
+ else
+ host_a_addr=${host6_a_addr}
+ host_b_addr=${host6_b_addr}
+ nodad="nodad"
+ nh_a_r1=${prefix6}:${a_r1}::2
+ nh_a_r2=${prefix6}:${a_r2}::2
+ nh_b_r1=${prefix6}:${b_r1}::2
+ nh_b_r2=${prefix6}:${b_r2}::2
+ fi
+
+ # Set up host A with multipath routes to host B host_b_addr
+ run_cmd ${ns_a} ip addr add ${host_a_addr} dev lo ${nodad}
+ run_cmd ${ns_a} ip nexthop add id ${family}01 via ${nh_a_r1} dev veth_A-R1
+ run_cmd ${ns_a} ip nexthop add id ${family}02 via ${nh_a_r2} dev veth_A-R2
+ run_cmd ${ns_a} ip nexthop add id ${family}03 group ${family}01/${family}02
+ run_cmd ${ns_a} ip route add ${host_b_addr} src ${host_a_addr} nhid ${family}03
+
+ # Set up host B with multipath routes to host A host_a_addr
+ run_cmd ${ns_b} ip addr add ${host_b_addr} dev lo ${nodad}
+ run_cmd ${ns_b} ip nexthop add id ${family}01 via ${nh_b_r1} dev veth_B-R1
+ run_cmd ${ns_b} ip nexthop add id ${family}02 via ${nh_b_r2} dev veth_B-R2
+ run_cmd ${ns_b} ip nexthop add id ${family}03 group ${family}01/${family}02
+ run_cmd ${ns_b} ip route add ${host_a_addr} src ${host_b_addr} nhid ${family}03
}
setup_multipath_old() {
- # Set up host A with multipath routes to host B host4_b_addr
- run_cmd ${ns_a} ip addr add ${host4_a_addr} dev lo
- run_cmd ${ns_a} ip route add ${host4_b_addr} \
- src ${host4_a_addr} \
- nexthop via ${prefix4}.${a_r1}.2 weight 1 \
- nexthop via ${prefix4}.${a_r2}.2 weight 1
+ family=${1}
+
+ if [ ${family} -eq 4 ]; then
+ host_a_addr=${host4_a_addr}
+ host_b_addr=${host4_b_addr}
+ nodad=""
+ nh_a_r1=${prefix4}.${a_r1}.2
+ nh_a_r2=${prefix4}.${a_r2}.2
+ nh_b_r1=${prefix4}.${b_r1}.2
+ nh_b_r2=${prefix4}.${b_r2}.2
+ else
+ host_a_addr=${host6_a_addr}
+ host_b_addr=${host6_b_addr}
+ nodad="nodad"
+ nh_a_r1=${prefix6}:${a_r1}::2
+ nh_a_r2=${prefix6}:${a_r2}::2
+ nh_b_r1=${prefix6}:${b_r1}::2
+ nh_b_r2=${prefix6}:${b_r2}::2
+ fi
+
+ # Set up host A with multipath routes to host B host_b_addr
+ run_cmd ${ns_a} ip addr add ${host_a_addr} dev lo ${nodad}
+ run_cmd ${ns_a} ip route add ${host_b_addr} \
+ src ${host_a_addr} \
+ nexthop via ${nh_a_r1} weight 1 \
+ nexthop via ${nh_a_r2} weight 1
- # Set up host B with multipath routes to host A host4_a_addr
- run_cmd ${ns_b} ip addr add ${host4_b_addr} dev lo
- run_cmd ${ns_b} ip route add ${host4_a_addr} \
- src ${host4_b_addr} \
- nexthop via ${prefix4}.${b_r1}.2 weight 1 \
- nexthop via ${prefix4}.${b_r2}.2 weight 1
+ # Set up host B with multipath routes to host A host_a_addr
+ run_cmd ${ns_b} ip addr add ${host_b_addr} dev lo ${nodad}
+ run_cmd ${ns_b} ip route add ${host_a_addr} \
+ src ${host_b_addr} \
+ nexthop via ${nh_b_r1} weight 1 \
+ nexthop via ${nh_b_r2} weight 1
}
+
setup_multipath() {
+ family="$1"
+
+ if [ ${family} -eq 4 ]; then
+ host_a_addr=${host4_a_addr}
+ host_b_addr=${host4_b_addr}
+ nh_r1_a=${prefix4}.${a_r1}.1
+ nh_r1_b=${prefix4}.${b_r1}.1
+ nh_r2_a=${prefix4}.${a_r2}.1
+ nh_r2_b=${prefix4}.${b_r2}.1
+ else
+ host_a_addr=${host6_a_addr}
+ host_b_addr=${host6_b_addr}
+ nh_r1_a=${prefix6}:${a_r1}::1
+ nh_r1_b=${prefix6}:${b_r1}::1
+ nh_r2_a=${prefix6}:${a_r2}::1
+ nh_r2_b=${prefix6}:${b_r2}::1
+ fi
+
if [ "$USE_NH" = "yes" ]; then
- setup_multipath_new
+ setup_multipath_new ${family}
else
- setup_multipath_old
+ setup_multipath_old ${family}
fi
# Set up routers with routes to dummies
- run_cmd ${ns_r1} ip route add ${host4_a_addr} via ${prefix4}.${a_r1}.1
- run_cmd ${ns_r2} ip route add ${host4_a_addr} via ${prefix4}.${a_r2}.1
- run_cmd ${ns_r1} ip route add ${host4_b_addr} via ${prefix4}.${b_r1}.1
- run_cmd ${ns_r2} ip route add ${host4_b_addr} via ${prefix4}.${b_r2}.1
+ run_cmd ${ns_r1} ip route add ${host_a_addr} via ${nh_r1_a}
+ run_cmd ${ns_r2} ip route add ${host_a_addr} via ${nh_r2_a}
+ run_cmd ${ns_r1} ip route add ${host_b_addr} via ${nh_r1_b}
+ run_cmd ${ns_r2} ip route add ${host_b_addr} via ${nh_r2_b}
+
+ # Let ping use ICMPv6 datagram sockets to avoid handling a PTB twice.
+ ${ns_a} sysctl -q -w net.ipv4.ping_group_range="0 2147483647"
+}
+
+setup_multipath4() {
+ setup_multipath 4
+}
+
+setup_multipath6() {
+ setup_multipath 6
}
setup() {
@@ -2386,8 +2467,18 @@ test_pmtu_ipv6_route_change() {
test_pmtu_ipvX_route_change 6
}
-test_pmtu_ipv4_mp_exceptions() {
- setup namespaces routing multipath || return $ksft_skip
+test_pmtu_ipvX_mp_exceptions() {
+ family=${1}
+
+ if [ ${family} -eq 4 ]; then
+ ping=ping
+ dst="${host4_b_addr}"
+ else
+ ping=${ping6}
+ dst="${host6_b_addr}"
+ fi
+
+ setup namespaces routing multipath${family} || return $ksft_skip
trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
"${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
@@ -2406,44 +2497,69 @@ test_pmtu_ipv4_mp_exceptions() {
mtu "${ns_b}" veth_B-R2 1500
# Ping and expect two nexthop exceptions for two routes
- run_cmd ${ns_a} ping -q -M want -i 0.1 -c 1 -s 1800 "${host4_b_addr}"
+ run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -c 1 -s 1800 "${dst}"
# Check that exceptions have been created with the correct PMTU
- pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)"
- pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)"
+ pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)"
+ pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)"
check_pmtu_value "1500" "${pmtu_a_R1}" "exceeding MTU (veth_A-R1)" || return 1
check_pmtu_value "1500" "${pmtu_a_R2}" "exceeding MTU (veth_A-R2)" || return 1
}
-# Pick a source address out of ${host4_a_net} for a flow from host A to
-# ${1} through ${2}: the IPv4 multipath hash covers addresses only by
-# default
+test_pmtu_ipv4_mp_exceptions() {
+ test_pmtu_ipvX_mp_exceptions 4
+}
+
+# Pick an IPv4 source address or an IPv6 flow label for a flow from host A
+# to ${2} through ${3}. Both ip and ping take the flow label in hex.
mp_flow_via() {
- dst="${1}"
- oif="${2}"
+ family="${1}"
+ dst="${2}"
+ oif="${3}"
for i in $(seq 1 32); do
- flow="${host4_a_net}.${i}"
- ${ns_a} ip route get ${dst} from ${flow} |
+ if [ ${family} -eq 4 ]; then
+ flow="${host4_a_net}.${i}"
+ lookup="from ${flow}"
+ else
+ flow="$(printf "0x%x" ${i})"
+ lookup="from ${host6_a_addr} ipproto 58 flowlabel ${flow}"
+ fi
+ ${ns_a} ip route get ${dst} ${lookup} |
grep -q " dev ${oif} " && echo "${flow}" && return
done
return 1
}
-test_pmtu_ipv4_mp_asym_exceptions() {
- setup namespaces routing multipath || return $ksft_skip
+test_pmtu_ipvX_mp_asym_exceptions() {
+ family=${1}
+
+ if [ ${family} -eq 4 ]; then
+ ping=ping
+ dst="${host4_b_addr}"
+ else
+ ping=${ping6}
+ dst="${host6_b_addr}"
+ fi
+
+ setup namespaces routing multipath${family} || 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
- # Source addresses for mp_flow_via(), with routes back to them
- run_cmd ${ns_a} ip route add local ${host4_a_net}.0/24 dev lo
- run_cmd ${ns_r1} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r1}.1
- run_cmd ${ns_r2} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r2}.1
+ if [ ${family} -eq 4 ]; then
+ # Source addresses for mp_flow_via(), with routes back to them
+ run_cmd ${ns_a} ip route add local ${host4_a_net}.0/24 dev lo
+ run_cmd ${ns_r1} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r1}.1
+ run_cmd ${ns_r2} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r2}.1
+ else
+ ${ns_a} ip route get ${dst} ipproto 58 flowlabel 0x1 >/dev/null 2>&1 || {
+ err " ip route get flowlabel not supported"; return $ksft_skip; }
+ fi
# Set up initial MTU values: 1400 behind R1, 1350 to R2, 1300 behind R2
mtu "${ns_a}" veth_A-R1 2000
@@ -2456,29 +2572,48 @@ test_pmtu_ipv4_mp_asym_exceptions() {
mtu "${ns_r2}" veth_R2-B 1300
mtu "${ns_b}" veth_B-R2 1300
- flow_r1="$(mp_flow_via ${host4_b_addr} veth_A-R1)" || {
+ flow_r1="$(mp_flow_via ${family} ${dst} veth_A-R1)" || {
err " no flow through veth_A-R1 found"; return 1; }
- flow_r2="$(mp_flow_via ${host4_b_addr} veth_A-R2)" || {
+ flow_r2="$(mp_flow_via ${family} ${dst} veth_A-R2)" || {
err " no flow through veth_A-R2 found"; return 1; }
+ if [ ${family} -eq 4 ]; then
+ ping_r1="${ping} -I ${flow_r1}"
+ ping_r2="${ping} -I ${flow_r2}"
+ else
+ ping_r1="${ping} -I ${host6_a_addr} -F ${flow_r1}"
+ ping_r2="${ping} -I ${host6_a_addr} -F ${flow_r2}"
+ fi
- # A Fragmentation Needed from R1 is cached on the path via R1, not on
- # the path via R2, whose link can't carry 1400
- run_cmd ${ns_a} ping -I ${flow_r1} -q -M want -i 0.1 -c 1 -s 1800 "${host4_b_addr}"
+ # The error from R1 is cached on the path via R1, not on the path via
+ # R2, whose link can't carry 1400
+ run_cmd ${ns_a} ${ping_r1} -q -M want -i 0.1 -c 1 -s 1800 "${dst}"
- pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)"
- pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)"
+ pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)"
+ pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)"
check_pmtu_value "1400" "${pmtu_a_R1}" "exceeding MTU via R1 (veth_A-R1)" || return 1
check_pmtu_value "" "${pmtu_a_R2}" "exceeding MTU via R1 (veth_A-R2)" || return 1
# The lower MTU behind R2 lowers the PMTU of both paths
- run_cmd ${ns_a} ping -I ${flow_r2} -q -M want -i 0.1 -c 1 -s 1280 "${host4_b_addr}"
+ run_cmd ${ns_a} ${ping_r2} -q -M want -i 0.1 -c 1 -s 1280 "${dst}"
- pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)"
- pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)"
+ pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)"
+ pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)"
check_pmtu_value "1300" "${pmtu_a_R1}" "exceeding MTU via R2 (veth_A-R1)" || return 1
check_pmtu_value "1300" "${pmtu_a_R2}" "exceeding MTU via R2 (veth_A-R2)" || return 1
}
+test_pmtu_ipv4_mp_asym_exceptions() {
+ test_pmtu_ipvX_mp_asym_exceptions 4
+}
+
+test_pmtu_ipv6_mp_asym_exceptions() {
+ test_pmtu_ipvX_mp_asym_exceptions 6
+}
+
+test_pmtu_ipv6_mp_exceptions() {
+ test_pmtu_ipvX_mp_exceptions 6
+}
+
usage() {
echo
echo "$0 [OPTIONS] [TEST]..."
--
2.56.0
next prev parent reply other threads:[~2026-12-02 18:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 18:25 [PATCH net-next v5 0/2] ipv6: Cache pmtu for all paths of a multipath route Vladimir Vdovin
2026-12-02 18:25 ` [PATCH net-next v5 1/2] " Vladimir Vdovin
2026-12-03 19:01 ` netdev-bot+sashiko
2026-12-02 18:25 ` Vladimir Vdovin [this message]
2026-12-03 19:01 ` [PATCH net-next v5 2/2] selftests: net: pmtu: Add IPv6 multipath tests netdev-bot+sashiko
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=20261202182545.19656-3-deliran@verdict.gg \
--to=deliran@verdict.gg \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=willemb@google.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