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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh
Extension
.sh
Size
17793 bytes
Lines
659
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 that packets are sampled when tc-sample is used and that reported
# metadata is correct. Two sets of hosts (with and without LAG) are used, since
# metadata extraction in mlxsw is a bit different when LAG is involved.
#
# +---------------------------------+       +---------------------------------+
# | H1 (vrf)                        |       | H3 (vrf)                        |
# |    + $h1                        |       |    + $h3_lag                    |
# |    | 192.0.2.1/28               |       |    | 192.0.2.17/28              |
# |    |                            |       |    |                            |
# |    |  default via 192.0.2.2     |       |    |  default via 192.0.2.18    |
# +----|----------------------------+       +----|----------------------------+
#      |                                         |
# +----|-----------------------------------------|----------------------------+
# |    | 192.0.2.2/28                            | 192.0.2.18/28              |
# |    + $rp1                                    + $rp3_lag                   |
# |                                                                           |
# |    + $rp2                                    + $rp4_lag                   |
# |    | 198.51.100.2/28                         | 198.51.100.18/28           |
# +----|-----------------------------------------|----------------------------+
#      |                                         |
# +----|----------------------------+       +----|----------------------------+
# |    |  default via 198.51.100.2  |       |    |  default via 198.51.100.18 |
# |    |                            |       |    |                            |
# |    | 198.51.100.1/28            |       |    | 198.51.100.17/28           |
# |    + $h2                        |       |    + $h4_lag                    |
# | H2 (vrf)                        |       | H4 (vrf)                        |
# +---------------------------------+       +---------------------------------+

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

ALL_TESTS="
	tc_sample_rate_test
	tc_sample_max_rate_test
	tc_sample_conflict_test
	tc_sample_group_conflict_test
	tc_sample_md_iif_test
	tc_sample_md_lag_iif_test
	tc_sample_md_oif_test
	tc_sample_md_lag_oif_test
	tc_sample_md_out_tc_test
	tc_sample_md_out_tc_occ_test
	tc_sample_md_latency_test
	tc_sample_acl_group_conflict_test
	tc_sample_acl_rate_test
	tc_sample_acl_max_rate_test
"
NUM_NETIFS=8
CAPTURE_FILE=$(mktemp)
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source mlxsw_lib.sh

# Available at https://github.com/Mellanox/libpsample
require_command psample

h1_create()
{
	simple_if_init $h1 192.0.2.1/28

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

h1_destroy()
{
	ip -4 route del default vrf v$h1 nexthop via 192.0.2.2

	simple_if_fini $h1 192.0.2.1/28

Annotation

Implementation Notes