tools/testing/selftests/net/bridge_stp_mode.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/bridge_stp_mode.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/bridge_stp_mode.sh- Extension
.sh- Size
- 7799 bytes
- Lines
- 289
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# shellcheck disable=SC2034,SC2154,SC2317,SC2329
#
# Test for bridge STP mode selection (IFLA_BR_STP_MODE).
#
# Verifies that:
# - stp_mode defaults to auto on new bridges
# - stp_mode can be toggled between user, kernel, and auto
# - stp_mode change is rejected while STP is active (-EBUSY)
# - stp_mode user in a netns yields userspace STP (stp_state=2)
# - stp_mode kernel forces kernel STP (stp_state=1)
# - stp_mode auto preserves traditional fallback to kernel STP
# - stp_mode and stp_state can be set atomically in one message
# - stp_mode persists across STP disable/enable cycles
source lib.sh
require_command jq
ALL_TESTS="
test_default_auto
test_set_modes
test_reject_change_while_stp_active
test_idempotent_mode_while_stp_active
test_user_mode_in_netns
test_kernel_mode
test_auto_mode
test_atomic_mode_and_state
test_mode_persistence
"
bridge_info_get()
{
ip -n "$NS1" -d -j link show "$1" | \
jq -r ".[0].linkinfo.info_data.$2"
}
check_stp_mode()
{
local br=$1; shift
local expected=$1; shift
local msg=$1; shift
local val
val=$(bridge_info_get "$br" stp_mode)
[ "$val" = "$expected" ]
check_err $? "$msg: expected $expected, got $val"
}
check_stp_state()
{
local br=$1; shift
local expected=$1; shift
local msg=$1; shift
local val
val=$(bridge_info_get "$br" stp_state)
[ "$val" = "$expected" ]
check_err $? "$msg: expected $expected, got $val"
}
# Create a bridge in NS1, bring it up, and defer its deletion.
bridge_create()
{
ip -n "$NS1" link add "$1" type bridge
ip -n "$NS1" link set "$1" up
defer ip -n "$NS1" link del "$1"
}
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.