]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftest: net: add a test-case for encap segmentation after GRO
authorPaolo Abeni <pabeni@redhat.com>
Mon, 2 Feb 2026 11:43:15 +0000 (12:43 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 4 Feb 2026 03:23:41 +0000 (19:23 -0800)
We had a few patches in this area and no explicit coverage so far.
The test case covers the scenario addressed by the previous fix;
reusing the existing udpgro_fwd.sh script to leverage part of the
of the virtual network setup, even if such script is possibly not
a perfect fit.

Note that the mentioned script already contains several shellcheck
violation; this patch does not fix the existing code, just avoids
adding more issues in the new one.

Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Link: https://patch.msgid.link/768ca132af81e83856e34d3105b86c37e566a7ad.1770032084.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/udpgro_fwd.sh

index a39fdc4aa2ffb3039c893e401b3aef7742841a1c..9b722c1e4b0fe98042aa4e3f30464dcb78a54ffe 100755 (executable)
@@ -162,6 +162,39 @@ run_test() {
        echo " ok"
 }
 
+run_test_csum() {
+       local -r msg="$1"
+       local -r dst="$2"
+       local csum_error_filter=UdpInCsumErrors
+       local csum_errors
+
+       printf "%-40s" "$msg"
+
+       is_ipv6 "$dst" && csum_error_filter=Udp6InCsumErrors
+
+       ip netns exec "$NS_DST" iperf3 -s -1 >/dev/null &
+       wait_local_port_listen "$NS_DST" 5201 tcp
+       local spid="$!"
+       ip netns exec "$NS_SRC" iperf3 -c "$dst" -t 2 >/dev/null
+       local retc="$?"
+       wait "$spid"
+       local rets="$?"
+       if [ "$rets" -ne 0 ] || [ "$retc" -ne 0 ]; then
+               echo " fail client exit code $retc, server $rets"
+               ret=1
+               return
+       fi
+
+       csum_errors=$(ip netns exec "$NS_DST" nstat -as "$csum_error_filter" |
+                     grep "$csum_error_filter" | awk '{print $2}')
+       if [ -n "$csum_errors" ] && [ "$csum_errors" -gt 0 ]; then
+               echo " fail - csum error on receive $csum_errors, expected 0"
+               ret=1
+               return
+       fi
+       echo " ok"
+}
+
 run_bench() {
        local -r msg=$1
        local -r dst=$2
@@ -260,6 +293,37 @@ for family in 4 6; do
        ip netns exec $NS_SRC $PING -q -c 1 $OL_NET$DST_NAT >/dev/null
        run_test "GRO fwd over UDP tunnel" $OL_NET$DST_NAT 10 10 $OL_NET$DST
        cleanup
+
+       # force segmentation and re-aggregation
+       create_vxlan_pair
+       ip netns exec "$NS_DST" ethtool -K veth"$DST" generic-receive-offload on
+       ip netns exec "$NS_SRC" ethtool -K veth"$SRC" tso off
+       ip -n "$NS_SRC" link set dev veth"$SRC" mtu 1430
+
+       # forward to a 2nd veth pair
+       ip -n "$NS_DST" link add br0 type bridge
+       ip -n "$NS_DST" link set dev veth"$DST" master br0
+
+       # segment the aggregated TSO packet, without csum offload
+       ip -n "$NS_DST" link add veth_segment type veth peer veth_rx
+       for FEATURE in tso tx-udp-segmentation tx-checksumming; do
+               ip netns exec "$NS_DST" ethtool -K veth_segment "$FEATURE" off
+       done
+       ip -n "$NS_DST" link set dev veth_segment master br0 up
+       ip -n "$NS_DST" link set dev br0 up
+       ip -n "$NS_DST" link set dev veth_rx up
+
+       # move the lower layer IP in the last added veth
+       for ADDR in "$BM_NET_V4$DST/24" "$BM_NET_V6$DST/64"; do
+               # the dad argument will let iproute emit a unharmful warning
+               # with ipv4 addresses
+               ip -n "$NS_DST" addr del dev veth"$DST" "$ADDR"
+               ip -n "$NS_DST" addr add dev veth_rx "$ADDR" \
+                       nodad 2>/dev/null
+       done
+
+       run_test_csum "GSO after GRO" "$OL_NET$DST"
+       cleanup
 done
 
 exit $ret