tools/testing/selftests/net/io_uring_zerocopy_tx.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/io_uring_zerocopy_tx.sh
Extension
.sh
Size
3402 bytes
Lines
136
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
#
# Send data between two processes across namespaces
# Run twice: once without and once with zerocopy

set -e

readonly DEV="veth0"
readonly DEV_MTU=65535
readonly BIN_TX="./io_uring_zerocopy_tx"
readonly BIN_RX="./msg_zerocopy"

readonly RAND="$(mktemp -u XXXXXX)"
readonly NSPREFIX="ns-${RAND}"
readonly NS1="${NSPREFIX}1"
readonly NS2="${NSPREFIX}2"

readonly SADDR4='192.168.1.1'
readonly DADDR4='192.168.1.2'
readonly SADDR6='fd::1'
readonly DADDR6='fd::2'

readonly path_sysctl_mem="net.core.optmem_max"

# No arguments: automated test
if [[ "$#" -eq "0" ]]; then
	IPs=( "4" "6" )

	for IP in "${IPs[@]}"; do
		for mode in $(seq 1 3); do
			$0 "$IP" udp -m "$mode" -t 1 -n 32
			$0 "$IP" tcp -m "$mode" -t 1 -n 1
		done
	done

	echo "OK. All tests passed"
	exit 0
fi

# Argument parsing
if [[ "$#" -lt "2" ]]; then
	echo "Usage: $0 [4|6] [tcp|udp|raw|raw_hdrincl|packet|packet_dgram] <args>"
	exit 1
fi

readonly IP="$1"
shift
readonly TXMODE="$1"
shift
readonly EXTRA_ARGS="$@"

# Argument parsing: configure addresses
if [[ "${IP}" == "4" ]]; then
	readonly SADDR="${SADDR4}"
	readonly DADDR="${DADDR4}"
elif [[ "${IP}" == "6" ]]; then
	readonly SADDR="${SADDR6}"
	readonly DADDR="${DADDR6}"
else
	echo "Invalid IP version ${IP}"
	exit 1
fi

# Argument parsing: select receive mode
#
# This differs from send mode for
# - packet:	use raw recv, because packet receives skb clones
# - raw_hdrinc: use raw recv, because hdrincl is a tx-only option
case "${TXMODE}" in
'packet' | 'packet_dgram' | 'raw_hdrincl')

Annotation

Implementation Notes