Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 ALL_TESTS="
0005         ping_ipv4
0006         ecn_test
0007         ecn_test_perband
0008         ecn_nodrop_test
0009         red_test
0010         mc_backlog_test
0011         red_mirror_test
0012         red_trap_test
0013         ecn_mirror_test
0014 "
0015 : ${QDISC:=ets}
0016 source sch_red_core.sh
0017 
0018 # do_ecn_test first build 2/3 of the requested backlog and expects no marking,
0019 # and then builds 3/2 of it and does expect marking. The values of $BACKLOG1 and
0020 # $BACKLOG2 are far enough not to overlap, so that we can assume that if we do
0021 # see (do not see) marking, it is actually due to the configuration of that one
0022 # TC, and not due to configuration of the other TC leaking over.
0023 BACKLOG1=200000
0024 BACKLOG2=500000
0025 
0026 install_root_qdisc()
0027 {
0028         tc qdisc add dev $swp3 root handle 10: $QDISC \
0029            bands 8 priomap 7 6 5 4 3 2 1 0
0030 }
0031 
0032 install_qdisc_tc0()
0033 {
0034         local -a args=("$@")
0035 
0036         tc qdisc add dev $swp3 parent 10:8 handle 108: red \
0037            limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \
0038            probability 1.0 avpkt 8000 burst 38 "${args[@]}"
0039 }
0040 
0041 install_qdisc_tc1()
0042 {
0043         local -a args=("$@")
0044 
0045         tc qdisc add dev $swp3 parent 10:7 handle 107: red \
0046            limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \
0047            probability 1.0 avpkt 8000 burst 63 "${args[@]}"
0048 }
0049 
0050 install_qdisc()
0051 {
0052         install_root_qdisc
0053         install_qdisc_tc0 "$@"
0054         install_qdisc_tc1 "$@"
0055         sleep 1
0056 }
0057 
0058 uninstall_qdisc_tc0()
0059 {
0060         tc qdisc del dev $swp3 parent 10:8
0061 }
0062 
0063 uninstall_qdisc_tc1()
0064 {
0065         tc qdisc del dev $swp3 parent 10:7
0066 }
0067 
0068 uninstall_root_qdisc()
0069 {
0070         tc qdisc del dev $swp3 root
0071 }
0072 
0073 uninstall_qdisc()
0074 {
0075         uninstall_qdisc_tc0
0076         uninstall_qdisc_tc1
0077         uninstall_root_qdisc
0078 }
0079 
0080 ecn_test()
0081 {
0082         install_qdisc ecn
0083 
0084         do_ecn_test 10 $BACKLOG1
0085         do_ecn_test 11 $BACKLOG2
0086 
0087         uninstall_qdisc
0088 }
0089 
0090 ecn_test_perband()
0091 {
0092         install_qdisc ecn
0093 
0094         do_ecn_test_perband 10 $BACKLOG1
0095         do_ecn_test_perband 11 $BACKLOG2
0096 
0097         uninstall_qdisc
0098 }
0099 
0100 ecn_nodrop_test()
0101 {
0102         install_qdisc ecn nodrop
0103 
0104         do_ecn_nodrop_test 10 $BACKLOG1
0105         do_ecn_nodrop_test 11 $BACKLOG2
0106 
0107         uninstall_qdisc
0108 }
0109 
0110 red_test()
0111 {
0112         install_qdisc
0113 
0114         # Make sure that we get the non-zero value if there is any.
0115         local cur=$(busywait 1100 until_counter_is "> 0" \
0116                             qdisc_stats_get $swp3 10: .backlog)
0117         (( cur == 0 ))
0118         check_err $? "backlog of $cur observed on non-busy qdisc"
0119         log_test "$QDISC backlog properly cleaned"
0120 
0121         do_red_test 10 $BACKLOG1
0122         do_red_test 11 $BACKLOG2
0123 
0124         uninstall_qdisc
0125 }
0126 
0127 mc_backlog_test()
0128 {
0129         install_qdisc
0130 
0131         # Note that the backlog numbers here do not correspond to RED
0132         # configuration, but are arbitrary.
0133         do_mc_backlog_test 10 $BACKLOG1
0134         do_mc_backlog_test 11 $BACKLOG2
0135 
0136         uninstall_qdisc
0137 }
0138 
0139 red_mirror_test()
0140 {
0141         install_qdisc qevent early_drop block 10
0142 
0143         do_drop_mirror_test 10 $BACKLOG1 early_drop
0144         do_drop_mirror_test 11 $BACKLOG2 early_drop
0145 
0146         uninstall_qdisc
0147 }
0148 
0149 red_trap_test()
0150 {
0151         install_qdisc qevent early_drop block 10
0152 
0153         do_drop_trap_test 10 $BACKLOG1 early_drop
0154         do_drop_trap_test 11 $BACKLOG2 early_drop
0155 
0156         uninstall_qdisc
0157 }
0158 
0159 ecn_mirror_test()
0160 {
0161         install_qdisc ecn qevent mark block 10
0162 
0163         do_mark_mirror_test 10 $BACKLOG1
0164         do_mark_mirror_test 11 $BACKLOG2
0165 
0166         uninstall_qdisc
0167 }
0168 
0169 bail_on_lldpad
0170 
0171 trap cleanup EXIT
0172 setup_prepare
0173 setup_wait
0174 tests_run
0175 
0176 exit $EXIT_STATUS