tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh- Extension
.sh- Size
- 11515 bytes
- Lines
- 445
- 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 configure_ipfunction validate_resultfunction check_for_dependenciesfunction check_for_tasksetfunction pkill_socatfunction wait_for_port
Annotated Snippet
function configure_ip() {
# Configure the IPs for both interfaces
ip netns exec "${NAMESPACE}" ip addr add "${DSTIP}"/24 dev "${DSTIF}"
ip netns exec "${NAMESPACE}" ip link set "${DSTIF}" up
ip addr add "${SRCIP}"/24 dev "${SRCIF}"
ip link set "${SRCIF}" up
}
function select_ipv4_or_ipv6()
{
local VERSION=${1}
if [[ "$VERSION" == "ipv6" ]]
then
DSTIP="${DSTIP6}"
SRCIP="${SRCIP6}"
else
DSTIP="${DSTIP4}"
SRCIP="${SRCIP4}"
fi
}
function set_network() {
local IP_VERSION=${1:-"ipv4"}
# setup_ns function is coming from lib.sh
setup_ns NAMESPACE
# Create both interfaces, and assign the destination to a different
# namespace
create_ifaces
# Link both interfaces back to back
link_ifaces
select_ipv4_or_ipv6 "${IP_VERSION}"
configure_ip
}
function _create_dynamic_target() {
local FORMAT="${1:?FORMAT parameter required}"
local NCPATH="${2:?NCPATH parameter required}"
DSTMAC=$(ip netns exec "${NAMESPACE}" \
ip link show "${DSTIF}" | awk '/ether/ {print $2}')
# Create a dynamic target
mkdir "${NCPATH}"
echo "${DSTIP}" > "${NCPATH}"/remote_ip
echo "${SRCIP}" > "${NCPATH}"/local_ip
echo "${DSTMAC}" > "${NCPATH}"/remote_mac
echo "${SRCIF}" > "${NCPATH}"/dev_name
if [ "${FORMAT}" == "basic" ]
then
# Basic target does not support release
echo 0 > "${NCPATH}"/release
echo 0 > "${NCPATH}"/extended
elif [ "${FORMAT}" == "extended" ]
then
echo 1 > "${NCPATH}"/extended
fi
}
function create_dynamic_target() {
local FORMAT=${1:-"extended"}
local NCPATH=${2:-"$NETCONS_PATH"}
_create_dynamic_target "${FORMAT}" "${NCPATH}"
Annotation
- Detected declarations: `function configure_ip`, `function validate_result`, `function check_for_dependencies`, `function check_for_taskset`, `function pkill_socat`, `function wait_for_port`.
- 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.