/usr/src/linux-headers-5.15.0-190/tools/testing/selftests/drivers/net/mlxsw
NameSizeModeActions
spectrum/-0755rm
spectrum-2/-0755rm
blackhole_routes.sh50750755editdlrm
devlink_trap.sh19280755editdlrm
devlink_trap_acl_drops.sh24580755editdlrm
devlink_trap_control.sh183990755editdlrm
devlink_trap_l2_drops.sh99660755editdlrm
devlink_trap_l3_drops.sh168120755editdlrm
devlink_trap_l3_exceptions.sh140980755editdlrm
devlink_trap_policer.sh94410755editdlrm
devlink_trap_tunnel_ipip.sh60350755editdlrm
devlink_trap_tunnel_vxlan.sh89890755editdlrm
ethtool_lanes.sh40260755editdlrm
extack.sh34710755editdlrm
fib.sh55620755editdlrm
fib_offload.sh101640755editdlrm
mirror_gre.sh44470755editdlrm
mirror_gre_scale.sh57820644editdlrm
mlxsw_lib.sh3620644editdlrm
one_armed_router.sh69500755editdlrm
port_scale.sh13910644editdlrm
qos_defprio.sh27380755editdlrm
qos_dscp_bridge.sh43250755editdlrm
qos_dscp_router.sh67640755editdlrm
qos_ets_strict.sh88100755editdlrm
qos_headroom.sh83670755editdlrm
qos_lib.sh19180644editdlrm
qos_mc_aware.sh94120755editdlrm
qos_pfc.sh117000755editdlrm
q_in_q_veto.sh79480755editdlrm
router_scale.sh21380644editdlrm
rtnetlink.sh306040755editdlrm
sch_ets.sh23320755editdlrm
sch_red_core.sh180140644editdlrm
sch_red_ets.sh24760755editdlrm
sch_red_prio.sh810755editdlrm
sch_red_root.sh10810755editdlrm
sch_tbf_ets.sh1750755editdlrm
sch_tbf_prio.sh1760755editdlrm
sch_tbf_root.sh1760755editdlrm
sharedbuffer.sh39120755editdlrm
tc_action_hw_stats.sh22930755editdlrm
tc_flower_scale.sh24600644editdlrm
tc_police_occ.sh21200755editdlrm
tc_police_scale.sh16600644editdlrm
tc_restrictions.sh118470755editdlrm
tc_sample.sh178910755editdlrm
vxlan.sh299960755editdlrm
vxlan_fdb_veto.sh29550755editdlrm
vxlan_flooding.sh88490755editdlrm
Edit: /usr/src/linux-headers-5.15.0-190/tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh (11847B)
#!/bin/bash # SPDX-License-Identifier: GPL-2.0 lib_dir=$(dirname $0)/../../../net/forwarding ALL_TESTS=" shared_block_drop_test egress_redirect_test multi_mirror_test matchall_sample_egress_test matchall_mirror_behind_flower_ingress_test matchall_sample_behind_flower_ingress_test matchall_mirror_behind_flower_egress_test matchall_proto_match_test police_limits_test multi_police_test " NUM_NETIFS=2 source $lib_dir/tc_common.sh source $lib_dir/lib.sh source $lib_dir/devlink_lib.sh switch_create() { simple_if_init $swp1 192.0.2.1/24 simple_if_init $swp2 192.0.2.2/24 } switch_destroy() { simple_if_fini $swp2 192.0.2.2/24 simple_if_fini $swp1 192.0.2.1/24 } shared_block_drop_test() { RET=0 # It is forbidden in mlxsw driver to have mixed-bound # shared block with a drop rule. tc qdisc add dev $swp1 ingress_block 22 clsact check_err $? "Failed to create clsact with ingress block" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_err $? "Failed to add drop rule to ingress bound block" tc qdisc add dev $swp2 ingress_block 22 clsact check_err $? "Failed to create another clsact with ingress shared block" tc qdisc del dev $swp2 clsact tc qdisc add dev $swp2 egress_block 22 clsact check_fail $? "Incorrect success to create another clsact with egress shared block" tc filter del block 22 protocol ip pref 1 handle 101 flower tc qdisc add dev $swp2 egress_block 22 clsact check_err $? "Failed to create another clsact with egress shared block after blocker drop rule removed" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_fail $? "Incorrect success to add drop rule to mixed bound block" tc qdisc del dev $swp1 clsact tc qdisc add dev $swp1 egress_block 22 clsact check_err $? "Failed to create another clsact with egress shared block" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_err $? "Failed to add drop rule to egress bound shared block" tc filter del block 22 protocol ip pref 1 handle 101 flower tc qdisc del dev $swp2 clsact tc qdisc del dev $swp1 clsact log_test "shared block drop" } egress_redirect_test() { RET=0 # It is forbidden in mlxsw driver to have mirred redirect on # egress-bound block. tc qdisc add dev $swp1 ingress_block 22 clsact check_err $? "Failed to create clsact with ingress block" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress redirect dev $swp2 check_err $? "Failed to add redirect rule to ingress bound block" tc qdisc add dev $swp2 ingress_block 22 clsact check_err $? "Failed to create another clsact with ingress shared block" tc qdisc del dev $swp2 clsact tc qdisc add dev $swp2 egress_block 22 clsact check_fail $? "Incorrect success to create another clsact with egress shared block" tc filter del block 22 protocol ip pref 1 handle 101 flower tc qdisc add dev $swp2 egress_block 22 clsact check_err $? "Failed to create another clsact with egress shared block after blocker redirect rule removed" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress redirect dev $swp2 check_fail $? "Incorrect success to add redirect rule to mixed bound block" tc qdisc del dev $swp1 clsact tc qdisc add dev $swp1 egress_block 22 clsact check_err $? "Failed to create another clsact with egress shared block" tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress redirect dev $swp2 check_fail $? "Incorrect success to add redirect rule to egress bound shared block" tc qdisc del dev $swp2 clsact tc filter add block 22 protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress redirect dev $swp2 check_fail $? "Incorrect success to add redirect rule to egress bound block" tc qdisc del dev $swp1 clsact log_test "shared block drop" } multi_mirror_test() { RET=0 # It is forbidden in mlxsw driver to have multiple mirror # actions in a single rule. tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress mirror dev $swp2 check_err $? "Failed to add rule with single mirror action" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 flower \ skip_sw dst_ip 192.0.2.2 \ action mirred egress mirror dev $swp2 \ action mirred egress mirror dev $swp1 check_fail $? "Incorrect success to add rule with two mirror actions" tc qdisc del dev $swp1 clsact log_test "multi mirror" } matchall_sample_egress_test() { RET=0 # It is forbidden in mlxsw driver to have matchall with sample action # bound on egress. Spectrum-1 specific restriction [[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress protocol all pref 1 handle 101 \ matchall skip_sw action sample rate 100 group 1 check_err $? "Failed to add rule with sample action on ingress" tc filter del dev $swp1 ingress protocol all pref 1 handle 101 matchall tc filter add dev $swp1 egress protocol all pref 1 handle 101 \ matchall skip_sw action sample rate 100 group 1 check_fail $? "Incorrect success to add rule with sample action on egress" tc qdisc del dev $swp1 clsact log_test "matchall sample egress" } matchall_behind_flower_ingress_test() { local action=$1 local action_args=$2 RET=0 # On ingress, all matchall-mirror and matchall-sample # rules have to be in front of the flower rules tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress protocol ip pref 10 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop tc filter add dev $swp1 ingress protocol all pref 9 handle 102 \ matchall skip_sw action $action_args check_err $? "Failed to add matchall rule in front of a flower rule" tc filter del dev $swp1 ingress protocol all pref 9 handle 102 matchall tc filter add dev $swp1 ingress protocol all pref 11 handle 102 \ matchall skip_sw action $action_args check_fail $? "Incorrect success to add matchall rule behind a flower rule" tc filter del dev $swp1 ingress protocol ip pref 10 handle 101 flower tc filter add dev $swp1 ingress protocol all pref 9 handle 102 \ matchall skip_sw action $action_args tc filter add dev $swp1 ingress protocol ip pref 10 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_err $? "Failed to add flower rule behind a matchall rule" tc filter del dev $swp1 ingress protocol ip pref 10 handle 101 flower tc filter add dev $swp1 ingress protocol ip pref 8 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_fail $? "Incorrect success to add flower rule in front of a matchall rule" tc qdisc del dev $swp1 clsact log_test "matchall $action flower ingress" } matchall_mirror_behind_flower_ingress_test() { matchall_behind_flower_ingress_test "mirror" "mirred egress mirror dev $swp2" } matchall_sample_behind_flower_ingress_test() { matchall_behind_flower_ingress_test "sample" "sample rate 100 group 1" } matchall_behind_flower_egress_test() { local action=$1 local action_args=$2 RET=0 # On egress, all matchall-mirror rules have to be behind the flower rules tc qdisc add dev $swp1 clsact tc filter add dev $swp1 egress protocol ip pref 10 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop tc filter add dev $swp1 egress protocol all pref 11 handle 102 \ matchall skip_sw action $action_args check_err $? "Failed to add matchall rule in front of a flower rule" tc filter del dev $swp1 egress protocol all pref 11 handle 102 matchall tc filter add dev $swp1 egress protocol all pref 9 handle 102 \ matchall skip_sw action $action_args check_fail $? "Incorrect success to add matchall rule behind a flower rule" tc filter del dev $swp1 egress protocol ip pref 10 handle 101 flower tc filter add dev $swp1 egress protocol all pref 11 handle 102 \ matchall skip_sw action $action_args tc filter add dev $swp1 egress protocol ip pref 10 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_err $? "Failed to add flower rule behind a matchall rule" tc filter del dev $swp1 egress protocol ip pref 10 handle 101 flower tc filter add dev $swp1 egress protocol ip pref 12 handle 101 flower \ skip_sw dst_ip 192.0.2.2 action drop check_fail $? "Incorrect success to add flower rule in front of a matchall rule" tc qdisc del dev $swp1 clsact log_test "matchall $action flower egress" } matchall_mirror_behind_flower_egress_test() { matchall_behind_flower_egress_test "mirror" "mirred egress mirror dev $swp2" } matchall_proto_match_test() { RET=0 tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ matchall skip_sw \ action sample group 1 rate 100 check_fail $? "Incorrect success to add matchall rule with protocol match" tc qdisc del dev $swp1 clsact log_test "matchall protocol match" } police_limits_test() { RET=0 tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 0.5kbit burst 2k conform-exceed drop/ok check_fail $? "Incorrect success to add police action with too low rate" tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 2.5tbit burst 1g conform-exceed drop/ok check_fail $? "Incorrect success to add police action with too high rate" tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 1.5kbit burst 2k conform-exceed drop/ok check_err $? "Failed to add police action with low rate" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 1.9tbit burst 1g conform-exceed drop/ok check_err $? "Failed to add police action with high rate" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 1.5kbit burst 512b conform-exceed drop/ok check_fail $? "Incorrect success to add police action with too low burst size" tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ action police rate 1.5kbit burst 2k conform-exceed drop/ok check_err $? "Failed to add police action with low burst size" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower tc qdisc del dev $swp1 clsact log_test "police rate and burst limits" } multi_police_test() { RET=0 # It is forbidden in mlxsw driver to have multiple police # actions in a single rule. tc qdisc add dev $swp1 clsact tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \ flower skip_sw \ action police rate 100mbit burst 100k conform-exceed drop/ok check_err $? "Failed to add rule with single police action" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \ flower skip_sw \ action police rate 100mbit burst 100k conform-exceed drop/pipe \ action police rate 200mbit burst 200k conform-exceed drop/ok check_fail $? "Incorrect success to add rule with two police actions" tc qdisc del dev $swp1 clsact log_test "multi police" } setup_prepare() { swp1=${NETIFS[p1]} swp2=${NETIFS[p2]} vrf_prepare switch_create } cleanup() { pre_cleanup switch_destroy vrf_cleanup } check_tc_shblock_support trap cleanup EXIT setup_prepare setup_wait tests_run exit $EXIT_STATUS