__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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

# Test for DSCP prioritization in the router.
#
# With ip_forward_update_priority disabled, the packets are expected to keep
# their DSCP (which in this test uses only values 0..7) intact as they are
# forwarded by the switch. That is verified at $h2. ICMP responses are formed
# with the same DSCP as the requests, and likewise pass through the switch
# intact, which is verified at $h1.
#
# With ip_forward_update_priority enabled, router reprioritizes the packets
# according to the table in reprioritize(). Thus, say, DSCP 7 maps to priority
# 4, which on egress maps back to DSCP 4. The response packet then gets
# reprioritized to 6, getting DSCP 6 on egress.
#
# +----------------------+                             +----------------------+
# | H1                   |                             |                   H2 |
# |    + $h1             |                             |            $h2 +     |
# |    | 192.0.2.1/28    |                             |  192.0.2.18/28 |     |
# +----|-----------------+                             +----------------|-----+
#      |                                                                |
# +----|----------------------------------------------------------------|-----+
# | SW |                                                                |     |
# |    + $swp1                                                    $swp2 +     |
# |      192.0.2.2/28                                     192.0.2.17/28       |
# |      APP=0,5,0 .. 7,5,7                          APP=0,5,0 .. 7,5,7       |
# +---------------------------------------------------------------------------+

ALL_TESTS="
	ping_ipv4
	test_update
	test_no_update
	test_pedit_norewrite
	test_dscp_leftover
"

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

NUM_NETIFS=4
source $lib_dir/lib.sh

reprioritize()
{
	local in=$1; shift

	# This is based on rt_tos2priority in include/net/route.h. Assuming 1:1
	# mapping between priorities and TOS, it yields a new priority for a
	# packet with ingress priority of $in.
	local -a reprio=(0 0 2 2 6 6 4 4)

	echo ${reprio[$in]}
}

zero()
{
    echo 0
}

three()
{
    echo 3
}

h1_create()
{
	simple_if_init $h1 192.0.2.1/28
	tc qdisc add dev $h1 clsact
	dscp_capture_install $h1 0
	ip route add vrf v$h1 192.0.2.16/28 via 192.0.2.2
}

h1_destroy()
{
	ip route del vrf v$h1 192.0.2.16/28 via 192.0.2.2
	dscp_capture_uninstall $h1 0
	tc qdisc del dev $h1 clsact
	simple_if_fini $h1 192.0.2.1/28
}

h2_create()
{
	simple_if_init $h2 192.0.2.18/28
	tc qdisc add dev $h2 clsact
	dscp_capture_install $h2 0
	ip route add vrf v$h2 192.0.2.0/28 via 192.0.2.17
}

h2_destroy()
{
	ip route del vrf v$h2 192.0.2.0/28 via 192.0.2.17
	dscp_capture_uninstall $h2 0
	tc qdisc del dev $h2 clsact
	simple_if_fini $h2 192.0.2.18/28
}

switch_create()
{
	simple_if_init $swp1 192.0.2.2/28
	__simple_if_init $swp2 v$swp1 192.0.2.17/28

	tc qdisc add dev $swp1 clsact
	tc qdisc add dev $swp2 clsact

	dcb app add dev $swp1 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
	dcb app add dev $swp2 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
}

switch_destroy()
{
	dcb app del dev $swp2 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
	dcb app del dev $swp1 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7

	tc qdisc del dev $swp2 clsact
	tc qdisc del dev $swp1 clsact

	__simple_if_fini $swp2 192.0.2.17/28
	simple_if_fini $swp1 192.0.2.2/28
}

setup_prepare()
{
	h1=${NETIFS[p1]}
	swp1=${NETIFS[p2]}

	swp2=${NETIFS[p3]}
	h2=${NETIFS[p4]}

	vrf_prepare

	sysctl_set net.ipv4.ip_forward_update_priority 1
	h1_create
	h2_create
	switch_create
}

cleanup()
{
	pre_cleanup

	switch_destroy
	h2_destroy
	h1_destroy
	sysctl_restore net.ipv4.ip_forward_update_priority

	vrf_cleanup
}

ping_ipv4()
{
	ping_test $h1 192.0.2.18
}

dscp_ping_test()
{
	local vrf_name=$1; shift
	local sip=$1; shift
	local dip=$1; shift
	local prio=$1; shift
	local reprio=$1; shift
	local dev1=$1; shift
	local dev2=$1; shift
	local i

	local prio2=$($reprio $prio)   # ICMP Request egress prio
	local prio3=$($reprio $prio2)  # ICMP Response egress prio

	local dscp=$((prio << 2))     # ICMP Request ingress DSCP
	local dscp2=$((prio2 << 2))   # ICMP Request egress DSCP
	local dscp3=$((prio3 << 2))   # ICMP Response egress DSCP

	RET=0

	eval "local -A dev1_t0s=($(dscp_fetch_stats $dev1 0))"
	eval "local -A dev2_t0s=($(dscp_fetch_stats $dev2 0))"

	local ping_timeout=$((PING_TIMEOUT * 5))
	ip vrf exec $vrf_name \
	   ${PING} -Q $dscp ${sip:+-I $sip} $dip \
		   -c 10 -i 0.5 -w $ping_timeout &> /dev/null

	eval "local -A dev1_t1s=($(dscp_fetch_stats $dev1 0))"
	eval "local -A dev2_t1s=($(dscp_fetch_stats $dev2 0))"

	for i in {0..7}; do
		local dscpi=$((i << 2))
		local expect2=0
		local expect3=0

		if ((i == prio2)); then
			expect2=10
		fi
		if ((i == prio3)); then
			expect3=10
		fi

		local delta=$((dev2_t1s[$i] - dev2_t0s[$i]))
		((expect2 == delta))
		check_err $? "DSCP $dscpi@$dev2: Expected to capture $expect2 packets, got $delta."

		delta=$((dev1_t1s[$i] - dev1_t0s[$i]))
		((expect3 == delta))
		check_err $? "DSCP $dscpi@$dev1: Expected to capture $expect3 packets, got $delta."
	done

	log_test "DSCP rewrite: $dscp-(prio $prio2)-$dscp2-(prio $prio3)-$dscp3"
}

__test_update()
{
	local update=$1; shift
	local reprio=$1; shift
	local prio

	sysctl_restore net.ipv4.ip_forward_update_priority
	sysctl_set net.ipv4.ip_forward_update_priority $update

	for prio in {0..7}; do
		dscp_ping_test v$h1 192.0.2.1 192.0.2.18 $prio $reprio $h1 $h2
	done
}

test_update()
{
	echo "Test net.ipv4.ip_forward_update_priority=1"
	__test_update 1 reprioritize
}

test_no_update()
{
	echo "Test net.ipv4.ip_forward_update_priority=0"
	__test_update 0 echo
}

# Test that when DSCP is updated in pedit, the DSCP rewrite is turned off.
test_pedit_norewrite()
{
	echo "Test no DSCP rewrite after DSCP is updated by pedit"

	tc filter add dev $swp1 ingress handle 101 pref 1 prot ip flower \
	    action pedit ex munge ip dsfield set $((3 << 2)) retain 0xfc \
	    action skbedit priority 3

	__test_update 0 three

	tc filter del dev $swp1 ingress pref 1
}

# Test that when the last APP rule is removed, the prio->DSCP map is properly
# set to zeroes, and that the last APP rule does not stay active in the ASIC.
test_dscp_leftover()
{
	echo "Test that last removed DSCP rule is deconfigured correctly"

	dcb app del dev $swp2 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7

	__test_update 0 zero

	dcb app add dev $swp2 dscp-prio 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
}

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