if [ $1 == htb ]; then $TC qdisc add dev $DEV root handle 7: htb $TC class add dev $DEV parent 7:0 classid 7:1 htb rate 500000 ceil 500000 $TC qdisc add dev $DEV parent 7:1 handle 1: htb $TC class add dev $DEV parent 1:0 classid 1:1 htb rate 500000 ceil 500000 $TC class add dev $DEV parent 1:1 classid 1:2 htb prio 4 rate 200000 ceil 500000 $TC class add dev $DEV parent 1:1 classid 1:3 htb prio 4 rate 300000 ceil 500000 $TC class add dev $DEV parent 1:2 classid 1:22 htb prio 4 rate 150000 ceil 500000 $TC class add dev $DEV parent 1:2 classid 1:23 htb prio 4 rate 50000 ceil 500000 $TC class add dev $DEV parent 1:2 classid 1:24 htb prio 2 rate 120000 ceil 120000 $TC class add dev $DEV parent 1:2 classid 1:25 htb prio 2 rate 80000 ceil 80000 $TC class add dev $DEV parent 1:3 classid 1:32 htb prio 4 rate 300000 ceil 500000 else $TC qdisc add dev $DEV root handle 1: hfsc $TC class add dev $DEV parent 1:0 classid 1:1 hfsc ls m2 500000 ul m2 500000 $TC class add dev $DEV parent 1:1 classid 1:2 hfsc ls m2 200000 ul m2 500000 $TC class add dev $DEV parent 1:1 classid 1:3 hfsc ls m2 300000 ul m2 500000 $TC class add dev $DEV parent 1:2 classid 1:22 hfsc ls m2 150000 ul m2 500000 $TC class add dev $DEV parent 1:2 classid 1:23 hfsc ls m2 50000 ul m2 500000 $TC class add dev $DEV parent 1:2 classid 1:24 hfsc rt m2 120000 $TC class add dev $DEV parent 1:2 classid 1:25 hfsc rt m2 80000 $TC class add dev $DEV parent 1:3 classid 1:32 hfsc ls m2 300000 ul m2 500000 fi
The 7:0 qdisc for htb had to be added to have the overall 500000 limit respected, I don't know exactly why it does not do the top-level shaping as well without it.