summaryrefslogtreecommitdiff
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2026-02-21 14:48:06 +0300
committerJakub Kicinski <kuba@kernel.org>2026-02-24 04:33:29 +0300
commitf77c7b96014471f2c39823ed9fcb42967e7d9ede (patch)
tree40eff66dd8a58e78232445f68c9b3dad44e6f045 /tools/testing/selftests
parent8bf22c33e7a172fbc72464f4cc484d23a6b412ba (diff)
downloadlinux-f77c7b96014471f2c39823ed9fcb42967e7d9ede.tar.xz
selftests/net: add test for IP-in-IPv6 tunneling
commit 81c734dae203 ("ip6_tunnel: use skb_vlan_inet_prepare() in __ip6_tnl_rcv()") was fine in and of itself, but its backport to 6.12 (and 6.6) broke IPv4-in-IPv6 tunneling, see [1]. This adds a self-test for basic IPv4-in-IPv6 and IPv6-in-IPv6 functionality. [1]: https://lore.kernel.org/all/CAA2RiuSnH_2xc+-W6EnFEG00XjS-dszMq61JEvRjcGS31CBw=g@mail.gmail.com/ Signed-off-by: Linus Heckemann <git@sphalerite.org> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Ricardo B. Marlière <rbm@suse.com> Tested-by: Ricardo B. Marlière <rbm@suse.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260221114806.1231666-1-git@sphalerite.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/net/Makefile1
-rwxr-xr-xtools/testing/selftests/net/ip6_tunnel.sh44
2 files changed, 45 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index afdea6d95bde..e97c90886f34 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -44,6 +44,7 @@ TEST_PROGS := \
io_uring_zerocopy_tx.sh \
ioam6.sh \
ip6_gre_headroom.sh \
+ ip6_tunnel.sh \
ip_defrag.sh \
ip_local_port_range.sh \
ipv6_flowlabel.sh \
diff --git a/tools/testing/selftests/net/ip6_tunnel.sh b/tools/testing/selftests/net/ip6_tunnel.sh
new file mode 100755
index 000000000000..fe081a521819
--- /dev/null
+++ b/tools/testing/selftests/net/ip6_tunnel.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Test that IPv4-over-IPv6 tunneling works.
+
+source lib.sh
+set -e
+
+setup_prepare() {
+ ip link add transport1 type veth peer name transport2
+
+ setup_ns ns1
+ ip link set transport1 netns $ns1
+ ip -n $ns1 address add 2001:db8::1/64 dev transport1 nodad
+ ip -n $ns1 address add 2001:db8::3/64 dev transport1 nodad
+ ip -n $ns1 link set transport1 up
+ ip -n $ns1 link add link transport1 name tunnel4 type ip6tnl mode ipip6 local 2001:db8::1 remote 2001:db8::2
+ ip -n $ns1 address add 172.0.0.1/32 peer 172.0.0.2/32 dev tunnel4
+ ip -n $ns1 link set tunnel4 up
+ ip -n $ns1 link add link transport1 name tunnel6 type ip6tnl mode ip6ip6 local 2001:db8::3 remote 2001:db8::4
+ ip -n $ns1 address add 2001:db8:6::1/64 dev tunnel6
+ ip -n $ns1 link set tunnel6 up
+
+ setup_ns ns2
+ ip link set transport2 netns $ns2
+ ip -n $ns2 address add 2001:db8::2/64 dev transport2 nodad
+ ip -n $ns2 address add 2001:db8::4/64 dev transport2 nodad
+ ip -n $ns2 link set transport2 up
+ ip -n $ns2 link add link transport2 name tunnel4 type ip6tnl mode ipip6 local 2001:db8::2 remote 2001:db8::1
+ ip -n $ns2 address add 172.0.0.2/32 peer 172.0.0.1/32 dev tunnel4
+ ip -n $ns2 link set tunnel4 up
+ ip -n $ns2 link add link transport2 name tunnel6 type ip6tnl mode ip6ip6 local 2001:db8::4 remote 2001:db8::3
+ ip -n $ns2 address add 2001:db8:6::2/64 dev tunnel6
+ ip -n $ns2 link set tunnel6 up
+}
+
+cleanup() {
+ cleanup_all_ns
+ # in case the namespaces haven't been set up yet
+ ip link delete transport1 &>/dev/null || true
+}
+
+trap cleanup EXIT
+setup_prepare
+ip netns exec $ns1 ping -q -W1 -c1 172.0.0.2 >/dev/null
+ip netns exec $ns1 ping -q -W1 -c1 2001:db8:6::2 >/dev/null