tools/testing/selftests/drivers/net/team/team_lib.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/team/team_lib.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/team/team_lib.sh- Extension
.sh- Size
- 4530 bytes
- Lines
- 175
- 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
test_dir="$(dirname "$0")"
export REQUIRE_MZ=no
export NUM_NETIFS=0
# shellcheck disable=SC1091
source "${test_dir}/../../../net/forwarding/lib.sh"
TCP_PORT="43434"
# Create a team interface inside of a given network namespace with a given
# mode, members, and IP address.
# Arguments:
# namespace - Network namespace to put the team interface into.
# team - The name of the team interface to setup.
# mode - The team mode of the interface.
# ip_address - The IP address to assign to the team interface.
# prefix_length - The prefix length for the IP address subnet.
# $@ - members - The member interfaces of the aggregation.
setup_team()
{
local namespace=$1
local team=$2
local mode=$3
local ip_address=$4
local prefix_length=$5
shift 5
local members=("$@")
# Prerequisite: team must have no members
for member in "${members[@]}"; do
ip -n "${namespace}" link set "${member}" nomaster
done
# Prerequisite: team must have no address in order to set it
# shellcheck disable=SC2086
ip -n "${namespace}" addr del "${ip_address}/${prefix_length}" \
${NODAD} dev "${team}"
echo "Setting team in ${namespace} to mode ${mode}"
if ! ip -n "${namespace}" link set "${team}" down; then
echo "Failed to bring team device down"
return 1
fi
if ! ip netns exec "${namespace}" teamnl "${team}" setoption mode \
"${mode}"; then
echo "Failed to set ${team} mode to '${mode}'"
return 1
fi
# Aggregate the members into teams.
for member in "${members[@]}"; do
ip -n "${namespace}" link set "${member}" master "${team}"
done
# Bring team devices up and give them addresses.
if ! ip -n "${namespace}" link set "${team}" up; then
echo "Failed to set ${team} up"
return 1
fi
# shellcheck disable=SC2086
if ! ip -n "${namespace}" addr add "${ip_address}/${prefix_length}" \
${NODAD} dev "${team}"; then
echo "Failed to give ${team} IP address in ${namespace}"
return 1
fi
}
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.