tools/testing/selftests/net/xfrm_state.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/xfrm_state.sh
Extension
.sh
Size
18110 bytes
Lines
614
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 -e
# SPDX-License-Identifier: GPL-2.0
#
# xfrm/IPsec tests.
# Currently implemented:
# - ICMP error source address verification (IETF RFC 4301 section 6)
# - ICMP MTU exceeded handling over IPsec tunnels.
#
# Addresses and topology:
# IPv4 prefix 10.1.c.d IPv6 prefix fc00:c::d/64 where c is the segment number
# and d is the interface identifier.
# IPv6 uses the same c:d as IPv4, and start with IPv6 prefix instead ipv4 prefix
#
# Network topology default: ns_set_v4 or ns_set_v6
#   1.1   1.2   2.1   2.2   3.1   3.2   4.1   4.2   5.1   5.2  6.1  6.2
#  eth0  eth1  eth0  eth1  eth0  eth1  eth0  eth1  eth0  eth1 eth0  eth1
# a -------- r1 -------- s1 -------- r2 -------- s2 -------- r3 -------- b
# a, b = Alice and Bob hosts without IPsec.
# r1, r2, r3 routers, without IPsec
# s1, s2, IPsec gateways/routers that setup tunnel(s).

# Network topology x: IPsec gateway that generates ICMP response - ns_set_v4x or ns_set_v6x
#   1.1   1.2   2.1   2.2   3.1   3.2   4.1   4.2   5.1   5.2
#  eth0  eth1  eth0  eth1  eth0  eth1  eth0  eth1  eth0  eth1
# a -------- r1 -------- s1 -------- r2 -------- s2 -------- b

. lib.sh

EXIT_ON_TEST_FAIL=no
PAUSE=no
VERBOSE=${VERBOSE:-0}
DEBUG=0

#	Name				Description
tests="
	unreachable_ipv4		IPv4 unreachable from router r3
	unreachable_ipv6		IPv6 unreachable from router r3
	unreachable_gw_ipv4		IPv4 unreachable from IPsec gateway s2
	unreachable_gw_ipv6		IPv6 unreachable from IPsec gateway s2
	mtu_ipv4_s2			IPv4 MTU exceeded from IPsec gateway s2
	mtu_ipv6_s2			IPv6 MTU exceeded from IPsec gateway s2
	mtu_ipv4_r2			IPv4 MTU exceeded from ESP router r2
	mtu_ipv6_r2			IPv6 MTU exceeded from ESP router r2
	mtu_ipv4_r3			IPv4 MTU exceeded from router r3
	mtu_ipv6_r3			IPv6 MTU exceeded from router r3"

prefix4="10.1"
prefix6="fc00"

run_cmd_err() {
	cmd="$*"

	if [ "$VERBOSE" -gt 0 ]; then
		printf "  COMMAND: %s\n" "$cmd"
	fi

	out="$($cmd 2>&1)" && rc=0 || rc=$?
	if [ "$VERBOSE" -gt 1 ] && [ -n "$out" ]; then
		echo "  $out"
		echo
	fi
	return 0
}

run_cmd() {
	run_cmd_err "$@" || exit 1
}

run_test() {
	# If errexit is set, unset it for sub-shell and restore after test

Annotation

Implementation Notes