Skip to content

Commit bee60ce

Browse files
Paolo Abenikuba-moo
authored andcommitted
selftest: net: add a test-case for encap segmentation after GRO
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 <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Link: https://patch.msgid.link/768ca132af81e83856e34d3105b86c37e566a7ad.1770032084.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5c2c3c3 commit bee60ce

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

tools/testing/selftests/net/udpgro_fwd.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,39 @@ run_test() {
162162
echo " ok"
163163
}
164164

165+
run_test_csum() {
166+
local -r msg="$1"
167+
local -r dst="$2"
168+
local csum_error_filter=UdpInCsumErrors
169+
local csum_errors
170+
171+
printf "%-40s" "$msg"
172+
173+
is_ipv6 "$dst" && csum_error_filter=Udp6InCsumErrors
174+
175+
ip netns exec "$NS_DST" iperf3 -s -1 >/dev/null &
176+
wait_local_port_listen "$NS_DST" 5201 tcp
177+
local spid="$!"
178+
ip netns exec "$NS_SRC" iperf3 -c "$dst" -t 2 >/dev/null
179+
local retc="$?"
180+
wait "$spid"
181+
local rets="$?"
182+
if [ "$rets" -ne 0 ] || [ "$retc" -ne 0 ]; then
183+
echo " fail client exit code $retc, server $rets"
184+
ret=1
185+
return
186+
fi
187+
188+
csum_errors=$(ip netns exec "$NS_DST" nstat -as "$csum_error_filter" |
189+
grep "$csum_error_filter" | awk '{print $2}')
190+
if [ -n "$csum_errors" ] && [ "$csum_errors" -gt 0 ]; then
191+
echo " fail - csum error on receive $csum_errors, expected 0"
192+
ret=1
193+
return
194+
fi
195+
echo " ok"
196+
}
197+
165198
run_bench() {
166199
local -r msg=$1
167200
local -r dst=$2
@@ -260,6 +293,37 @@ for family in 4 6; do
260293
ip netns exec $NS_SRC $PING -q -c 1 $OL_NET$DST_NAT >/dev/null
261294
run_test "GRO fwd over UDP tunnel" $OL_NET$DST_NAT 10 10 $OL_NET$DST
262295
cleanup
296+
297+
# force segmentation and re-aggregation
298+
create_vxlan_pair
299+
ip netns exec "$NS_DST" ethtool -K veth"$DST" generic-receive-offload on
300+
ip netns exec "$NS_SRC" ethtool -K veth"$SRC" tso off
301+
ip -n "$NS_SRC" link set dev veth"$SRC" mtu 1430
302+
303+
# forward to a 2nd veth pair
304+
ip -n "$NS_DST" link add br0 type bridge
305+
ip -n "$NS_DST" link set dev veth"$DST" master br0
306+
307+
# segment the aggregated TSO packet, without csum offload
308+
ip -n "$NS_DST" link add veth_segment type veth peer veth_rx
309+
for FEATURE in tso tx-udp-segmentation tx-checksumming; do
310+
ip netns exec "$NS_DST" ethtool -K veth_segment "$FEATURE" off
311+
done
312+
ip -n "$NS_DST" link set dev veth_segment master br0 up
313+
ip -n "$NS_DST" link set dev br0 up
314+
ip -n "$NS_DST" link set dev veth_rx up
315+
316+
# move the lower layer IP in the last added veth
317+
for ADDR in "$BM_NET_V4$DST/24" "$BM_NET_V6$DST/64"; do
318+
# the dad argument will let iproute emit a unharmful warning
319+
# with ipv4 addresses
320+
ip -n "$NS_DST" addr del dev veth"$DST" "$ADDR"
321+
ip -n "$NS_DST" addr add dev veth_rx "$ADDR" \
322+
nodad 2>/dev/null
323+
done
324+
325+
run_test_csum "GSO after GRO" "$OL_NET$DST"
326+
cleanup
263327
done
264328

265329
exit $ret

0 commit comments

Comments
 (0)