177 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4ALL_TESTS="5 ping_ipv46 ecn_test7 ecn_test_perband8 ecn_nodrop_test9 red_test10 mc_backlog_test11 red_mirror_test12 red_trap_test13 ecn_mirror_test14"15: ${QDISC:=ets}16source sch_red_core.sh17 18# do_ecn_test first build 2/3 of the requested backlog and expects no marking,19# and then builds 3/2 of it and does expect marking. The values of $BACKLOG1 and20# $BACKLOG2 are far enough not to overlap, so that we can assume that if we do21# see (do not see) marking, it is actually due to the configuration of that one22# TC, and not due to configuration of the other TC leaking over.23BACKLOG1=20000024BACKLOG2=50000025 26install_root_qdisc()27{28 tc qdisc add dev $swp3 parent 1: handle 10: $QDISC \29 bands 8 priomap 7 6 5 4 3 2 1 030}31 32install_qdisc_tc0()33{34 local -a args=("$@")35 36 tc qdisc add dev $swp3 parent 10:8 handle 108: red \37 limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \38 probability 1.0 avpkt 8000 burst 38 "${args[@]}"39}40 41install_qdisc_tc1()42{43 local -a args=("$@")44 45 tc qdisc add dev $swp3 parent 10:7 handle 107: red \46 limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \47 probability 1.0 avpkt 8000 burst 63 "${args[@]}"48}49 50install_qdisc()51{52 install_root_qdisc53 install_qdisc_tc0 "$@"54 install_qdisc_tc1 "$@"55 sleep 156}57 58uninstall_qdisc_tc0()59{60 tc qdisc del dev $swp3 parent 10:861}62 63uninstall_qdisc_tc1()64{65 tc qdisc del dev $swp3 parent 10:766}67 68uninstall_root_qdisc()69{70 tc qdisc del dev $swp3 parent 1:71}72 73uninstall_qdisc()74{75 uninstall_qdisc_tc076 uninstall_qdisc_tc177 uninstall_root_qdisc78}79 80ecn_test()81{82 install_qdisc ecn83 84 do_ecn_test 10 $BACKLOG185 do_ecn_test 11 $BACKLOG286 87 uninstall_qdisc88}89 90ecn_test_perband()91{92 install_qdisc ecn93 94 do_ecn_test_perband 10 $BACKLOG195 do_ecn_test_perband 11 $BACKLOG296 97 uninstall_qdisc98}99 100ecn_nodrop_test()101{102 install_qdisc ecn nodrop103 104 do_ecn_nodrop_test 10 $BACKLOG1105 do_ecn_nodrop_test 11 $BACKLOG2106 107 uninstall_qdisc108}109 110red_test()111{112 install_qdisc113 114 # Make sure that we get the non-zero value if there is any.115 local cur=$(busywait 1100 until_counter_is "> 0" \116 qdisc_stats_get $swp3 10: .backlog)117 (( cur == 0 ))118 check_err $? "backlog of $cur observed on non-busy qdisc"119 log_test "$QDISC backlog properly cleaned"120 121 do_red_test 10 $BACKLOG1122 do_red_test 11 $BACKLOG2123 124 uninstall_qdisc125}126 127mc_backlog_test()128{129 install_qdisc130 131 # Note that the backlog numbers here do not correspond to RED132 # configuration, but are arbitrary.133 do_mc_backlog_test 10 $BACKLOG1134 do_mc_backlog_test 11 $BACKLOG2135 136 uninstall_qdisc137}138 139red_mirror_test()140{141 install_qdisc qevent early_drop block 10142 143 do_drop_mirror_test 10 $BACKLOG1 early_drop144 do_drop_mirror_test 11 $BACKLOG2 early_drop145 146 uninstall_qdisc147}148 149red_trap_test()150{151 install_qdisc qevent early_drop block 10152 153 do_drop_trap_test 10 $BACKLOG1 early_drop154 do_drop_trap_test 11 $BACKLOG2 early_drop155 156 uninstall_qdisc157}158 159ecn_mirror_test()160{161 install_qdisc ecn qevent mark block 10162 163 do_mark_mirror_test 10 $BACKLOG1164 do_mark_mirror_test 11 $BACKLOG2165 166 uninstall_qdisc167}168 169bail_on_lldpad "configure DCB" "configure Qdiscs"170 171trap cleanup EXIT172setup_prepare173setup_wait174tests_run175 176exit $EXIT_STATUS177