tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh
Extension
.sh
Size
2938 bytes
Lines
148
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

lib_dir=$(dirname $0)/../../../net/forwarding

ALL_TESTS="
	rif_mac_profile_edit_test
"
NUM_NETIFS=2
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh

setup_prepare()
{
	h1=${NETIFS[p1]}
	h2=${NETIFS[p2]}

	# Disable IPv6 on the two interfaces to avoid IPv6 link-local addresses
	# being generated and RIFs being created
	sysctl_set net.ipv6.conf.$h1.disable_ipv6 1
	sysctl_set net.ipv6.conf.$h2.disable_ipv6 1

	ip link set $h1 up
	ip link set $h2 up
}

cleanup()
{
	pre_cleanup

	ip link set $h2 down
	ip link set $h1 down

	sysctl_restore net.ipv6.conf.$h2.disable_ipv6
	sysctl_restore net.ipv6.conf.$h1.disable_ipv6

	# Reload in order to clean all the RIFs and RIF MAC profiles created
	devlink_reload
}

create_max_rif_mac_profiles()
{
	local count=$1; shift
	local batch_file="$(mktemp)"

	for ((i = 1; i <= count; i++)); do
		vlan=$(( i*10 ))
		m=$(( i*11 ))

		cat >> $batch_file <<-EOF
			link add link $h1 name $h1.$vlan \
				address 00:$m:$m:$m:$m:$m type vlan id $vlan
			address add 192.0.$m.1/24 dev $h1.$vlan
		EOF
	done

	ip -b $batch_file &> /dev/null
	rm -f $batch_file
}

rif_mac_profile_replacement_test()
{
	local h1_10_mac=$(mac_get $h1.10)

	RET=0

	ip link set $h1.10 address 00:12:34:56:78:99
	check_err $?

	log_test "RIF MAC profile replacement"

Annotation

Implementation Notes