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
41 simple_if_init
$h1 192.0.2.1/28
42 tc qdisc add dev
$h1 clsact
43 dscp_capture_install
$h1 10
48 dscp_capture_uninstall
$h1 10
49 tc qdisc del dev
$h1 clsact
50 simple_if_fini
$h1 192.0.2.1/28
55 simple_if_init
$h2 192.0.2.2/28
56 tc qdisc add dev
$h2 clsact
57 dscp_capture_install
$h2 20
62 dscp_capture_uninstall
$h2 20
63 tc qdisc del dev
$h2 clsact
64 simple_if_fini
$h2 192.0.2.2/28
71 for prio
in {0.
.7}; do
72 echo app
=$prio,5,$
((base
+ prio
))
78 ip link add name br1
type bridge vlan_filtering
1
79 ip link
set dev br1 up
80 ip link
set dev
$swp1 master br1
81 ip link
set dev
$swp1 up
82 ip link
set dev
$swp2 master br1
83 ip link
set dev
$swp2 up
85 lldptool
-T -i $swp1 -V APP $
(dscp_map
10) >/dev
/null
86 lldptool
-T -i $swp2 -V APP $
(dscp_map
20) >/dev
/null
87 lldpad_app_wait_set
$swp1
88 lldpad_app_wait_set
$swp2
93 lldptool
-T -i $swp2 -V APP
-d $
(dscp_map
20) >/dev
/null
94 lldptool
-T -i $swp1 -V APP
-d $
(dscp_map
10) >/dev
/null
97 ip link
set dev
$swp2 nomaster
98 ip link
set dev
$swp1 nomaster
130 ping_test
$h1 192.0.2.2
135 local vrf_name
=$1; shift
139 local dev_10
=$1; shift
140 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"
178 for prio in {0..7}; do
179 dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2