tools/testing/selftests/drivers/net/netconsole/netcons_resume.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/netconsole/netcons_resume.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/netconsole/netcons_resume.sh- Extension
.sh- Size
- 3754 bytes
- Lines
- 125
- 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
function cleanupfunction trigger_deactivation
Annotated Snippet
function cleanup() {
cleanup_netcons "${NETCONS_CONFIGFS}/cmdline0"
do_cleanup
rmmod netconsole
}
function trigger_reactivation() {
# Add back low level module
modprobe netdevsim
# Recreate namespace and two interfaces
set_network
# Restore MACs
ip netns exec "${NAMESPACE}" ip link set "${DSTIF}" \
address "${SAVED_DSTMAC}"
if [ "${BINDMODE}" == "mac" ]; then
ip link set dev "${SRCIF}" down
ip link set dev "${SRCIF}" address "${SAVED_SRCMAC}"
# Rename device in order to trigger target resume, as initial
# when device was recreated it didn't have correct mac address.
ip link set dev "${SRCIF}" name "${TARGET}"
fi
}
function trigger_deactivation() {
# Start by storing mac addresses so we can be restored in reactivate
SAVED_DSTMAC=$(ip netns exec "${NAMESPACE}" \
cat /sys/class/net/"$DSTIF"/address)
SAVED_SRCMAC=$(mac_get "${SRCIF}")
# Remove low level module
rmmod netdevsim
}
trap cleanup EXIT
# Run the test twice, with different cmdline parameters
for BINDMODE in "ifname" "mac"
do
echo "Running with bind mode: ${BINDMODE}" >&2
# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5)
echo "6 5" > /proc/sys/kernel/printk
# Create one namespace and two interfaces
set_network
# Create the command line for netconsole, with the configuration from
# the function above
CMDLINE=$(create_cmdline_str "${BINDMODE}")
# The content of kmsg will be save to the following file
OUTPUT_FILE="/tmp/${TARGET}-${BINDMODE}"
# Load the module, with the cmdline set
modprobe netconsole "${CMDLINE}"
# Expose cmdline target in configfs
mkdir "${NETCONS_CONFIGFS}/cmdline0"
# Target should be enabled
wait_target_state "cmdline0" "enabled"
# Trigger deactivation by unloading netdevsim module. Target should be
# disabled.
trigger_deactivation
wait_target_state "cmdline0" "disabled"
# Trigger reactivation by loading netdevsim, recreating the network and
# restoring mac addresses. Target should be re-enabled.
trigger_reactivation
wait_target_state "cmdline0" "enabled"
# Listen for netconsole port inside the namespace and destination
Annotation
- Detected declarations: `function cleanup`, `function trigger_deactivation`.
- 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.