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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh
Extension
.sh
Size
9891 bytes
Lines
354
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
#
# Test devlink-trap policer functionality over mlxsw.

# +---------------------------------+
# | H1 (vrf)                        |
# |    + $h1                        |
# |    | 192.0.2.1/24               |
# |    |                            |
# |    |  default via 192.0.2.2     |
# +----|----------------------------+
#      |
# +----|----------------------------------------------------------------------+
# | SW |                                                                      |
# |    + $rp1                                                                 |
# |        192.0.2.2/24                                                       |
# |                                                                           |
# |        198.51.100.2/24                                                    |
# |    + $rp2                                                                 |
# |    |                                                                      |
# +----|----------------------------------------------------------------------+
#      |
# +----|----------------------------+
# |    |  default via 198.51.100.2  |
# |    |                            |
# |    | 198.51.100.1/24            |
# |    + $h2                        |
# | H2 (vrf)                        |
# +---------------------------------+

lib_dir=$(dirname $0)/../../../net/forwarding

ALL_TESTS="
	rate_limits_test
	burst_limits_test
	rate_test
	burst_test
"
NUM_NETIFS=4
source $lib_dir/tc_common.sh
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh

h1_create()
{
	adf_simple_if_init $h1 192.0.2.1/24

	mtu_set $h1 10000
	defer mtu_restore $h1

	ip -4 route add default vrf v$h1 nexthop via 192.0.2.2
	defer ip -4 route del default vrf v$h1 nexthop via 192.0.2.2
}

h2_create()
{
	adf_simple_if_init $h2 198.51.100.1/24

	mtu_set $h2 10000
	defer mtu_restore $h2

	ip -4 route add default vrf v$h2 nexthop via 198.51.100.2
	defer ip -4 route del default vrf v$h2 nexthop via 198.51.100.2
}

router_create()
{
	ip link set dev $rp1 up
	defer ip link set dev $rp1 down

Annotation

Implementation Notes