tools/testing/selftests/net/netfilter/ipvs.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/netfilter/ipvs.sh
Extension
.sh
Size
5947 bytes
Lines
206
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
#
# End-to-end ipvs test suite
# Topology:
#--------------------------------------------------------------+
#                      |                                       |
#         ns0          |         ns1                           |
#      -----------     |     -----------    -----------        |
#      | veth01  | --------- | veth10  |    | veth12  |        |
#      -----------    peer   -----------    -----------        |
#           |          |                        |              |
#      -----------     |                        |              |
#      |  br0    |     |-----------------  peer |--------------|
#      -----------     |                        |              |
#           |          |                        |              |
#      ----------     peer   ----------      -----------       |
#      |  veth02 | --------- |  veth20 |     | veth21  |       |
#      ----------      |     ----------      -----------       |
#                      |         ns2                           |
#                      |                                       |
#--------------------------------------------------------------+
#
# We assume that all network driver are loaded
#

source lib.sh

ret=0
GREEN='\033[0;92m'
RED='\033[0;31m'
NC='\033[0m' # No Color

readonly port=8080

readonly vip_v4=207.175.44.110
readonly cip_v4=10.0.0.2
readonly gip_v4=10.0.0.1
readonly dip_v4=172.16.0.1
readonly rip_v4=172.16.0.2
readonly sip_v4=10.0.0.3

readonly infile="$(mktemp)"
readonly outfile="$(mktemp)"
readonly datalen=32

sysipvsnet="/proc/sys/net/ipv4/vs/"
if [ ! -d $sysipvsnet ]; then
	if ! modprobe -q ip_vs; then
		echo "skip: could not run test without ipvs module"
		exit $ksft_skip
	fi
fi

checktool "ipvsadm -v" "run test without ipvsadm"
checktool "socat -h" "run test without socat"

setup() {
	setup_ns ns0 ns1 ns2

	ip link add veth01 netns "${ns0}" type veth peer name veth10 netns "${ns1}"
	ip link add veth02 netns "${ns0}" type veth peer name veth20 netns "${ns2}"
	ip link add veth12 netns "${ns1}" type veth peer name veth21 netns "${ns2}"

	ip netns exec "${ns0}" ip link set veth01 up
	ip netns exec "${ns0}" ip link set veth02 up
	ip netns exec "${ns0}" ip link add br0 type bridge
	ip netns exec "${ns0}" ip link set veth01 master br0
	ip netns exec "${ns0}" ip link set veth02 master br0
	ip netns exec "${ns0}" ip link set br0 up

Annotation

Implementation Notes