tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh
Extension
.sh
Size
5941 bytes
Lines
302
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

# ShellCheck incorrectly believes that most of the code here is unreachable
# because it's invoked by variable name following ALL_TESTS.
#
# shellcheck disable=SC2317

ALL_TESTS="check_accounting check_limit"
NUM_NETIFS=6
source lib.sh

TEST_MAC_BASE=de:ad:be:ef:42:

NUM_PKTS=16
FDB_LIMIT=8

FDB_TYPES=(
	# name		is counted?	overrides learned?
	'learned	1		0'
	'static		0		1'
	'user		0		1'
	'extern_learn	0		1'
	'local		0		1'
)

mac()
{
	printf "${TEST_MAC_BASE}%02x" "$1"
}

H1_DEFAULT_MAC=$(mac 42)

switch_create()
{
	ip link add dev br0 type bridge

	ip link set dev "$swp1" master br0
	ip link set dev "$swp2" master br0
	# swp3 is used to add local MACs, so do not add it to the bridge yet.

	# swp2 is only used for replying when learning on swp1, its MAC should not be learned.
	ip link set dev "$swp2" type bridge_slave learning off

	ip link set dev br0 up

	ip link set dev "$swp1" up
	ip link set dev "$swp2" up
	ip link set dev "$swp3" up
}

switch_destroy()
{
	ip link set dev "$swp3" down
	ip link set dev "$swp2" down
	ip link set dev "$swp1" down

	ip link del dev br0
}

h_create()
{
	ip link set "$h1" addr "$H1_DEFAULT_MAC"

	simple_if_init "$h1" 192.0.2.1/24
	simple_if_init "$h2" 192.0.2.2/24
}

h_destroy()
{

Annotation

Implementation Notes