2 # SPDX-License-Identifier: GPL-2.0
4 # Test for DSCP prioritization and rewrite. Packets ingress $swp1 with a DSCP
5 # tag and are prioritized according to the map at $swp1. They egress $swp2 and
6 # the DSCP value is updated to match the map at that interface. The updated DSCP
7 # tag is verified at $h2.
9 # ICMP responses are produced with the same DSCP tag that arrived at $h2. They
10 # go through prioritization at $swp2 and DSCP retagging at $swp1. The tag is
11 # verified at $h1--it should match the original tag.
13 # +----------------------+ +----------------------+
16 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
17 # +----|-----------------+ +----------------|-----+
19 # +----|----------------------------------------------------------------|-----+
21 # | +-|----------------------------------------------------------------|-+ |
22 # | | + $swp1 BR $swp2 + | |
23 # | | APP=0,5,10 .. 7,5,17 APP=0,5,20 .. 7,5,27 | |
24 # | +--------------------------------------------------------------------+ |
25 # +---------------------------------------------------------------------------+
32 lib_dir=$(dirname $0)/../../../net/forwarding
35 source $lib_dir/lib.sh
39 simple_if_init $h1 192.0.2.1/28
40 tc qdisc add dev $h1 clsact
41 dscp_capture_install $h1 10
46 dscp_capture_uninstall $h1 10
47 tc qdisc del dev $h1 clsact
48 simple_if_fini $h1 192.0.2.1/28
53 simple_if_init $h2 192.0.2.2/28
54 tc qdisc add dev $h2 clsact
55 dscp_capture_install $h2 20
60 dscp_capture_uninstall $h2 20
61 tc qdisc del dev $h2 clsact
62 simple_if_fini $h2 192.0.2.2/28
70 for prio in {0..7}; do
71 echo app=$prio,5,$((base + prio))
77 ip link add name br1 type bridge vlan_filtering 1
78 ip link set dev br1 up
79 ip link set dev $swp1 master br1
80 ip link set dev $swp1 up
81 ip link set dev $swp2 master br1
82 ip link set dev $swp2 up
84 lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null
85 lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null
86 lldpad_app_wait_set $swp1
87 lldpad_app_wait_set $swp2
92 lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null
93 lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null
96 ip link set dev $swp2 nomaster
97 ip link set dev $swp1 nomaster
129 ping_test $h1 192.0.2.2
134 local vrf_name=$1; shift
138 local dev_10=$1; shift
139 local dev_20=$1; shift
142 local dscp_10=$(((prio + 10) << 2))
143 local dscp_20=$(((prio + 20) << 2))
148 eval "t0s=($(dscp_fetch_stats $dev_10 10)
149 $(dscp_fetch_stats $dev_20 20))"
151 local ping_timeout=$((PING_TIMEOUT * 5))
152 ip vrf exec $vrf_name \
153 ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \
154 -c 10 -i 0.5 -w $ping_timeout &> /dev/null
157 eval "t1s=($(dscp_fetch_stats $dev_10 10)
158 $(dscp_fetch_stats $dev_20 20))"
160 for key in ${!t0s[@]}; do
162 if ((key == prio+10 || key == prio+20)); then
168 local delta=$((t1s[$key] - t0s[$key]))
170 check_err $? "DSCP $key: Expected to capture $expect packets, got $delta."
173 log_test "DSCP rewrite: $dscp_10-(prio $prio)-$dscp_20"
180 for prio in {0..7}; do
181 dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2