diff mbox series

[net,4/4] selftests: more UDP GRO tests

Message ID 31746302323edf8282b8c9e80293ca45f1dbbf03.1620223174.git.pabeni@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series udp: more FRAGLIST fixes | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 12 maintainers not CCed: linux-kselftest@vger.kernel.org yhs@fb.com hawk@kernel.org daniel@iogearbox.net andrii@kernel.org kpsingh@kernel.org bpf@vger.kernel.org kafai@fb.com ast@kernel.org john.fastabend@gmail.com songliubraving@fb.com shuah@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? WARNING: line length of 91 exceeds 80 columns WARNING: line length of 98 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Paolo Abeni May 5, 2021, 3:35 p.m. UTC
Introduces explicit scenarios for the issues addressed
on the previous patches, and functionally checks the
expected aggregation and segmentation.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 tools/testing/selftests/net/set_sysfs_attr.sh | 15 ++++++
 tools/testing/selftests/net/udpgro_fwd.sh     | 54 +++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100755 tools/testing/selftests/net/set_sysfs_attr.sh
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/set_sysfs_attr.sh b/tools/testing/selftests/net/set_sysfs_attr.sh
new file mode 100755
index 000000000000..fd042a162326
--- /dev/null
+++ b/tools/testing/selftests/net/set_sysfs_attr.sh
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+if [ $# -lt 2 ]; then
+	echo -e "syntax:\n$0 <device> <attr> [<value>]"
+	exit 0
+fi
+
+mount -t sysfs /sys 2>/dev/null
+if [ $# -lt 3 ]; then
+	cat /sys/class/net/$1/$2
+	exit $?
+fi
+
+echo $3 > /sys/class/net/$1/$2
diff --git a/tools/testing/selftests/net/udpgro_fwd.sh b/tools/testing/selftests/net/udpgro_fwd.sh
index a8fa64136282..8569b3f81fd7 100755
--- a/tools/testing/selftests/net/udpgro_fwd.sh
+++ b/tools/testing/selftests/net/udpgro_fwd.sh
@@ -79,6 +79,16 @@  create_vxlan_pair() {
 	done
 }
 
+move_address() {
+	local -r ns=$1
+	local -r src_dev=$2
+	local -r dst_dev=$3
+	local -r addr=$4
+
+	ip -n $ns addr del dev $src_dev $addr
+	ip -n $ns addr add dev $dst_dev $addr nodad 2>/dev/null
+}
+
 is_ipv6() {
 	if [[ $1 =~ .*:.* ]]; then
 		return 0
@@ -86,6 +96,35 @@  is_ipv6() {
 	return 1
 }
 
+create_bridge() {
+	local vxdev=vxlan$SRC
+	local src=$1
+	local i
+
+	is_ipv6 $src && vxdev=vxlan6$SRC
+
+	create_vxlan_pair
+	ip -n $NS_SRC link add name br_port type veth peer name br_port_peer
+	ip -n $NS_SRC link add name br0 type bridge
+	ip -n $NS_SRC link set dev br0 up
+	ip -n $NS_SRC link set dev br_port_peer up
+	ip -n $NS_SRC link set dev br_port up master br0
+	ip -n $NS_SRC link set dev $vxdev master br0
+	move_address $NS_SRC $vxdev br_port_peer $src/24
+
+	ip -n $NS_SRC link set br_port xdp object ../bpf/xdp_dummy.o section xdp_dummy 2>/dev/null
+	ip netns exec $NS_SRC ./set_sysfs_attr.sh br_port threaded 1
+
+	# slowing down the input path, we will help the napi thread to
+	# aggregate as much packets as possible via GRO
+	modprobe br_netfilter 2>/dev/null
+	ip netns exec $NS_SRC sysctl -qw net.bridge.bridge-nf-call-iptables=1
+	ip netns exec $NS_SRC sysctl -qw net.bridge.bridge-nf-call-ip6tables=1
+	for i in `seq 1 100`; do
+		ip netns exec $NS_SRC $IPT -A FORWARD
+	done
+}
+
 run_test() {
 	local -r msg=$1
 	local -r dst=$2
@@ -228,6 +267,21 @@  for family in 4 6; do
 	run_test "GRO frag list over UDP tunnel" $OL_NET$DST 1 1
 	cleanup
 
+	create_bridge $OL_NET$SRC
+	ip netns exec $NS_SRC ethtool -K br_port rx-gro-list on
+	ip netns exec $NS_SRC ethtool -K br_port_peer tx-udp-segmentation off
+	ip netns exec $NS_DST ethtool -K veth$DST rx-gro-list on
+	run_test "GRO frag list over UDP tunnel segmentation" $OL_NET$DST 1 1
+	cleanup
+
+	create_bridge $OL_NET$SRC
+	ip netns exec $NS_SRC ethtool -K br_port rx-gro-list on
+	ip netns exec $NS_SRC ethtool -K br_port_peer tx-udp-segmentation off
+	ip netns exec $NS_DST ethtool -K veth$DST rx-gro-list on
+	ip netns exec $NS_SRC ethtool -K veth$SRC tx off
+	run_test "GRO frag list over UDP tunnel segmentation (tx csum off)" $OL_NET$DST 1 1
+	cleanup
+
 	# use NAT to circumvent GRO FWD check
 	create_vxlan_pair
 	ip -n $NS_DST addr add dev $VXDEV$DST $OL_NET$DST_NAT/$SUFFIX