2 # SPDX-License-Identifier: GPL-2.0
4 # This test sends traffic from H1 to H2. Either on ingress of $swp1, or on
5 # egress of $swp2, the traffic is acted upon by an action skbedit priority. The
6 # new priority should be taken into account when classifying traffic on the PRIO
7 # qdisc at $swp2. The test verifies that for different priority values, the
8 # traffic ends up in expected PRIO band.
10 # +----------------------+ +----------------------+
13 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
14 # +----|-----------------+ +----------------|-----+
16 # +----|----------------------------------------------------------------|-----+
18 # | +-|----------------------------------------------------------------|-+ |
19 # | | + $swp1 BR $swp2 + | |
21 # | +--------------------------------------------------------------------+ |
22 # +---------------------------------------------------------------------------+
33 : ${HIT_TIMEOUT:=2000} # ms
37 simple_if_init
$h1 192.0.2.1/28
42 simple_if_fini
$h1 192.0.2.1/28
47 simple_if_init
$h2 192.0.2.2/28
52 simple_if_fini
$h2 192.0.2.2/28
57 ip link add name br1
type bridge vlan_filtering
1
58 ip link
set dev br1 addrgenmode none
59 ip link
set dev br1 up
60 ip link
set dev
$swp1 master br1
61 ip link
set dev
$swp1 up
62 ip link
set dev
$swp2 master br1
63 ip link
set dev
$swp2 up
65 tc qdisc add dev
$swp1 clsact
66 tc qdisc add dev
$swp2 clsact
67 tc qdisc add dev
$swp2 root handle
10: \
68 prio bands
8 priomap
7 6 5 4 3 2 1 0
73 tc qdisc del dev
$swp2 root
74 tc qdisc del dev
$swp2 clsact
75 tc qdisc del dev
$swp1 clsact
77 ip link
set dev
$swp2 down
78 ip link
set dev
$swp2 nomaster
79 ip link
set dev
$swp1 down
80 ip link
set dev
$swp1 nomaster
112 ping_test
$h1 192.0.2.2
115 test_skbedit_priority_one
()
117 local locus
=$1; shift
119 local classid
=$1; shift
123 tc filter add
$locus handle
101 pref
1 \
124 flower action skbedit priority
$prio
126 local pkt0
=$
(qdisc_parent_stats_get
$swp2 $classid .packets
)
127 local pkt2
=$
(tc_rule_handle_stats_get
"$locus" 101)
128 $MZ $h1 -t udp
"sp=54321,dp=12345" -c 10 -d 20msec
-p 100 \
129 -a own
-b $h2mac -A 192.0.2.1 -B 192.0.2.2 -q
132 pkt1
=$
(busywait
"$HIT_TIMEOUT" until_counter_is
">= $((pkt0 + 10))" \
133 qdisc_parent_stats_get
$swp2 $classid .packets
)
134 check_err $?
"Expected to get 10 packets on class $classid, but got $((pkt1 - pkt0))."
136 local pkt3
=$
(tc_rule_handle_stats_get
"$locus" 101)
137 ((pkt3
>= pkt2
+ 10))
138 check_err $?
"Expected to get 10 packets on skbedit rule but got $((pkt3 - pkt2))."
140 log_test
"$locus skbedit priority $prio -> classid $classid"
142 tc filter del
$locus pref
1
149 for prio
in {0.
.7}; do
150 test_skbedit_priority_one
"dev $swp1 ingress" \
151 $prio 10:$
((8 - prio
))
159 for prio
in {0.
.7}; do
160 test_skbedit_priority_one
"dev $swp2 egress" \
161 $prio 10:$
((8 - prio
))