tools/testing/selftests/net/netns-name.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/netns-name.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/netns-name.sh- Extension
.sh- Size
- 2952 bytes
- Lines
- 103
- 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 fail
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
source lib.sh
set -o pipefail
DEV=dummy-dev0
DEV2=dummy-dev1
ALT_NAME=some-alt-name
NSIM_ADDR=2025
RET_CODE=0
cleanup() {
cleanup_netdevsim $NSIM_ADDR
cleanup_ns $NS $test_ns
}
trap cleanup EXIT
fail() {
echo "ERROR: ${1:-unexpected return code} (ret: $_)" >&2
RET_CODE=1
}
setup_ns NS test_ns
#
# Test basic move without a rename
# Use netdevsim because it has extra asserts for notifiers.
#
nsim=$(create_netdevsim $NSIM_ADDR $NS)
ip -netns $NS link set dev $nsim netns $test_ns ||
fail "Can't perform a netns move"
ip -netns $test_ns link show dev $nsim >> /dev/null ||
fail "Device not found after move"
cleanup_netdevsim $NSIM_ADDR
#
# Test move with a conflict
#
ip -netns $test_ns link add name $DEV type dummy
ip -netns $NS link add name $DEV type dummy || fail
ip -netns $NS link set dev $DEV netns $test_ns 2> /dev/null &&
fail "Performed a netns move with a name conflict"
ip -netns $test_ns link show dev $DEV >> /dev/null || fail "Device not found after move"
ip -netns $NS link del $DEV || fail
ip -netns $test_ns link del $DEV || fail
#
# Test move with a conflict and rename
#
ip -netns $test_ns link add name $DEV type dummy
ip -netns $NS link add name $DEV type dummy || fail
ip -netns $NS link set dev $DEV netns $test_ns name $DEV2 ||
fail "Can't perform a netns move with rename"
ip -netns $test_ns link del $DEV2 || fail
ip -netns $test_ns link del $DEV || fail
#
# Test dup alt-name with netns move
#
ip -netns $test_ns link add name $DEV type dummy || fail
ip -netns $test_ns link property add dev $DEV altname $ALT_NAME || fail
ip -netns $NS link add name $DEV2 type dummy || fail
ip -netns $NS link property add dev $DEV2 altname $ALT_NAME || fail
ip -netns $NS link set dev $DEV2 netns $test_ns 2> /dev/null &&
fail "Moved with alt-name dup"
Annotation
- Detected declarations: `function fail`.
- 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.