tools/testing/selftests/net/forwarding/router_nh.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/forwarding/router_nh.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/forwarding/router_nh.sh
Extension
.sh
Size
3389 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.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# +-------------------------+  +-------------------------+
# | H1                      |  |                      H2 |
# |               $h1 +     |  |               $h2 +     |
# |      192.0.2.2/24 |     |  |   198.51.100.2/24 |     |
# |  2001:db8:1::2/64 |     |  |  2001:db8:2::2/64 |     |
# +-------------------|-----+  +-------------------|-----+
#                     |                            |
# +-------------------|----------------------------|-----+
# | R1                |                            |     |
# |              $rp1 +                       $rp2 +     |
# |      192.0.2.1/24              198.51.100.1/24       |
# |  2001:db8:1::1/64             2001:db8:2::1/64       |
# +------------------------------------------------------+

ALL_TESTS="
	ping_ipv4
	ping_ipv6
"

NUM_NETIFS=4
source lib.sh
source tc_common.sh

h1_create()
{
	vrf_create "vrf-h1"
	ip link set dev $h1 master vrf-h1

	ip link set dev vrf-h1 up
	ip link set dev $h1 up

	ip address add 192.0.2.2/24 dev $h1
	ip address add 2001:db8:1::2/64 dev $h1

	ip route add 198.51.100.0/24 vrf vrf-h1 nexthop via 192.0.2.1
	ip route add 2001:db8:2::/64 vrf vrf-h1 nexthop via 2001:db8:1::1
}

h1_destroy()
{
	ip route del 2001:db8:2::/64 vrf vrf-h1
	ip route del 198.51.100.0/24 vrf vrf-h1

	ip address del 2001:db8:1::2/64 dev $h1
	ip address del 192.0.2.2/24 dev $h1

	ip link set dev $h1 down
	vrf_destroy "vrf-h1"
}

h2_create()
{
	vrf_create "vrf-h2"
	ip link set dev $h2 master vrf-h2

	ip link set dev vrf-h2 up
	ip link set dev $h2 up

	ip address add 198.51.100.2/24 dev $h2
	ip address add 2001:db8:2::2/64 dev $h2

	ip route add 192.0.2.0/24 vrf vrf-h2 nexthop via 198.51.100.1
	ip route add 2001:db8:1::/64 vrf vrf-h2 nexthop via 2001:db8:2::1
}

h2_destroy()
{

Annotation

Implementation Notes