[PATCH net-next v2 2/2] selftests: net: big_tcp_tunnels: Cover bareudp

From: Haishuang Yan

Date: Sat Oct 03 2026 - 06:11:14 EST


Now that bareudp allows BIG TCP too, run the same checks over bareudp as
for vxlan and geneve.

bareudp only works in external mode, so attach the tunnel metadata to
all packets sent through the device with a tc tunnel_key action on
egress. The device uses ethertype ipv4 with multiproto, so that both
IPv4 and IPv6 traffic can go through it. Its MTU does not account for
the encapsulation, so lower it to leave room for the IPv6 and UDP
headers, otherwise the encapsulated packets would be fragmented.

Assisted-by: LLM
Signed-off-by: Haishuang Yan <yanhaishuang@xxxxxxxxxxxxxxxxxxxx>
---
.../testing/selftests/net/big_tcp_tunnels.sh | 45 ++++++++++++++++---
1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/net/big_tcp_tunnels.sh b/tools/testing/selftests/net/big_tcp_tunnels.sh
index cc0875e52fb9..cf38377f576b 100755
--- a/tools/testing/selftests/net/big_tcp_tunnels.sh
+++ b/tools/testing/selftests/net/big_tcp_tunnels.sh
@@ -53,6 +53,16 @@ setup() {
DEFAULT_TCP_MIN_TSO_SEGS=$(ip netns exec "$CLIENT_NS" sysctl -n net.ipv4.tcp_min_tso_segs)
}

+# bareudp only works in external mode: attach the tunnel metadata to all
+# packets sent through the device. Its MTU does not account for the
+# encapsulation either, so leave room for IPv6 and UDP headers.
+setup_bareudp() {
+ ip -netns "$1" link set "$2" mtu 1452
+ tc -netns "$1" qdisc add dev "$2" clsact
+ tc -netns "$1" filter add dev "$2" egress matchall \
+ action tunnel_key set src_ip "$3" dst_ip "$4" id 0 ttl 64
+}
+
setup_tunnel() {
if [ "$2" = 4 ]; then
SERVER_IP="$SERVER_IP4"
@@ -64,26 +74,42 @@ setup_tunnel() {
echo "Setting up ${1^^} over IPv6, veth tx csum offload $3"
fi

- if [ "$1" = vxlan ]; then
+ case "$1" in
+ vxlan)
ip -netns "$CLIENT_NS" link add tun0 type vxlan \
id 5001 remote "$SERVER_IP" local "$CLIENT_IP" dev link0 dstport 4789
- else
+ ;;
+ geneve)
ip -netns "$CLIENT_NS" link add tun0 type geneve \
id 5001 remote "$SERVER_IP"
- fi
+ ;;
+ bareudp)
+ ip -netns "$CLIENT_NS" link add tun0 type bareudp \
+ dstport 6635 ethertype ipv4 multiproto
+ setup_bareudp "$CLIENT_NS" tun0 "$CLIENT_IP" "$SERVER_IP"
+ ;;
+ esac
ip -netns "$CLIENT_NS" link set tun0 up
ip -netns "$CLIENT_NS" addr replace "$CLIENT_IP4_TUN/24" dev tun0
ip -netns "$CLIENT_NS" addr replace "$CLIENT_IP6_TUN/112" dev tun0 nodad
ip -netns "$CLIENT_NS" link set tun0 \
gso_max_size 196608 gso_ipv4_max_size 196608 \
gro_max_size 196608 gro_ipv4_max_size 196608
- if [ "$1" = vxlan ]; then
+ case "$1" in
+ vxlan)
ip -netns "$SERVER_NS" link add tun1 type vxlan \
id 5001 remote "$CLIENT_IP" local "$SERVER_IP" dev link1 dstport 4789
- else
+ ;;
+ geneve)
ip -netns "$SERVER_NS" link add tun1 type geneve \
id 5001 remote "$CLIENT_IP"
- fi
+ ;;
+ bareudp)
+ ip -netns "$SERVER_NS" link add tun1 type bareudp \
+ dstport 6635 ethertype ipv4 multiproto
+ setup_bareudp "$SERVER_NS" tun1 "$SERVER_IP" "$CLIENT_IP"
+ ;;
+ esac
ip -netns "$SERVER_NS" link set tun1 up
ip -netns "$SERVER_NS" addr replace "$SERVER_IP4_TUN/24" dev tun1
ip -netns "$SERVER_NS" addr replace "$SERVER_IP6_TUN/112" dev tun1 nodad
@@ -192,6 +218,11 @@ if ! iptables --version &> /dev/null; then
exit "$ksft_skip"
fi

+if ! tc -V &> /dev/null; then
+ echo "SKIP: Could not run test without tc tool"
+ exit "$ksft_skip"
+fi
+
if ! ethtool --version &> /dev/null; then
echo "SKIP: Could not run test without ethtool tool"
exit "$ksft_skip"
@@ -205,7 +236,7 @@ fi
WORKDIR=$(mktemp -d)
trap cleanup EXIT
setup
-for tunnel in vxlan geneve; do
+for tunnel in vxlan geneve bareudp; do
for tun_family in 4 6; do
for traffic_family in 4 6; do
for csum_offload in on off; do
--
2.43.0