@@ -11,6 +11,8 @@ ALL_TESTS="
1111 matchall_mirror_behind_flower_ingress_test
1212 matchall_sample_behind_flower_ingress_test
1313 matchall_mirror_behind_flower_egress_test
14+ police_limits_test
15+ multi_police_test
1416"
1517NUM_NETIFS=2
1618
@@ -287,6 +289,80 @@ matchall_mirror_behind_flower_egress_test()
287289 matchall_behind_flower_egress_test " mirror" " mirred egress mirror dev $swp2 "
288290}
289291
292+ police_limits_test ()
293+ {
294+ RET=0
295+
296+ tc qdisc add dev $swp1 clsact
297+
298+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
299+ flower skip_sw \
300+ action police rate 0.5kbit burst 1m conform-exceed drop/ok
301+ check_fail $? " Incorrect success to add police action with too low rate"
302+
303+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
304+ flower skip_sw \
305+ action police rate 2.5tbit burst 1g conform-exceed drop/ok
306+ check_fail $? " Incorrect success to add police action with too high rate"
307+
308+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
309+ flower skip_sw \
310+ action police rate 1.5kbit burst 1m conform-exceed drop/ok
311+ check_err $? " Failed to add police action with low rate"
312+
313+ tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
314+
315+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
316+ flower skip_sw \
317+ action police rate 1.9tbit burst 1g conform-exceed drop/ok
318+ check_err $? " Failed to add police action with high rate"
319+
320+ tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
321+
322+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
323+ flower skip_sw \
324+ action police rate 1.5kbit burst 512b conform-exceed drop/ok
325+ check_fail $? " Incorrect success to add police action with too low burst size"
326+
327+ tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
328+ flower skip_sw \
329+ action police rate 1.5kbit burst 2k conform-exceed drop/ok
330+ check_err $? " Failed to add police action with low burst size"
331+
332+ tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
333+
334+ tc qdisc del dev $swp1 clsact
335+
336+ log_test " police rate and burst limits"
337+ }
338+
339+ multi_police_test ()
340+ {
341+ RET=0
342+
343+ # It is forbidden in mlxsw driver to have multiple police
344+ # actions in a single rule.
345+
346+ tc qdisc add dev $swp1 clsact
347+
348+ tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \
349+ flower skip_sw \
350+ action police rate 100mbit burst 100k conform-exceed drop/ok
351+ check_err $? " Failed to add rule with single police action"
352+
353+ tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
354+
355+ tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \
356+ flower skip_sw \
357+ action police rate 100mbit burst 100k conform-exceed drop/pipe \
358+ action police rate 200mbit burst 200k conform-exceed drop/ok
359+ check_fail $? " Incorrect success to add rule with two police actions"
360+
361+ tc qdisc del dev $swp1 clsact
362+
363+ log_test " multi police"
364+ }
365+
290366setup_prepare ()
291367{
292368 swp1=${NETIFS[p1]}
0 commit comments