tools/testing/selftests/drivers/net/mlxsw/mirror_gre_scale.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/mirror_gre_scale.sh
Extension
.sh
Size
5563 bytes
Lines
186
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

# SPDX-License-Identifier: GPL-2.0

# Test offloading a number of mirrors-to-gretap. The test creates a number of
# tunnels. Then it adds one flower mirror for each of the tunnels, matching a
# given host IP. Then it generates traffic at each of the host IPs and checks
# that the traffic has been mirrored at the appropriate tunnel.
#
#   +--------------------------+                   +--------------------------+
#   | H1                       |                   |                       H2 |
#   |     + $h1                |                   |                $h2 +     |
#   |     | 2001:db8:1:X::1/64 |                   | 2001:db8:1:X::2/64 |     |
#   +-----|--------------------+                   +--------------------|-----+
#         |                                                             |
#   +-----|-------------------------------------------------------------|-----+
#   | SW  o--> mirrors                                                  |     |
#   | +---|-------------------------------------------------------------|---+ |
#   | |   + $swp1                    BR                           $swp2 +   | |
#   | +---------------------------------------------------------------------+ |
#   |                                                                         |
#   |     + $swp3                          + gt6-<X> (ip6gretap)              |
#   |     | 2001:db8:2:X::1/64             : loc=2001:db8:2:X::1              |
#   |     |                                : rem=2001:db8:2:X::2              |
#   |     |                                : ttl=100                          |
#   |     |                                : tos=inherit                      |
#   |     |                                :                                  |
#   +-----|--------------------------------:----------------------------------+
#         |                                :
#   +-----|--------------------------------:----------------------------------+
#   | H3  + $h3                            + h3-gt6-<X> (ip6gretap)           |
#   |       2001:db8:2:X::2/64               loc=2001:db8:2:X::2              |
#   |                                        rem=2001:db8:2:X::1              |
#   |                                        ttl=100                          |
#   |                                        tos=inherit                      |
#   |                                                                         |
#   +-------------------------------------------------------------------------+

source ../../../../net/forwarding/mirror_lib.sh

MIRROR_NUM_NETIFS=6

mirror_gre_ipv6_addr()
{
	local net=$1; shift
	local num=$1; shift

	printf "2001:db8:%x:%x" $net $num
}

mirror_gre_tunnels_create()
{
	local count=$1; shift
	local should_fail=$1; shift

	MIRROR_GRE_BATCH_FILE="$(mktemp)"
	for ((i=0; i < count; ++i)); do
		local match_dip=$(mirror_gre_ipv6_addr 1 $i)::2
		local htun=h3-gt6-$i
		local tun=gt6-$i

		((mirror_gre_tunnels++))

		ip address add dev $h1 $(mirror_gre_ipv6_addr 1 $i)::1/64
		ip address add dev $h2 $(mirror_gre_ipv6_addr 1 $i)::2/64

		ip address add dev $swp3 $(mirror_gre_ipv6_addr 2 $i)::1/64
		ip address add dev $h3 $(mirror_gre_ipv6_addr 2 $i)::2/64

		tunnel_create $tun ip6gretap \
			      $(mirror_gre_ipv6_addr 2 $i)::1 \
			      $(mirror_gre_ipv6_addr 2 $i)::2 \

Annotation

Implementation Notes