tools/testing/selftests/net/route_localnet.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/route_localnet.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/route_localnet.sh- Extension
.sh- Size
- 1970 bytes
- Lines
- 77
- 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
#
# Run a couple of tests when route_localnet = 1.
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
setup() {
ip netns add "${PEER_NS}"
ip -netns "${PEER_NS}" link set dev lo up
ip link add name veth0 type veth peer name veth1
ip link set dev veth0 up
ip link set dev veth1 netns "${PEER_NS}"
# Enable route_localnet and delete useless route 127.0.0.0/8.
sysctl -w net.ipv4.conf.veth0.route_localnet=1
ip netns exec "${PEER_NS}" sysctl -w net.ipv4.conf.veth1.route_localnet=1
ip route del 127.0.0.0/8 dev lo table local
ip netns exec "${PEER_NS}" ip route del 127.0.0.0/8 dev lo table local
ip address add 127.25.3.4/24 dev veth0
ip link set dev veth0 up
ip netns exec "${PEER_NS}" ip address add 127.25.3.14/24 dev veth1
ip netns exec "${PEER_NS}" ip link set dev veth1 up
ip route flush cache
ip netns exec "${PEER_NS}" ip route flush cache
}
cleanup() {
ip link del veth0
ip route add local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local -r ns="$(ip netns list|grep $PEER_NS)"
[ -n "$ns" ] && ip netns del $ns 2>/dev/null
}
# Run test when arp_announce = 2.
run_arp_announce_test() {
echo "run arp_announce test"
setup
sysctl -w net.ipv4.conf.veth0.arp_announce=2
ip netns exec "${PEER_NS}" sysctl -w net.ipv4.conf.veth1.arp_announce=2
ping -c5 -I veth0 127.25.3.14
if [ $? -ne 0 ];then
echo "failed"
else
echo "ok"
fi
cleanup
}
# Run test when arp_ignore = 3.
run_arp_ignore_test() {
echo "run arp_ignore test"
setup
sysctl -w net.ipv4.conf.veth0.arp_ignore=3
ip netns exec "${PEER_NS}" sysctl -w net.ipv4.conf.veth1.arp_ignore=3
ping -c5 -I veth0 127.25.3.14
if [ $? -ne 0 ];then
echo "failed"
else
echo "ok"
fi
cleanup
}
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.