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>
Subject: [PATCH net-next v2 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted
Date: Wed, 25 Nov 2026 18:33:37 -0700 [thread overview]
Message-ID: <c1700ffd419c7247da4c896cb09f384894c32f43.1795642432.git.dahern@nvidia.com> (raw)
In-Reply-To: <cover.1795642432.git.dahern@nvidia.com>
From: David Ahern <dahern@nvidia.com>
Add a test that learns a PMTU from a packet too big message, changes
the FIB with a route that has nothing to do with the destination, and
deletes the cached exception without looking the destination up in
between. After a FIB change the exception's dst is stale, and a lookup
that handed it out would replace it with a current copy: deleting it
must work on a stale exception too, and nothing may then bring it back.
Check that neither a route lookup nor a packet that fits, which looks
the route up as well, creates the exception again, and that a packet
that exceeds the PMTU does, through a new packet too big message. The
cache is dumped to see the exception, as that does not look the
destination up and so does not refresh it.
The test is run again with nexthop objects like the other exception
tests, which takes the deletion through the nexthop path.
Signed-off-by: David Ahern <dahern@nvidia.com>
---
tools/testing/selftests/net/pmtu.sh | 90 +++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index c7cd271714ef..5e44ff3a6515 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -198,6 +198,14 @@
# - pmtu_ipv6_route_change
# Same as above but with IPv6
#
+# - pmtu_ipv6_cached_del
+# Use the same topology as in pmtu_ipv6. Learn a PMTU from a packet too big
+# message, change the FIB with an unrelated route add and, without looking
+# the destination up in between, delete the cached exception. Check that
+# neither a route lookup nor a packet that does not exceed the PMTU
+# brings the exception back, and that a packet that does exceed it
+# creates a new one
+#
# - pmtu_ipv4_mp_exceptions
# Use the same topology as in pmtu_ipv4, but add routeable addresses
# on host A and B on lo reachable via both routers. Host A and B
@@ -272,6 +280,7 @@ tests="
list_flush_ipv6_exception ipv6: list and flush cached exceptions 1
pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1
pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1
+ pmtu_ipv6_cached_del ipv6: delete a cached PMTU exception after a FIB change 1
pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1"
# Addressing and routing for tests with routers: four network segments, with
@@ -2377,6 +2386,87 @@ test_pmtu_ipv6_route_change() {
test_pmtu_ipvX_route_change 6
}
+# Is there a cached exception for ${2} in the namespace ${1}? Dumping the cache
+# does not look the destination up, so it does not touch the exception
+cached_exception_exists() {
+ ns_cmd="${1}"
+ dst="${2}"
+
+ ${ns_cmd} ip -oneline -6 route list cache | grep -qw -- "${dst}"
+}
+
+test_pmtu_ipv6_cached_del() {
+ setup namespaces routing || 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
+
+ dst="${prefix6}:${b_r1}::1"
+
+ # Set up initial MTU values
+ mtu "${ns_a}" veth_A-R1 2000
+ mtu "${ns_r1}" veth_R1-A 2000
+ mtu "${ns_r1}" veth_R1-B 1400
+ mtu "${ns_b}" veth_B-R1 1400
+
+ mtu "${ns_a}" veth_A-R2 2000
+ mtu "${ns_r2}" veth_R2-A 2000
+ mtu "${ns_r2}" veth_R2-B 1500
+ mtu "${ns_b}" veth_B-R2 1500
+
+ # Learn a PMTU from a packet too big message
+ run_cmd ${ns_a} ${ping6} -q -M want -i 0.1 -w 1 -s 1800 ${dst}
+
+ pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+ check_pmtu_value "1400" "${pmtu}" "exceeding MTU" || return 1
+
+ # Change the FIB with a route that has nothing to do with ${dst}. Any
+ # FIB change makes the cached dsts of the namespace stale. Do not look
+ # ${dst} up from here to the deletion: that would refresh the
+ # exception
+ run_cmd ${ns_a} ip -6 route add unreachable "${prefix6}:ff::/64"
+
+ if ! cached_exception_exists "${ns_a}" ${dst}; then
+ err " PMTU exception disappeared after an unrelated route add"
+ return 1
+ fi
+
+ # Delete the cached exception
+ run_cmd ${ns_a} ip -6 route flush cached ${dst}
+
+ if cached_exception_exists "${ns_a}" ${dst}; then
+ err " PMTU exception still there after deleting it"
+ return 1
+ fi
+
+ # A lookup must not bring it back
+ run_cmd ${ns_a} ip -6 route get ${dst}
+
+ if cached_exception_exists "${ns_a}" ${dst}; then
+ err " PMTU exception came back after a route lookup"
+ return 1
+ fi
+
+ # Neither must a packet that fits, which looks the route up as well
+ run_cmd ${ns_a} ${ping6} -q -c 1 -w 1 -s 1000 ${dst}
+
+ pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+ check_pmtu_value "" "${pmtu}" "deleting the exception and a lookup" || return 1
+
+ if cached_exception_exists "${ns_a}" ${dst}; then
+ err " PMTU exception came back after a packet that fits"
+ return 1
+ fi
+
+ # A packet that exceeds the PMTU does, through a new packet too big
+ # message. This is what learning it again looks like
+ run_cmd ${ns_a} ${ping6} -q -M want -i 0.1 -w 1 -s 1800 ${dst}
+
+ pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
+ check_pmtu_value "1400" "${pmtu}" "exceeding MTU after the deletion" || return 1
+}
+
test_pmtu_ipv4_mp_exceptions() {
setup namespaces routing multipath || return $ksft_skip
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-26 1:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 1:33 [PATCH net-next v2 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-11-26 1:33 ` David Ahern [this message]
2026-11-26 1:33 ` [PATCH net-next v2 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
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=c1700ffd419c7247da4c896cb09f384894c32f43.1795642432.git.dahern@nvidia.com \
--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=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