From: Anton Danilov <littlesmilingcloud@gmail.com>
To: netdev@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>, Simon Horman <horms@kernel.org>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH net-next 11/11] selftests: net: cover the tunnel transmit drop reasons
Date: Tue, 1 Sep 2026 00:51:37 +0300 [thread overview]
Message-ID: <20260831215137.549324-12-littlesmilingcloud@gmail.com> (raw)
In-Reply-To: <20260831215137.549324-1-littlesmilingcloud@gmail.com>
Extend the tunnel drop reason test with three failures of the transmit
path, all on GRE:
- an underlay that cannot carry what the tunnel advertises, so the
encapsulated packet does not fit the path MTU and is dropped after an
ICMP fragmentation needed is sent back. This is the case worth
telling apart from the others: path MTU discovery is working as
intended, and until now the drop was indistinguishable from a real
failure,
- a device in external mode receiving traffic that carries no tunnel
metadata, reported as TUNNEL_TXINFO,
- a tunnel whose remote endpoint has no route, reported as
IP_OUTNOROUTES.
Assisted-by: Claude-Code:claude-opus-5
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
.../selftests/net/tunnel_drop_reasons.sh | 58 ++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tunnel_drop_reasons.sh b/tools/testing/selftests/net/tunnel_drop_reasons.sh
index aad003f0efe5..5639e29365a4 100755
--- a/tools/testing/selftests/net/tunnel_drop_reasons.sh
+++ b/tools/testing/selftests/net/tunnel_drop_reasons.sh
@@ -26,6 +26,11 @@
# GRE_TUNNEL_NOT_FOUND. It is triggered here by giving the two
# endpoints different keys.
#
+# On the transmit side, the reasons reported while encapsulating are
+# checked too: a packet that does not fit the path MTU, a device in
+# external mode that receives no metadata, and a tunnel whose remote
+# endpoint has no route.
+#
# - a header with the routing bit set is reported as GRE_INVALID_HDR,
# and a header announcing a GRE version nobody handles is reported as
# UNHANDLED_PROTO. Both are triggered by corrupting the GRE header
@@ -81,6 +86,7 @@ setup_tracing()
setup_ns_pair()
{
+ PING_ARGS=""
cleanup_all_ns
setup_ns NS_SND NS_RCV
@@ -122,9 +128,15 @@ addr_tunnels()
ip -n "$NS_RCV" addr add "$TUN_RCV/24" dev gre_test
}
+# Traffic used by check_reason(). Tests that need something else set
+# PING_ARGS before calling it.
+PING_ARGS=""
+
send_traffic()
{
- ip netns exec "$NS_SND" ping -c 2 -W 1 "$TUN_RCV" >/dev/null 2>&1
+ # shellcheck disable=SC2086
+ ip netns exec "$NS_SND" ping -c 2 -W 1 $PING_ARGS "$TUN_RCV" \
+ >/dev/null 2>&1
# Let the tracepoint records reach the trace buffer.
sleep 1
}
@@ -254,6 +266,46 @@ test_corrupted_header()
check_reason "$name" "$want"
}
+test_tx_pkt_too_big()
+{
+ setup_ns_pair
+ # The underlay cannot carry what the tunnel advertises, so the
+ # encapsulated packet does not fit the path MTU. The kernel sends
+ # an ICMP fragmentation needed back and drops it, which is path MTU
+ # discovery working as intended.
+ ip -n "$NS_SND" link set veth_s mtu 1280
+ ip -n "$NS_RCV" link set veth_r mtu 1280
+ add_gre "$NS_SND" "$SND_V4" "$RCV_V4"
+ add_gre "$NS_RCV" "$RCV_V4" "$SND_V4"
+ ip -n "$NS_SND" link set gre_test mtu 1500
+ addr_tunnels
+
+ PING_ARGS="-s 1400 -M do"
+ check_reason "gre: packet does not fit the path MTU" PKT_TOO_BIG
+}
+
+test_tx_no_metadata()
+{
+ setup_ns_pair
+ # A device in external mode expects the destination to come from
+ # the tunnel metadata, which plain traffic does not carry.
+ ip -n "$NS_SND" link add gre_test type gre external
+ ip -n "$NS_SND" link set gre_test up
+ ip -n "$NS_SND" addr add "$TUN_SND/24" dev gre_test
+
+ check_reason "gre: external mode without metadata" TUNNEL_TXINFO
+}
+
+test_tx_no_route()
+{
+ setup_ns_pair
+ # Nothing knows how to reach the remote endpoint of the tunnel.
+ add_gre "$NS_SND" "$SND_V4" 172.31.255.254
+ ip -n "$NS_SND" addr add "$TUN_SND/24" dev gre_test
+
+ check_reason "gre: no route to the remote endpoint" IP_OUTNOROUTES
+}
+
if [ "$(id -u)" -ne 0 ]; then
echo "SKIP: need root"
exit "$ksft_skip"
@@ -279,6 +331,10 @@ test_corrupted_header "gre: routing bit set" GRE_INVALID_HDR \
test_corrupted_header "gre: unhandled GRE version" UNHANDLED_PROTO \
offset 21 u8 set 0x01
+test_tx_pkt_too_big
+test_tx_no_metadata
+test_tx_no_route
+
if [ -e /proc/sys/net/ipv6 ]; then
test_opts_mismatch ip6gre iseq
test_old_seq ip6gre
--
2.47.3
prev parent reply other threads:[~2026-08-31 21:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 21:51 [PATCH net-next 00/11] tunnels: add core and gre drop reasons Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 01/11] ip_tunnel: add drop reasons to the generic RX path Anton Danilov
2026-09-03 1:47 ` Jakub Kicinski
2026-09-03 1:47 ` Jakub Kicinski
2026-08-31 21:51 ` [PATCH net-next 02/11] ip6_tunnel: " Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 03/11] selftests: net: add a test for the tunnel RX drop reasons Anton Danilov
2026-09-03 1:45 ` Jakub Kicinski
2026-08-31 21:51 ` [PATCH net-next 04/11] gre: make gre_parse_header() report a drop reason Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 05/11] ip_gre: add drop reasons to the RX path Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 06/11] ip6_gre: " Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 07/11] selftests: net: cover the GRE specific drop reasons Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 08/11] ip_tunnel: add drop reasons to the transmit path Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 09/11] ip_gre: " Anton Danilov
2026-08-31 21:51 ` [PATCH net-next 10/11] ip6_tunnel: " Anton Danilov
2026-09-03 1:43 ` Jakub Kicinski
2026-08-31 21:51 ` Anton Danilov [this message]
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=20260831215137.549324-12-littlesmilingcloud@gmail.com \
--to=littlesmilingcloud@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).