Skip to content

Commit 6788d44

Browse files
committed
Merge branch 'net-gro-fix-outer-network-offset'
Paolo Abeni says: ==================== net: gro: fix outer network offset The GRO stage has still problems in some edge scenarios when dealing with encapsulated traffic: the first patch address an issue there leading to bad checksums. The second patch introduces a test case covering the relevant scenario: S/W segmentation after GRO for encapsulated traffic. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents f613e8b + bee60ce commit 6788d44

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

net/core/gro.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ static void gro_complete(struct gro_node *gro, struct sk_buff *skb)
265265
goto out;
266266
}
267267

268+
/* NICs can feed encapsulated packets into GRO */
269+
skb->encapsulation = 0;
268270
rcu_read_lock();
269271
list_for_each_entry_rcu(ptype, head, list) {
270272
if (ptype->type != type || !ptype->callbacks.gro_complete)

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)