tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh
Extension
.sh
Size
3914 bytes
Lines
162
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.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Topology for Bond mode 1,5,6 testing
#
#  +-------------------------+
#  |          bond0          |  Server
#  |            +            |  192.0.2.1/24
#  |      eth0  |  eth1      |  2001:db8::1/24
#  |        +---+---+        |
#  |        |       |        |
#  +-------------------------+
#           |       |
#  +-------------------------+
#  |        |       |        |
#  |    +---+-------+---+    |  Gateway
#  |    |      br0      |    |  192.0.2.254/24
#  |    +-------+-------+    |  2001:db8::254/24
#  |            |            |
#  +-------------------------+
#               |
#  +-------------------------+
#  |            |            |  Client
#  |            +            |  192.0.2.10/24
#  |          eth0           |  2001:db8::10/24
#  +-------------------------+

REQUIRE_MZ=no
NUM_NETIFS=0
lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh

s_ns="s-$(mktemp -u XXXXXX)"
c_ns="c-$(mktemp -u XXXXXX)"
g_ns="g-$(mktemp -u XXXXXX)"
s_ip4="192.0.2.1"
c_ip4="192.0.2.10"
g_ip4="192.0.2.254"
s_ip6="2001:db8::1"
c_ip6="2001:db8::10"
g_ip6="2001:db8::254"
mac[0]="00:0a:0b:0c:0d:01"
mac[1]="00:0a:0b:0c:0d:02"

gateway_create()
{
	ip netns add ${g_ns}
	ip -n ${g_ns} link add br0 type bridge
	ip -n ${g_ns} link set br0 up
	ip -n ${g_ns} addr add ${g_ip4}/24 dev br0
	ip -n ${g_ns} addr add ${g_ip6}/24 dev br0
}

gateway_destroy()
{
	ip -n ${g_ns} link del br0
	ip netns del ${g_ns}
}

server_create()
{
	ip netns add ${s_ns}
	ip -n ${s_ns} link add bond0 type bond mode active-backup miimon 100

	for i in $(seq 0 1); do
		ip -n ${s_ns} link add eth${i} type veth peer name s${i} netns ${g_ns}
		ip -n "${s_ns}" link set "eth${i}" addr "${mac[$i]}"

		ip -n ${g_ns} link set s${i} up
		ip -n ${g_ns} link set s${i} master br0

Annotation

Implementation Notes