1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4ALL_TESTS="
5	ping_ipv4
6	ecn_test
7	ecn_nodrop_test
8	red_test
9	mc_backlog_test
10	red_mirror_test
11"
12source sch_red_core.sh
13
14BACKLOG=300000
15
16install_qdisc()
17{
18	local -a args=("$@")
19
20	tc qdisc add dev $swp3 root handle 108: red \
21	   limit 1000000 min $BACKLOG max $((BACKLOG + 1)) \
22	   probability 1.0 avpkt 8000 burst 38 "${args[@]}"
23	sleep 1
24}
25
26uninstall_qdisc()
27{
28	tc qdisc del dev $swp3 root
29}
30
31ecn_test()
32{
33	install_qdisc ecn
34	do_ecn_test 10 $BACKLOG
35	uninstall_qdisc
36}
37
38ecn_nodrop_test()
39{
40	install_qdisc ecn nodrop
41	do_ecn_nodrop_test 10 $BACKLOG
42	uninstall_qdisc
43}
44
45red_test()
46{
47	install_qdisc
48	do_red_test 10 $BACKLOG
49	uninstall_qdisc
50}
51
52mc_backlog_test()
53{
54	install_qdisc
55	# Note that the backlog value here does not correspond to RED
56	# configuration, but is arbitrary.
57	do_mc_backlog_test 10 $BACKLOG
58	uninstall_qdisc
59}
60
61red_mirror_test()
62{
63	install_qdisc qevent early_drop block 10
64	do_drop_mirror_test 10 $BACKLOG
65	uninstall_qdisc
66}
67
68trap cleanup EXIT
69
70setup_prepare
71setup_wait
72
73bail_on_lldpad
74tests_run
75
76exit $EXIT_STATUS
77