HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //lib/modules/6.8.0-1036-gcp/build/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Test bond device handling of addr lists (dev->uc, mc)
#

ALL_TESTS="
	bond_cleanup_mode1
	bond_cleanup_mode4
	bond_listen_lacpdu_multicast_case_down
	bond_listen_lacpdu_multicast_case_up
"

REQUIRE_MZ=no
NUM_NETIFS=0
lib_dir=$(dirname "$0")
source "$lib_dir"/net_forwarding_lib.sh

source "$lib_dir"/lag_lib.sh


destroy()
{
	local ifnames=(dummy1 dummy2 bond1 mv0)
	local ifname

	for ifname in "${ifnames[@]}"; do
		ip link del "$ifname" &>/dev/null
	done
}

cleanup()
{
	pre_cleanup

	destroy
}


# bond driver control paths vary between modes that have a primary slave
# (bond_uses_primary()) and others. Test both kinds of modes.

bond_cleanup_mode1()
{
	RET=0

	test_LAG_cleanup "bonding" "active-backup"
}

bond_cleanup_mode4() {
	RET=0

	test_LAG_cleanup "bonding" "802.3ad"
}

bond_listen_lacpdu_multicast()
{
	# Initial state of bond device, up | down
	local init_state=$1
	local lacpdu_mc="01:80:c2:00:00:02"

	ip link add dummy1 type dummy
	ip link add bond1 "$init_state" type bond mode 802.3ad
	ip link set dev dummy1 master bond1
	if [ "$init_state" = "down" ]; then
		ip link set dev bond1 up
	fi

	grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address not present on slave (1)"

	ip link set dev bond1 down

	not grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address still present on slave"

	ip link set dev bond1 up

	grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address not present on slave (2)"

	cleanup

	log_test "bonding LACPDU multicast address to slave (from bond $init_state)"
}

# The LACPDU mc addr is added by different paths depending on the initial state
# of the bond when enslaving a device. Test both cases.

bond_listen_lacpdu_multicast_case_down()
{
	RET=0

	bond_listen_lacpdu_multicast "down"
}

bond_listen_lacpdu_multicast_case_up()
{
	RET=0

	bond_listen_lacpdu_multicast "up"
}


trap cleanup EXIT

tests_run

exit "$EXIT_STATUS"