tools/testing/selftests/net/udpgro.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/udpgro.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/udpgro.sh
Extension
.sh
Size
5847 bytes
Lines
221
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Run a series of udpgro functional tests.

source lib.sh

readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"

# set global exit status, but never reset nonzero one.
check_err()
{
	if [ $ret -eq 0 ]; then
		ret=$1
	fi
}

cleanup() {
	local -r jobs="$(jobs -p)"
	local -r ns="$(ip netns list|grep $PEER_NS)"

	[ -n "${jobs}" ] && kill -1 ${jobs} 2>/dev/null
	[ -n "$ns" ] && ip netns del $ns 2>/dev/null
}
trap cleanup EXIT

cfg_veth() {
	ip netns add "${PEER_NS}"
	ip -netns "${PEER_NS}" link set lo up
	ip link add type veth
	ip link set dev veth0 up
	ip addr add dev veth0 192.168.1.2/24
	ip addr add dev veth0 2001:db8::2/64 nodad

	ip link set dev veth1 netns "${PEER_NS}"
	ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
	ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
	ip -netns "${PEER_NS}" link set dev veth1 up
	ip netns exec "${PEER_NS}" ethtool -K veth1 gro on
}

run_one() {
	# use 'rx' as separator between sender args and receiver args
	local -r all="$@"
	local -r tx_args=${all%rx*}
	local -r rx_args=${all#*rx}
	local ret=0

	cfg_veth

	ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 100 ${rx_args} &
	local PID1=$!

	wait_local_port_listen ${PEER_NS} 8000 udp
	./udpgso_bench_tx ${tx_args}
	check_err $?
	wait ${PID1}
	check_err $?
	[ "$ret" -eq 0 ] && echo "ok" || echo "failed"
	return $ret
}

run_test() {
	local -r args=$@

	printf " %-40s" "$1"
	./in_netns.sh $0 __subprocess $2 rx -G -r $3
}

run_one_nat() {

Annotation

Implementation Notes