2 # SPDX-License-Identifier: GPL-2.0
4 # Test that policers shared by different tc filters are correctly reference
5 # counted by observing policers' occupancy via devlink-resource.
7 lib_dir
=$
(dirname $0)/..
/..
/..
/net
/forwarding
13 source $lib_dir/lib.sh
14 source $lib_dir/devlink_lib.sh
29 tc qdisc add dev
$swp1 clsact
34 tc qdisc del dev
$swp1 clsact
61 devlink_resource_occ_get global_policers single_rate_policers
68 local occ
=$
(tc_police_occ_get
)
70 tc filter add dev
$swp1 ingress pref
1 handle
101 proto ip \
72 action police rate
100mbit burst
100k conform-exceed drop
/ok
73 (( occ
+ 1 == $
(tc_police_occ_get
) ))
74 check_err $?
"Got occupancy $(tc_police_occ_get), expected $((occ + 1))"
76 tc filter del dev
$swp1 ingress pref
1 handle
101 flower
77 (( occ
== $
(tc_police_occ_get
) ))
78 check_err $?
"Got occupancy $(tc_police_occ_get), expected $occ"
80 tc filter add dev
$swp1 ingress pref
1 handle
101 proto ip \
82 action police rate
100mbit burst
100k conform-exceed drop
/ok \
84 tc filter add dev
$swp1 ingress pref
2 handle
102 proto ip \
85 flower skip_sw action police index
10
87 (( occ
+ 1 == $
(tc_police_occ_get
) ))
88 check_err $?
"Got occupancy $(tc_police_occ_get), expected $((occ + 1))"
90 tc filter del dev
$swp1 ingress pref
2 handle
102 flower
91 (( occ
+ 1 == $
(tc_police_occ_get
) ))
92 check_err $?
"Got occupancy $(tc_police_occ_get), expected $((occ + 1))"
94 tc filter del dev
$swp1 ingress pref
1 handle
101 flower
95 (( occ
== $
(tc_police_occ_get
) ))
96 check_err $?
"Got occupancy $(tc_police_occ_get), expected $occ"
98 log_test
"tc police occupancy"