* [PATCH net-next] selftests: net: bareudp: Add stream tests with software GSO
@ 2026-10-08 5:59 Haishuang Yan
2026-10-11 1:23 ` netdev-bot+sashiko
0 siblings, 1 reply; 3+ messages in thread
From: Haishuang Yan @ 2026-10-08 5:59 UTC (permalink / raw)
To: netdev
Cc: Willem de Bruijn, Martin Varghese, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan, linux-kselftest, linux-kernel, Haishuang Yan
The bareudp tests only send pings, which are not GSO packets, so the
segmentation path of bareudp is not covered.
Copy a file over TCP from NS0 to NS3 with socat after each ping test,
with UDP tunnel segmentation offload disabled on the underlay veths, so
that the GSO packets encapsulated by bareudp are segmented in software.
Raise the MTU of the underlay veths, so that full sized packets fit with
the encapsulation, as there is no path MTU discovery through bareudp.
The ping and stream tests share the result reporting, so move it into
report_result(). Without socat or ethtool, the stream tests are skipped.
Without commit c57b2e60d4bf ("bareudp: set the inner protocol to the
protocol of the packet"), the IPv4 and IPv6 streams over UDPv6, and the
IPv6 stream over UDPv4 in multiproto mode, time out.
Suggested-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
tools/testing/selftests/net/bareudp.sh | 93 ++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/bareudp.sh b/tools/testing/selftests/net/bareudp.sh
index d9e5b967f815..4b6d3a64f3c3 100755
--- a/tools/testing/selftests/net/bareudp.sh
+++ b/tools/testing/selftests/net/bareudp.sh
@@ -105,17 +105,27 @@
# | (encapsulated with MPLS label 200) |
# | |
# +-----------------------------------------------------------------------+
+#
+# Besides the ping tests, a file is copied over TCP from NS0 to NS3 with
+# socat. UDP tunnel segmentation offload is disabled on veth12 and veth21,
+# so that the GSO packets encapsulated by bareudp are segmented in software.
+# These two veths get a larger MTU to fit the encapsulation.
. ./lib.sh
ERR=4 # Return 4 by default, which is the SKIP code for kselftest
PING6="ping"
PAUSE_ON_FAIL="no"
+STREAM="yes"
+STREAM_PORT=5000
+STREAM_TIMEOUT=10
+TMPFILE=""
# Exit the script after having removed the network namespaces it created
exit_cleanup()
{
cleanup_all_ns
+ [ -n "${TMPFILE}" ] && rm -f "${TMPFILE}"
if [ "${ERR}" -eq 4 ]; then
echo "Error: Setting up the testing environment failed." >&2
@@ -180,6 +190,29 @@ setup_underlay()
tc -netns "${NS1}" qdisc add dev veth10 ingress
tc -netns "${NS2}" qdisc add dev veth23 ingress
+
+ if [ "${STREAM}" = "yes" ]; then
+ # Leave room for the encapsulation on the underlay, so that full
+ # sized packets from NS0 can be tunnelled without fragmentation
+ ip -netns "${NS1}" link set dev veth12 mtu 1600
+ ip -netns "${NS2}" link set dev veth21 mtu 1600
+
+ # Segment the encapsulated GSO packets in software
+ ip netns exec "${NS1}" ethtool -K veth12 \
+ tx-udp_tnl-segmentation off \
+ tx-udp_tnl-csum-segmentation off
+ ip netns exec "${NS2}" ethtool -K veth21 \
+ tx-udp_tnl-segmentation off \
+ tx-udp_tnl-csum-segmentation off
+
+ TMPFILE=$(mktemp)
+ dd if=/dev/urandom of="${TMPFILE}" bs=1M count=16 status=none
+
+ ip netns exec "${NS3}" socat -u \
+ TCP6-LISTEN:"${STREAM_PORT}",ipv6only=0,reuseaddr,fork \
+ OPEN:/dev/null &
+ wait_local_port_listen "${NS3}" "${STREAM_PORT}" tcp
+ fi
}
# Set up the IPv4, IPv6 and MPLS overlays.
@@ -252,9 +285,6 @@ setup_overlay_mpls()
# * $2: the IP address to ping,
# * $3: a human readable description of the purpose of the test.
#
-# If the test fails and PAUSE_ON_FAIL is active, the user is given the
-# possibility to continue with the next test or to quit immediately.
-#
ping_test_one()
{
local PING="$1"; readonly PING
@@ -269,7 +299,50 @@ ping_test_one()
RET=$?
set -e
- if [ "${RET}" -eq 0 ]; then
+ report_result "${RET}"
+}
+
+# Copy a file over TCP from NS0 to NS3 and print the result
+#
+# Parameters:
+#
+# * $1: the socat address of the receiver,
+# * $2: a human readable description of the purpose of the test.
+#
+stream_test_one()
+{
+ local ADDR="$1"; readonly ADDR
+ local MSG="$2"; readonly MSG
+ local RET
+
+ printf "TEST: %-60s " "${MSG}"
+
+ if [ "${STREAM}" != "yes" ]; then
+ printf "[SKIP]\n"
+ return
+ fi
+
+ set +e
+ ip netns exec "${NS0}" timeout "${STREAM_TIMEOUT}" \
+ socat -u OPEN:"${TMPFILE}" "${ADDR}" > /dev/null 2>&1
+ RET=$?
+ set -e
+
+ report_result "${RET}"
+}
+
+# Print the result of a test
+#
+# Parameters:
+#
+# * $1: the exit code of the test.
+#
+# If the test fails and PAUSE_ON_FAIL is active, the user is given the
+# possibility to continue with the next test or to quit immediately.
+#
+report_result()
+{
+ if [ "$1" -eq 0 ]; then
printf "[ OK ]\n"
else
ERR=1
@@ -307,12 +380,18 @@ ping_test()
if [ $IPV4 ]; then
ping_test_one "ping" "192.0.2.103" "IPv4 packets over ${UNDERLAY}${MODE}"
+ stream_test_one "TCP4:192.0.2.103:${STREAM_PORT}" \
+ "IPv4 stream over ${UNDERLAY}${MODE}"
fi
if [ $IPV6 ]; then
ping_test_one "${PING6}" "2001:db8::103" "IPv6 packets over ${UNDERLAY}${MODE}"
+ stream_test_one "TCP6:[2001:db8::103]:${STREAM_PORT}" \
+ "IPv6 stream over ${UNDERLAY}${MODE}"
fi
if [ $MPLS_UC ]; then
ping_test_one "${PING6}" "2001:db8::203" "Unicast MPLS packets over ${UNDERLAY}${MODE}"
+ stream_test_one "TCP6:[2001:db8::203]:${STREAM_PORT}" \
+ "Unicast MPLS stream over ${UNDERLAY}${MODE}"
fi
}
@@ -471,6 +550,12 @@ check_features()
# Use ping6 on systems where ping doesn't handle IPv6
ping -w 1 -c 1 ::1 > /dev/null 2>&1 || PING6="ping6"
+
+ if [ ! -x "$(command -v socat)" ] ||
+ [ ! -x "$(command -v ethtool)" ]; then
+ echo "socat or ethtool not found, skipping the stream tests" >&2
+ STREAM="no"
+ fi
}
usage()
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] selftests: net: bareudp: Add stream tests with software GSO
2026-10-08 5:59 [PATCH net-next] selftests: net: bareudp: Add stream tests with software GSO Haishuang Yan
@ 2026-10-11 1:23 ` netdev-bot+sashiko
2026-10-11 10:30 ` Haishuang Yan
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-10-11 1:23 UTC (permalink / raw)
To: yanhaishuang
Cc: netdev, willemb, martin.varghese, davem, edumazet, kuba, pabeni,
horms, shuah, linux-kselftest, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The two new "Unicast MPLS stream over UDPv4/UDPv6" tests never
push a GSO packet through bareudp's UDP-tunnel software segmentation.
- [Low] exit_cleanup() calls cleanup_all_ns before the new `[ -n
"${TMPFILE}" ] && rm -f "${TMPFILE}"`.
--
selftests: net: bareudp: Add stream tests with software GSO
This patch adds TCP stream tests to bareudp.sh. After each ping test, a
16 MiB file is copied with socat from NS0 to NS3. UDP tunnel segmentation
offload is turned off on the underlay veths so that bareudp's GSO packets
are segmented in software.
> diff --git a/tools/testing/selftests/net/bareudp.sh b/tools/testing/selftests/net/bareudp.sh
> index d9e5b967f8151..4b6d3a64f3c3f 100755
> --- a/tools/testing/selftests/net/bareudp.sh
> +++ b/tools/testing/selftests/net/bareudp.sh
> @@ -105,17 +105,27 @@
[ ... ]
> # Exit the script after having removed the network namespaces it created
> exit_cleanup()
> {
> cleanup_all_ns
> + [ -n "${TMPFILE}" ] && rm -f "${TMPFILE}"
[Severity: Low]
exit_cleanup() runs from the EXIT trap, and set -e is still active at that
point. cleanup_all_ns can return non-zero. For example, cleanup_ns() in
lib.sh sets ret=1 when it hits this path:
tools/testing/selftests/net/lib.sh:cleanup_ns() {
...
if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
echo "Warn: Failed to remove namespace $ns"
ret=1
...
}
When that happens, does the shell exit before the rm? That would leave the
16 MiB file that setup_underlay() created with mktemp and dd in $TMPDIR.
Would it help to remove TMPFILE before calling cleanup_all_ns, or to
tolerate its failure?
[ ... ]
> @@ -307,12 +380,18 @@ ping_test()
[ ... ]
> if [ $MPLS_UC ]; then
> ping_test_one "${PING6}" "2001:db8::203" "Unicast MPLS packets over ${UNDERLAY}${MODE}"
> + stream_test_one "TCP6:[2001:db8::203]:${STREAM_PORT}" \
> + "Unicast MPLS stream over ${UNDERLAY}${MODE}"
> fi
> }
[Severity: Medium]
The new header comment says:
so that the GSO packets encapsulated by bareudp are segmented in software.
Does that hold for the two Unicast MPLS stream tests?
In NS0, mpls_xmit() sets skb->protocol to ETH_P_MPLS_UC. veth01 advertises
GSO in its MPLS features:
drivers/net/veth.c:veth_setup() {
...
dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE;
...
}
So the TSO skb reaches NS1 unsegmented, and the veth10 ingress rule
redirects it to bareudp_ns1. There, validate_xmit_skb() masks the features
through netif_skb_features()->harmonize_features()->net_mpls_features():
net/core/dev.c:net_mpls_features() {
...
features &= skb->dev->mpls_features;
...
}
bareudp_setup() sets dev->features and dev->hw_features but never
dev->mpls_features. That field only holds NETIF_F_SG, which
register_netdevice() adds, so all the TSO bits are cleared.
If mpls_gso is loaded, mpls_gso_segment() splits the skb before
bareudp_xmit(). bareudp then only encapsulates single segment packets, and
software UDP tunnel segmentation on veth12/veth21 never runs for MPLS.
If no ETH_P_MPLS_UC offload is registered, skb_mac_gso_segment() returns
-EPROTONOSUPPORT and the skb is dropped. With CONFIG_NET_MPLS_GSO=n, the
drop happens later instead, in skb_udp_tunnel_segment() at veth12, because
the inner protocol is MPLS.
tools/testing/selftests/net/config doesn't list CONFIG_NET_MPLS_GSO. It
only ends up =m through CONFIG_OPENVSWITCH=m, and nothing loads
mpls_gso.ko automatically. In those setups, could the MPLS stream tests
time out on a correct kernel?
The commit message also suggests these tests don't reach the tunnel GSO
path:
Without commit c57b2e60d4bf ("bareudp: set the inner protocol to the
protocol of the packet"), the IPv4 and IPv6 streams over UDPv6, and the
IPv6 stream over UDPv4 in multiproto mode, time out.
Before that commit, an MPLS GSO skb reaching UDPv6 tunnel segmentation
would have kept the stale ETH_P_IPV6 inner protocol from mpls_xmit(). Yet
the MPLS stream over UDPv6 isn't listed as timing out.
Should the MPLS stream tests be dropped? Alternatively, the header comment
and commit message could be updated and CONFIG_NET_MPLS_GSO added to the
selftests config.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261008055920.1560930-1-yanhaishuang%40cmss.chinamobile.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] selftests: net: bareudp: Add stream tests with software GSO
2026-10-11 1:23 ` netdev-bot+sashiko
@ 2026-10-11 10:30 ` Haishuang Yan
0 siblings, 0 replies; 3+ messages in thread
From: Haishuang Yan @ 2026-10-11 10:30 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, willemb, martin.varghese, davem, edumazet, kuba, pabeni,
horms, shuah, linux-kselftest, linux-kernel
On Sun, Oct 11, 2026 at 01:23:25 +0000, netdev-bot+sashiko@kernel.org wrote:
> [Severity: Medium]
> The new header comment says:
>
> so that the GSO packets encapsulated by bareudp are segmented in software.
>
> Does that hold for the two Unicast MPLS stream tests?
[...]
> Should the MPLS stream tests be dropped? Alternatively, the header comment
> and commit message could be updated and CONFIG_NET_MPLS_GSO added to the
> selftests config.
Right. Counting calls with the function profiler, the MPLS streams only
go through mpls_gso_segment() and never reach skb_udp_tunnel_segment(),
while the IPv4 streams do. With mpls_gso blocked from loading, both
MPLS streams fail. (When it is a module, it does get loaded here, as a
softdep of mpls_iptunnel, but the tests do not reach the tunnel GSO
path anyway.)
I will drop the MPLS stream tests in v2.
> [Severity: Low]
> exit_cleanup() calls cleanup_all_ns before the new `[ -n
> "${TMPFILE}" ] && rm -f "${TMPFILE}"`.
[...]
> Would it help to remove TMPFILE before calling cleanup_all_ns, or to
> tolerate its failure?
Yes, v2 will remove it first.
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-11 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 5:59 [PATCH net-next] selftests: net: bareudp: Add stream tests with software GSO Haishuang Yan
2026-10-11 1:23 ` netdev-bot+sashiko
2026-10-11 10:30 ` Haishuang Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®