tools/testing/selftests/net/tcp_ecmp_failover.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/tcp_ecmp_failover.sh
Extension
.sh
Size
5038 bytes
Lines
217
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
#
# Copyright 2026 Google LLC.
#
# This test verifies TCP flow failover between ECMP routes
# upon carrier loss on the active device.
#
#   socat  ----------------------------->  socat
#                        |
#           .-- veth-c1 -|- veth-s1 --.
#   dummy0 -|            |            |-- dummy0
#           '-- veth-c2 -|- veth-s2 --'
#                        |
#

REQUIRE_JQ=no
REQUIRE_MZ=no
NUM_NETIFS=0

source forwarding/lib.sh

CLIENT_IP="10.0.59.1"
SERVER_IP="10.0.92.1"
CLIENT_IP6="2001:db8:5a9a::1"
SERVER_IP6="2001:db8:9292::1"

setup_server()
{
	IP="ip -n $server"
	NS_EXEC="ip netns exec $server"

	$IP link add dummy0 type dummy
	$IP link set dummy0 up

	$IP -4 addr add $SERVER_IP/32 dev dummy0
	$IP -6 addr add $SERVER_IP6/128 dev dummy0 nodad

	$IP link set veth-s1 up
	$IP link set veth-s2 up

	$IP -4 addr add 192.168.1.2/24 dev veth-s1
	$IP -4 addr add 192.168.2.2/24 dev veth-s2

	$IP -4 route add $CLIENT_IP/32 \
		nexthop via 192.168.1.1 dev veth-s1 weight 1 \
		nexthop via 192.168.2.1 dev veth-s2 weight 1

	$IP -6 addr add 2001:db8:1::2/64 dev veth-s1 nodad
	$IP -6 addr add 2001:db8:2::2/64 dev veth-s2 nodad

	$IP -6 route add $CLIENT_IP6/128 \
		nexthop via 2001:db8:1::1 dev veth-s1 weight 1 \
		nexthop via 2001:db8:2::1 dev veth-s2 weight 1
}

setup_client()
{
	IP="ip -n $client"
	NS_EXEC="ip netns exec $client"

	$IP link add dummy0 type dummy
	$IP link set dummy0 up

	$IP -4 addr add $CLIENT_IP/32 dev dummy0
	$IP -6 addr add $CLIENT_IP6/128 dev dummy0 nodad

	$IP link set veth-c1 up
	$IP link set veth-c2 up

Annotation

Implementation Notes