tools/testing/selftests/net/protodown.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/protodown.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/protodown.sh- Extension
.sh- Size
- 4775 bytes
- Lines
- 183
- 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.
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
#
# Test the protodown mechanism. Verify basic protodown toggling, protodown
# reasons, operational state when the lower device carrier changes, and correct
# operational state when the lower device has no carrier.
# shellcheck disable=SC1091,SC2034,SC2154,SC2317
source lib.sh
require_command jq
ALL_TESTS="
protodown_basic_macvlan
protodown_basic_vxlan
protodown_reasons
protodown_lower_toggle
protodown_lower_down
"
operstate_get()
{
local ns=$1; shift
local dev=$1; shift
ip -n "$ns" -j link show dev "$dev" | jq -r '.[].operstate'
}
operstate_check()
{
local ns=$1; shift
local dev=$1; shift
local expected=$1; shift
local current
current=$(operstate_get "$ns" "$dev")
[ "$current" = "$expected" ]
}
setup_prepare()
{
setup_ns NS
defer cleanup_all_ns
ip -n "$NS" link add name dummy0 up type dummy
ip -n "$NS" link add name macvlan0 link dummy0 up type macvlan mode bridge
ip -n "$NS" link add name vxlan0 up type vxlan id 10010 dstport 4789
}
protodown_basic()
{
local dev=$1; shift
ip -n "$NS" link set dev "$dev" protodown on
check_err $? "Failed to set protodown on"
busywait "$BUSYWAIT_TIMEOUT" operstate_check "$NS" "$dev" DOWN
check_err $? "Operational state is not DOWN after setting protodown"
ip -n "$NS" link set dev "$dev" protodown off
check_err $? "Failed to set protodown off"
busywait "$BUSYWAIT_TIMEOUT" operstate_check "$NS" "$dev" UP
check_err $? "Operational state is not UP after clearing protodown"
}
protodown_basic_macvlan()
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
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.