tools/testing/selftests/net/netdevice.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/netdevice.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/netdevice.sh- Extension
.sh- Size
- 5829 bytes
- Lines
- 258
- 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/sh
# SPDX-License-Identifier: GPL-2.0
#
# This test is for checking network interface
# For the moment it tests only ethernet interface (but wifi could be easily added)
#
# We assume that all network driver are loaded
# if not they probably have failed earlier in the boot process and their logged error will be catched by another test
#
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
# this function will try to up the interface
# if already up, nothing done
# arg1: network interface name
kci_net_start()
{
netdev=$1
ip link show "$netdev" |grep -q UP
if [ $? -eq 0 ];then
echo "SKIP: $netdev: interface already up"
return $ksft_skip
fi
ip link set "$netdev" up
if [ $? -ne 0 ];then
echo "FAIL: $netdev: Fail to up interface"
return 1
else
echo "PASS: $netdev: set interface up"
NETDEV_STARTED=1
fi
return 0
}
# this function will try to setup an IP and MAC address on a network interface
# Doing nothing if the interface was already up
# arg1: network interface name
kci_net_setup()
{
netdev=$1
# do nothing if the interface was already up
if [ $NETDEV_STARTED -eq 0 ];then
return 0
fi
MACADDR='02:03:04:05:06:07'
ip link set dev $netdev address "$MACADDR"
if [ $? -ne 0 ];then
echo "FAIL: $netdev: Cannot set MAC address"
else
ip link show $netdev |grep -q "$MACADDR"
if [ $? -eq 0 ];then
echo "PASS: $netdev: set MAC address"
else
echo "FAIL: $netdev: Cannot set MAC address"
fi
fi
#check that the interface did not already have an IP
ip address show "$netdev" |grep '^[[:space:]]*inet'
if [ $? -eq 0 ];then
echo "SKIP: $netdev: already have an IP"
return $ksft_skip
fi
if [ "$veth_created" ]; then
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.