tools/testing/selftests/drivers/net/netdevsim/devlink_trap.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/netdevsim/devlink_trap.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/netdevsim/devlink_trap.sh- Extension
.sh- Size
- 12923 bytes
- Lines
- 515
- 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 check_netdev_down
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# This test is for checking devlink-trap functionality. It makes use of
# netdevsim which implements the required callbacks.
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
init_test
trap_action_test
trap_metadata_test
bad_trap_test
bad_trap_action_test
trap_stats_test
trap_group_action_test
bad_trap_group_test
trap_group_stats_test
trap_policer_test
trap_policer_bind_test
port_del_test
dev_del_test
"
NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR}
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV/
SLEEP_TIME=1
NETDEV=""
NUM_NETIFS=0
source $lib_dir/lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
require_command udevadm
modprobe netdevsim &> /dev/null
if [ ! -d "$NETDEVSIM_PATH" ]; then
echo "SKIP: No netdevsim support"
exit 1
fi
if [ -d "${NETDEVSIM_PATH}/devices/netdevsim${DEV_ADDR}" ]; then
echo "SKIP: Device netdevsim${DEV_ADDR} already exists"
exit 1
fi
check_netdev_down()
{
state=$(cat /sys/class/net/${NETDEV}/flags)
if [ $((state & 1)) -ne 0 ]; then
echo "WARNING: unexpected interface UP, disable NetworkManager?"
ip link set dev $NETDEV down
fi
}
init_test()
{
RET=0
test $(devlink_traps_num_get) -ne 0
check_err $? "No traps were registered"
log_test "Initialization"
}
Annotation
- Detected declarations: `function check_netdev_down`.
- 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.