tools/testing/selftests/net/arp_ndisc_untracked_subnets.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/arp_ndisc_untracked_subnets.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/arp_ndisc_untracked_subnets.sh- Extension
.sh- Size
- 7214 bytes
- Lines
- 284
- 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
#
# 2 namespaces: one host and one router. Use arping from the host to send a
# garp to the router. Router accepts or ignores based on its arp_accept
# or accept_untracked_na configuration.
source lib.sh
TESTS="arp ndisc"
ROUTER_INTF="veth-router"
ROUTER_ADDR="10.0.10.1"
ROUTER_ADDR_V6="2001:db8:abcd:0012::1"
HOST_INTF="veth-host"
HOST_ADDR="10.0.10.2"
HOST_ADDR_V6="2001:db8:abcd:0012::2"
SUBNET_WIDTH=24
PREFIX_WIDTH_V6=64
cleanup() {
cleanup_ns ${HOST_NS} ${ROUTER_NS}
}
cleanup_v6() {
cleanup_ns ${HOST_NS_V6} ${ROUTER_NS_V6}
}
setup() {
set -e
local arp_accept=$1
# Set up two namespaces
setup_ns HOST_NS ROUTER_NS
# Set up interfaces veth0 and veth1, which are pairs in separate
# namespaces. veth0 is veth-router, veth1 is veth-host.
# first, set up the inteface's link to the namespace
# then, set the interface "up"
ip netns exec ${ROUTER_NS} ip link add name ${ROUTER_INTF} \
type veth peer name ${HOST_INTF}
ip netns exec ${ROUTER_NS} ip link set dev ${ROUTER_INTF} up
ip netns exec ${ROUTER_NS} ip link set dev ${HOST_INTF} netns ${HOST_NS}
ip netns exec ${HOST_NS} ip link set dev ${HOST_INTF} up
ip netns exec ${ROUTER_NS} ip addr add ${ROUTER_ADDR}/${SUBNET_WIDTH} \
dev ${ROUTER_INTF}
ip netns exec ${HOST_NS} ip addr add ${HOST_ADDR}/${SUBNET_WIDTH} \
dev ${HOST_INTF}
ip netns exec ${HOST_NS} ip route add default via ${HOST_ADDR} \
dev ${HOST_INTF}
ip netns exec ${ROUTER_NS} ip route add default via ${ROUTER_ADDR} \
dev ${ROUTER_INTF}
ROUTER_CONF=net.ipv4.conf.${ROUTER_INTF}
ip netns exec ${ROUTER_NS} sysctl -w \
${ROUTER_CONF}.arp_accept=${arp_accept} >/dev/null 2>&1
set +e
}
setup_v6() {
set -e
local accept_untracked_na=$1
# Set up two namespaces
setup_ns HOST_NS_V6 ROUTER_NS_V6
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.