tools/testing/selftests/net/test_vxlan_fdb_changelink.sh

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

File Facts

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

ALL_TESTS="
	test_set_remote
	test_change_mc_remote
"
source lib.sh

check_remotes()
{
	local what=$1; shift
	local N=$(bridge fdb sh dev vx | grep 00:00:00:00:00:00 | wc -l)

	((N == 2))
	check_err $? "expected 2 remotes after $what, got $N"
}

# Check FDB default-remote handling across "ip link set".
test_set_remote()
{
	RET=0

	adf_ip_link_add vx up type vxlan id 2000 dstport 4789
	bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.20 self permanent
	bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.30 self permanent
	check_remotes "fdb append"

	ip link set dev vx type vxlan remote 192.0.2.30
	check_remotes "link set"

	log_test 'FDB default-remote handling across "ip link set"'
}

fmt_remote()
{
	local addr=$1; shift

	if [[ $addr == 224.* ]]; then
		echo "group $addr"
	else
		echo "remote $addr"
	fi
}

change_remote()
{
	local remote=$1; shift

	ip link set dev vx type vxlan $(fmt_remote $remote) dev v1
}

check_membership()
{
	local check_vec=("$@")

	local memberships
	memberships=$(
	    netstat -n --groups |
		sed -n '/^v1\b/p' |
		grep -o '[^ ]*$'
	)
	check_err $? "Couldn't obtain group memberships"

	local item
	for item in "${check_vec[@]}"; do
		eval "local $item"
		echo "$memberships" | grep -q "\b$group\b"
		check_err_fail $fail $? "$group is_ex reported in IGMP query response"
	done

Annotation

Implementation Notes