tools/testing/selftests/drivers/net/bonding/bond_lacp_strict.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/bonding/bond_lacp_strict.sh
Extension
.sh
Size
11029 bytes
Lines
348
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

if (ctx == "actor") {
				gsub(":", "", iface)
				printf "%s_%s_state=%s\n", iface, ctx, $3
			}
		}
		' /proc/net/bonding/bond0
	)

	if [ "$interface" == "eth0" ] || [ "$interface" == "both" ]; then
		compare_state "$eth0_actor_state" "$expected" eth0 "$last_attempt" || ret=1
	fi

	if [ "$interface" == "eth1" ] || [ "$interface" == "both" ]; then
		compare_state "$eth1_actor_state" "$expected" eth1 "$last_attempt" || ret=1
	fi

	return $ret
}

test_lacp_port_state() {
	local interface=$1
	local expected=$2
	local retry=$3
	local last_attempt=0
	local attempt=1
	local ret=1

	while [ $attempt -le $((retry + 1)) ]; do
		[ $attempt -eq $((retry + 1)) ] && last_attempt=1
		_test_lacp_port_state "$interface" "$expected" "$last_attempt" && return
		((attempt++))
		sleep 1
	done

	RET=1
}


trap cleanup_all_ns EXIT
setup_ns d_ns p_ns br_ns
setup_links

# Initial state
RET=0
mode=off
test_lacp_port_state both $COLLECTING_DISTRIBUTING 3
test_master_carrier up $mode
log_test "bond LACP" "lacp_strict $mode - eth0 and eth1 up"

# partner eth0 down, eth1 up
# (replicate eth0 state to dut eth0 by shutting a bridge port)
RET=0
ip -n "${p_ns}" link set eth0 down
ip -n "${br_ns}" link set eth2 down
test_lacp_port_state eth0 $FAILED 5
test_lacp_port_state eth1 $COLLECTING_DISTRIBUTING 1
test_master_carrier up $mode
log_test "bond LACP" "lacp_strict $mode - eth0 down"

# partner eth0 and eth1 down
RET=0
ip -n "${p_ns}" link set eth1 down
ip -n "${br_ns}" link set eth3 down
test_lacp_port_state both $FAILED 5
test_master_carrier down $mode # down because of min_links
log_test "bond LACP" "lacp_strict $mode - eth0 and eth1 down"

# partner eth0 up, eth1 down
RET=0
ip -n "${p_ns}" link set eth0 up

Annotation

Implementation Notes