No Description

simple_pppoe.qos 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. #!/bin/sh
  2. # Cero3 Shaper
  3. # A 3 bin tc_codel and ipv6 enabled shaping script for
  4. # ethernet gateways
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License version 2 as
  7. # published by the Free Software Foundation.
  8. #
  9. # Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
  10. # Compared to the complexity that debloat had become
  11. # this cleanly shows a means of going from diffserv marking
  12. # to prioritization using the current tools (ip(6)tables
  13. # and tc. I note that the complexity of debloat exists for
  14. # a reason, and it is expected that script is run first
  15. # to setup various other parameters such as BQL and ethtool.
  16. # (And that the debloat script has setup the other interfaces)
  17. # You need to jiggle these parameters. Note limits are tuned towards a <10Mbit uplink <60Mbup down
  18. #sm: Goal to create a set of tc filters that also apply on pppoe encapsulated packets
  19. # but having multiple filters run in succession is slow, so look at tc filter hashing
  20. # (this should help cut down the number of OPs per packet considerably)
  21. . /usr/lib/sqm/functions.sh
  22. #sqm_logger IPT_MASK: ${IPT_MASK_STRING}
  23. ipt_setup() {
  24. ipt -t mangle -N QOS_MARK_${IFACE}
  25. ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING}
  26. # You can go further with classification but...
  27. ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS1 -j MARK --set-mark 0x3${IPT_MASK_STRING}
  28. ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1${IPT_MASK_STRING}
  29. ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1${IPT_MASK_STRING}
  30. ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1${IPT_MASK_STRING}
  31. ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-mark 0x1${IPT_MASK_STRING}
  32. # and it might be a good idea to do it for udp tunnels too
  33. # Turn it on. Preserve classification if already performed
  34. if [ "$SQUASH_DSCP" = "1" ]
  35. then
  36. sqm_logger "Squashing differentiated services code points (DSCP) from ingress."
  37. ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be
  38. else
  39. sqm_logger "Keeping differentiad services code points (DSCP) from ingress."
  40. ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE}
  41. fi
  42. ipt -t mangle -A POSTROUTING -o $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE}
  43. # The Syn optimization was nice but fq_codel does it for us
  44. # ipt -t mangle -A PREROUTING -i s+ -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x01
  45. # Not sure if this will work. Encapsulation is a problem period
  46. ipt -t mangle -I PREROUTING -i vtun+ -p tcp -j MARK --set-mark 0x2${IPT_MASK_STRING} # tcp tunnels need ordering
  47. # Emanating from router, do a little more optimization
  48. # but don't bother with it too much.
  49. ipt -t mangle -A OUTPUT -p udp -m multiport --ports 123,53 -j DSCP --set-dscp-class AF42
  50. #Not clear if the second line is needed
  51. #ipt -t mangle -A OUTPUT -o $IFACE -g QOS_MARK_${IFACE}
  52. }
  53. MYBURST=1600 #sm: make burst and cburst as well as quantum configurable for ingress and egress in the GUI
  54. # TC rules
  55. egress() {
  56. CEIL=${UPLINK}
  57. PRIO_RATE=`expr $CEIL / 3` # Ceiling for priority
  58. BE_RATE=`expr $CEIL / 6` # Min for best effort
  59. BK_RATE=`expr $CEIL / 6` # Min for background
  60. BE_CEIL=`expr $CEIL - 16` # A little slop at the top
  61. LQ="quantum `get_mtu $IFACE $CEIL`"
  62. HTB_BURSTS="burst ${MYBURST} cburst ${MYBURST}"
  63. $TC qdisc del dev $IFACE root 2> /dev/null
  64. $TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 12
  65. $TC class add dev $IFACE parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
  66. $TC class add dev $IFACE parent 1:1 classid 1:10 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit prio 0 `get_htb_adsll_string`
  67. $TC class add dev $IFACE parent 1:1 classid 1:11 htb $LQ ${HTB_BURSTS} rate 128kbit ceil ${PRIO_RATE}kbit prio 1 `get_htb_adsll_string`
  68. $TC class add dev $IFACE parent 1:1 classid 1:12 htb $LQ ${HTB_BURSTS} rate ${BE_RATE}kbit ceil ${BE_CEIL}kbit prio 2 `get_htb_adsll_string`
  69. $TC class add dev $IFACE parent 1:1 classid 1:13 htb $LQ ${HTB_BURSTS} rate ${BK_RATE}kbit ceil ${BE_CEIL}kbit prio 3 `get_htb_adsll_string`
  70. $TC qdisc add dev $IFACE parent 1:11 handle 110: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${PRIO_RATE}` ${EQDISC_OPTS}
  71. $TC qdisc add dev $IFACE parent 1:12 handle 120: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BE_RATE}` ${EQDISC_OPTS}
  72. $TC qdisc add dev $IFACE parent 1:13 handle 130: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${EQDISC_OPTS}
  73. #sm: for testing we need a band to collect PPPOEd packets
  74. $TC class add dev $IFACE parent 1:1 classid 1:14 htb $LQ rate ${BE_RATE}kbit ceil ${BE_CEIL}kbit prio 2 `get_htb_adsll_string`
  75. $TC qdisc add dev $IFACE parent 1:14 handle 140: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${EQDISC_OPTS}
  76. # Need a catchall rule (should also match VLANs and PPPoE packets)
  77. $TC filter add dev $IFACE parent 1:0 protocol all prio 999 u32 \
  78. match ip protocol 0 0x00 flowid 1:12
  79. # FIXME should probably change the filter here to do pre-nat
  80. $TC filter add dev $IFACE parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11
  81. $TC filter add dev $IFACE parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12
  82. $TC filter add dev $IFACE parent 1:0 protocol ip prio 3 handle 3 fw classid 1:13
  83. # ipv6 support. Note that the handle indicates the fw mark bucket that is looked for
  84. $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 4 handle 1 fw classid 1:11
  85. $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 5 handle 2 fw classid 1:12
  86. $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 6 handle 3 fw classid 1:13
  87. # Arp traffic
  88. $TC filter add dev $IFACE parent 1:0 protocol arp prio 7 handle 1 fw classid 1:11
  89. # ICMP traffic - Don't impress your friends. Deoptimize to manage ping floods
  90. # better instead
  91. $TC filter add dev $IFACE parent 1:0 protocol ip prio 8 \
  92. u32 match ip protocol 1 0xff flowid 1:13
  93. $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 9 \
  94. u32 match ip protocol 1 0xff flowid 1:13
  95. # PPPoE encapsulated packets traversing the router (e.g.: the router does PPPoE termination but we shape
  96. # on the underlaying ethernet interface instead of the pppoe device)
  97. PPPOE_SESSION_ETHERTYPE="0x8864"
  98. PPPOE_DISCOVERY_ETHERTYPE="0x8863"
  99. PPP_PROTO_IP4="0x0021"
  100. PPP_PROTO_IP6="0x0057"
  101. ARP_PROTO_IP4="0x0806"
  102. # NOTE it seems prio can not be reused?
  103. #$TC filter add dev $IFACE protocol 0x8863 parent 1:0 prio 1 u32 flowid 1:14
  104. # PPPoE can be selected for by ether_type, the encapsulated IP version from the PPP (0x0021 IPv4, 0x0057 IPv6)
  105. #U32_PREFIX="$TC filter add dev $IFACE" parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE}"
  106. #BE: 1:12 is the default anyway, but this will catch all non marked packets
  107. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 400 u32 \
  108. # match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  109. # match u8 0x00 0xfb at 9 \
  110. # flowid 1:12
  111. #AF42
  112. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 401 u32 \
  113. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  114. match u8 0x90 0xfc at 9 \
  115. flowid 1:11
  116. #EF
  117. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 402 u32 \
  118. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  119. match u8 0xb8 0xfc at 9 \
  120. flowid 1:11
  121. #CS1
  122. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 403 u32 \
  123. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  124. match u8 0x20 0xf0 at 9 \
  125. flowid 1:13
  126. #IMM
  127. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 404 u32 \
  128. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  129. match u8 0x10 0xf0 at 9 \
  130. flowid 1:11
  131. #CS3
  132. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 405 u32 \
  133. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  134. match u8 0xc0 0xf0 at 9 \
  135. flowid 1:11
  136. #CS6
  137. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 406 u32 \
  138. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  139. match u8 0xe0 0xf0 at 9 \
  140. flowid 1:11
  141. ## Arp traffic
  142. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 409 u32 \
  143. # match u16 ${ARP_PROTO_IP4} 0xffff at 6 \
  144. # flowid 1:14
  145. # ICMP traffic - Don't impress your friends. Deoptimize to manage ping floods
  146. # better instead; sm: really only deprio echo requestst and echo replies instead?
  147. # ECHO request, the rest stays in best effort
  148. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 410 u32 \
  149. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  150. match u8 0x01 0xff at 17 \
  151. match u8 0x08 0xff at 28 \
  152. flowid 1:13
  153. # ECHO reply
  154. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 410 u32 \
  155. match u16 ${PPP_PROTO_IP4} 0xffff at 6 \
  156. match u8 0x01 0xff at 17 \
  157. match u8 0x00 0xff at 28 \
  158. flowid 1:13
  159. ## ICMPv6 133-137 (NDP) is equivalent to IPv4 ARP, so only push echo request and reply into the bulk class
  160. ## 133
  161. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  162. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  163. # match u8 0x85 0xff at 48 \
  164. # match u8 0x3a 0xff at 14 \
  165. # flowid 1:14
  166. ## 134
  167. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  168. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  169. # match u8 0x86 0xff at 48 \
  170. # match u8 0x3a 0xff at 14 \
  171. # flowid 1:14
  172. ## 135
  173. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  174. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  175. # match u8 0x87 0xff at 48 \
  176. # match u8 0x3a 0xff at 14 \
  177. # flowid 1:14
  178. ## 136
  179. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  180. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  181. # match u8 0x88 0xff at 48 \
  182. # match u8 0x3a 0xff at 14 \
  183. # flowid 1:14
  184. ## 137
  185. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  186. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  187. # match u8 0x89 0xff at 48 \
  188. # match u8 0x3a 0xff at 14 \
  189. # flowid 1:14
  190. # ICMPv6 echo request
  191. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  192. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  193. match u8 0x3a 0xff at 14 \
  194. match u8 0x80 0xff at 48 \
  195. flowid 1:13
  196. # ICMPv6 echo reply
  197. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 610 u32 \
  198. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  199. match u8 0x3a 0xff at 14 \
  200. match u8 0x81 0xff at 48 \
  201. flowid 1:13
  202. #IPV6
  203. #BE: careful, will override ICMP
  204. #$TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 600 u32 \
  205. # match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  206. # match u16 0x0000 0x0fb0 at 8 \
  207. # flowid 1:12
  208. #AF42
  209. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 601 u32 \
  210. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  211. match u16 0x0900 0x0fc0 at 8 \
  212. flowid 1:11
  213. #EF
  214. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 602 u32 \
  215. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  216. match u16 0x0b80 0x0fc0 at 8 \
  217. flowid 1:11
  218. #CS1
  219. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 603 u32 \
  220. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  221. match u16 0x0200 0x0fc0 at 8 \
  222. flowid 1:13
  223. #IMM
  224. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 604 u32 \
  225. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  226. match u16 0x0100 0x0fc0 at 8 \
  227. flowid 1:11
  228. #CS3
  229. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 605 u32 \
  230. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  231. match u16 0x0c00 0x0fc0 at 8 \
  232. flowid 1:11
  233. #CS6
  234. $TC filter add dev $IFACE parent 1:0 protocol ${PPPOE_SESSION_ETHERTYPE} prio 606 u32 \
  235. match u16 ${PPP_PROTO_IP6} 0xffff at 6 \
  236. match u16 0x0e00 0x0fc0 at 8 \
  237. flowid 1:11
  238. #diffserv $IFACE
  239. }
  240. ingress() {
  241. CEIL=$DOWNLINK
  242. PRIO_RATE=`expr $CEIL / 3` # Ceiling for prioirty
  243. BE_RATE=`expr $CEIL / 6` # Min for best effort
  244. BK_RATE=`expr $CEIL / 6` # Min for background
  245. BE_CEIL=`expr $CEIL - 16` # A little slop at the top
  246. LQ="quantum `get_mtu $IFACE $CEIL`"
  247. HTB_BURSTS="burst ${MYBURST} cburst ${MYBURST}"
  248. $TC qdisc del dev $IFACE handle ffff: ingress 2> /dev/null
  249. $TC qdisc add dev $IFACE handle ffff: ingress
  250. $TC qdisc del dev $DEV root 2> /dev/null
  251. if [ "$SQUASH_INGRESS" = "1" ]
  252. then
  253. sqm_logger "Do not perform DSCP based filtering on ingress. (1-tier classification)"
  254. # Revert to no dscp based filtering
  255. $TC qdisc del dev $DEV root 2>/dev/null
  256. $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10
  257. $TC class add dev $DEV parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string`
  258. $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ ${HTB_BURSTS} rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit prio 0 `get_htb_adsll_string`
  259. $TC qdisc add dev $DEV parent 1:10 handle 110: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_flows ${DOWNLINK}` ${IQDISC_OPTS}
  260. else
  261. sqm_logger "Perform DSCP based filtering on ingress. (3-tier classification)"
  262. $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 12
  263. $TC class add dev $DEV parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
  264. $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit prio 0 `get_htb_adsll_string`
  265. $TC class add dev $DEV parent 1:1 classid 1:11 htb $LQ ${HTB_BURSTS} rate 32kbit ceil ${PRIO_RATE}kbit prio 1 `get_htb_adsll_string`
  266. $TC class add dev $DEV parent 1:1 classid 1:12 htb $LQ ${HTB_BURSTS} rate ${BE_RATE}kbit ceil ${BE_CEIL}kbit prio 2 `get_htb_adsll_string`
  267. $TC class add dev $DEV parent 1:1 classid 1:13 htb $LQ ${HTB_BURSTS} rate ${BK_RATE}kbit ceil ${BE_CEIL}kbit prio 3 `get_htb_adsll_string`
  268. # I'd prefer to use a pre-nat filter but that causes permutation...
  269. $TC qdisc add dev $DEV parent 1:11 handle 110: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_quantum 500` `get_flows ${PRIO_RATE}` ${IQDISC_OPTS}
  270. $TC qdisc add dev $DEV parent 1:12 handle 120: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_quantum 1500` `get_flows ${BE_RATE}` ${IQDISC_OPTS}
  271. $TC qdisc add dev $DEV parent 1:13 handle 130: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${IQDISC_OPTS}
  272. #sm: for PPPoE packet testing
  273. $TC class add dev $DEV parent 1:1 classid 1:14 htb $LQ rate ${BK_RATE}kbit ceil ${BE_CEIL}kbit prio 3 `get_htb_adsll_string`
  274. $TC qdisc add dev $DEV parent 1:14 handle 140: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${IQDISC_OPTS}
  275. #diffserv $DEV
  276. diffserv_pppoe $DEV
  277. fi
  278. ifconfig $DEV up
  279. # redirect all IP packets arriving in $IFACE to ifb0
  280. $TC filter add dev $IFACE parent ffff: protocol all prio 10 u32 \
  281. match u32 0 0 flowid 1:1 action mirred egress redirect dev $DEV
  282. }
  283. do_modules
  284. ipt_setup
  285. if [ "$UPLINK" -ne 0 ];
  286. then
  287. egress
  288. sqm_logger "egress shaping activated"
  289. else
  290. sqm_logger "egress shaping deactivated"
  291. tc qdisc del dev $IFACE root 2> /dev/null
  292. fi
  293. if [ "$DOWNLINK" -ne 0 ];
  294. then
  295. ingress
  296. sqm_logger "ingress shaping activated"
  297. else
  298. sqm_logger "ingress shaping deactivated"
  299. tc qdisc del dev $DEV root 2> /dev/null
  300. tc qdisc del dev $IFACE ingress 2> /dev/null
  301. fi
  302. # References:
  303. # This alternate shaper attempts to go for 1/u performance in a clever way
  304. # http://git.coverfire.com/?p=linux-qos-scripts.git;a=blob;f=src-3tos.sh;hb=HEAD
  305. # Comments
  306. # This does the right thing with ipv6 traffic.
  307. # It also tries to leverage diffserv to some sane extent. In particular,
  308. # the 'priority' queue is limited to 33% of the total, so EF, and IMM traffic
  309. # cannot starve other types. The rfc suggested 30%. 30% is probably
  310. # a lot in today's world.
  311. # Flaws
  312. # Many!