__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
#!/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
source mlxsw_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
	mlxsw_only_on_spectrum 1 || 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 1m 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 1m 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

Filemanager

Name Type Size Permission Actions
spectrum Folder 0755
spectrum-2 Folder 0755
blackhole_routes.sh File 4.96 KB 0755
devlink_linecard.sh File 7.5 KB 0755
devlink_trap.sh File 1.86 KB 0755
devlink_trap_acl_drops.sh File 2.4 KB 0755
devlink_trap_control.sh File 18.22 KB 0755
devlink_trap_l2_drops.sh File 12.87 KB 0755
devlink_trap_l3_drops.sh File 16.38 KB 0755
devlink_trap_l3_exceptions.sh File 13.64 KB 0755
devlink_trap_policer.sh File 9.75 KB 0755
devlink_trap_tunnel_ipip.sh File 5.24 KB 0755
devlink_trap_tunnel_ipip6.sh File 5.31 KB 0755
devlink_trap_tunnel_vxlan.sh File 8.84 KB 0755
devlink_trap_tunnel_vxlan_ipv6.sh File 9.32 KB 0755
egress_vid_classification.sh File 6.55 KB 0755
ethtool_lanes.sh File 4.02 KB 0755
extack.sh File 3.74 KB 0755
fib.sh File 5.43 KB 0755
fib_offload.sh File 9.93 KB 0755
hw_stats_l3.sh File 410 B 0755
ingress_rif_conf_1d.sh File 6.15 KB 0755
ingress_rif_conf_1q.sh File 6.23 KB 0755
ingress_rif_conf_vxlan.sh File 8.44 KB 0755
mirror_gre.sh File 3.78 KB 0755
mirror_gre_scale.sh File 5.43 KB 0644
mlxsw_lib.sh File 1.43 KB 0644
one_armed_router.sh File 6.82 KB 0755
pci_reset.sh File 1.27 KB 0755
port_range_occ.sh File 2.33 KB 0755
port_range_scale.sh File 1.51 KB 0644
port_scale.sh File 1.36 KB 0644
q_in_q_veto.sh File 8.06 KB 0755
qos_defprio.sh File 2.33 KB 0755
qos_dscp_bridge.sh File 4.14 KB 0755
qos_dscp_router.sh File 6.43 KB 0755
qos_ets_strict.sh File 9.09 KB 0755
qos_headroom.sh File 8.19 KB 0755
qos_lib.sh File 1.27 KB 0644
qos_max_descriptors.sh File 6.14 KB 0755
qos_mc_aware.sh File 9.54 KB 0755
qos_pfc.sh File 11.36 KB 0755
rif_bridge.sh File 4.12 KB 0755
rif_counter_scale.sh File 1.71 KB 0644
rif_lag.sh File 2.98 KB 0755
rif_lag_vlan.sh File 3.24 KB 0755
rif_mac_profile_scale.sh File 1.64 KB 0644
rif_mac_profiles.sh File 4.65 KB 0755
rif_mac_profiles_occ.sh File 2.87 KB 0755
router_bridge_lag.sh File 786 B 0755
router_scale.sh File 2.09 KB 0644
rtnetlink.sh File 26.93 KB 0755
sch_ets.sh File 2.3 KB 0755
sch_offload.sh File 5.25 KB 0755
sch_red_core.sh File 20.75 KB 0644
sch_red_ets.sh File 3.12 KB 0755
sch_red_prio.sh File 81 B 0755
sch_red_root.sh File 1.25 KB 0755
sch_tbf_ets.sh File 216 B 0755
sch_tbf_prio.sh File 217 B 0755
sch_tbf_root.sh File 217 B 0755
sharedbuffer.sh File 5.24 KB 0755
tc_action_hw_stats.sh File 2.24 KB 0755
tc_flower_scale.sh File 2.81 KB 0644
tc_police_occ.sh File 2.07 KB 0755
tc_police_scale.sh File 1.62 KB 0644
tc_restrictions.sh File 11.58 KB 0755
tc_sample.sh File 17.38 KB 0755
vxlan.sh File 30.19 KB 0755
vxlan_fdb_veto.sh File 3.11 KB 0755
vxlan_fdb_veto_ipv6.sh File 250 B 0755
vxlan_flooding.sh File 8.64 KB 0755
vxlan_ipv6.sh File 1.39 KB 0755
Filemanager