tools/testing/selftests/net/double_udp_encap.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/double_udp_encap.sh
Extension
.sh
Size
10652 bytes
Lines
394
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

source lib.sh

# shellcheck disable=SC2155 # prefer RO variable over return value from cmd
readonly CLI="$(dirname "$(readlink -f "$0")")/../../../net/ynl/pyynl/cli.py"

readonly SRC=1
readonly DST=2

readonly NET_V4=192.168.1.
readonly NET_V6=2001:db8::
readonly OL1_NET_V4=172.16.1.
readonly OL1_NET_V6=2001:db8:1::
readonly OL2_NET_V4=172.16.2.
readonly OL2_NET_V6=2001:db8:2::

trap cleanup_all_ns EXIT

# shellcheck disable=SC2329 # can't figure out usage trough a variable
is_ipv6() {
	if [[ $1 =~ .*:.* ]]; then
		return 0
	fi
	return 1
}

# shellcheck disable=SC2329 # can't figure out usage trough a variable
create_gnv_endpoint() {
	local -r netns=$1
	local -r bm_rem_addr=$2
	local -r gnv_dev=$3
	local -r gnv_id=$4
	local opts=$5
	local gnv_json
	local rem

	if is_ipv6 "$bm_rem_addr"; then
		rem=remote6
	else
		rem=remote
	fi

	# add ynl opt separator, if needed
	[ -n "$opts" ] && opts=", $opts"

	gnv_json="{ \"id\": $gnv_id, \"$rem\": \"$bm_rem_addr\"$opts }"
	ip netns exec "$netns" "$CLI" --family rt-link --create --excl \
	   --do newlink  --json "{\"ifname\": \"$gnv_dev\",
	       \"linkinfo\": {\"kind\":\"geneve\",
	       \"data\": $gnv_json } }" > /dev/null
	ip -n "$netns" link set dev "$gnv_dev" up
}

# shellcheck disable=SC2329 # can't figure out usage trough a variable
create_vxlan_endpoint() {
	local -r netns=$1
	local -r bm_rem_addr=$2
	local -r vxlan_dev=$3
	local -r vxlan_id=$4
	local -r opts_str=$5
	local oldifs
	local -a opts
	local opt

	# convert the arguments from yaml format
	oldifs=$IFS
	IFS=','
	for opt in $opts_str; do

Annotation

Implementation Notes