1
0

01-change-default.patch 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. diff -Nur wondershaper-1.1a/wshaper.conf wondershaper-1.1a_openwrt/wshaper.conf
  2. --- wondershaper-1.1a/wshaper.conf 1970-01-01 01:00:00.000000000 +0100
  3. +++ wondershaper-1.1a_openwrt/wshaper.conf 2005-09-09 00:31:54.239340744 +0200
  4. @@ -0,0 +1,27 @@
  5. +# Wonder Shaper
  6. +# please read the README before filling out these values
  7. +#
  8. +# Set the following values to somewhat less than your actual download
  9. +# and uplink speed. In kilobits.
  10. +DOWNLINK=1000
  11. +UPLINK=220
  12. +
  13. +# low priority OUTGOING traffic - you can leave this blank if you want
  14. +# low priority source netmasks
  15. +NOPRIOHOSTSRC=80
  16. +
  17. +# low priority destination netmasks
  18. +NOPRIOHOSTDST=
  19. +
  20. +# low priority source ports
  21. +NOPRIOPORTSRC=
  22. +
  23. +# low priority destination ports
  24. +NOPRIOPORTDST=
  25. +
  26. +# WAN device
  27. +DEV=ppp0
  28. +
  29. +# tc location
  30. +TC=/usr/sbin/tc
  31. +
  32. diff -Nur wondershaper-1.1a/wshaper.htb wondershaper-1.1a_openwrt/wshaper.htb
  33. --- wondershaper-1.1a/wshaper.htb 2002-04-16 16:26:51.000000000 +0200
  34. +++ wondershaper-1.1a_openwrt/wshaper.htb 2005-09-11 13:24:56.143626544 +0200
  35. @@ -1,44 +1,22 @@
  36. -#!/bin/bash
  37. +#!/bin/ash
  38. # Wonder Shaper
  39. -# please read the README before filling out these values
  40. -#
  41. -# Set the following values to somewhat less than your actual download
  42. -# and uplink speed. In kilobits. Also set the device that is to be shaped.
  43. -
  44. -DOWNLINK=800
  45. -UPLINK=220
  46. -DEV=ppp0
  47. -
  48. -# low priority OUTGOING traffic - you can leave this blank if you want
  49. -# low priority source netmasks
  50. -NOPRIOHOSTSRC=
  51. -
  52. -# low priority destination netmasks
  53. -NOPRIOHOSTDST=
  54. +. /etc/functions.sh
  55. +. /etc/wshaper.conf
  56. -# low priority source ports
  57. -NOPRIOPORTSRC=
  58. -# low priority destination ports
  59. -NOPRIOPORTDST=
  60. -
  61. -
  62. -# Now remove the following two lines :-)
  63. -
  64. -echo Please read the documentation in 'README' first
  65. -exit
  66. +# do the magic
  67. if [ "$1" = "status" ]
  68. then
  69. - tc -s qdisc ls dev $DEV
  70. - tc -s class ls dev $DEV
  71. + $TC -s qdisc ls dev $DEV
  72. + $TC -s class ls dev $DEV
  73. exit
  74. fi
  75. # clean existing down- and uplink qdiscs, hide errors
  76. -tc qdisc del dev $DEV root 2> /dev/null > /dev/null
  77. -tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
  78. +$TC qdisc del dev $DEV root 2> /dev/null > /dev/null
  79. +$TC qdisc del dev $DEV ingress 2> /dev/null > /dev/null
  80. if [ "$1" = "stop" ]
  81. then
  82. @@ -46,50 +24,66 @@
  83. fi
  84. +# wondershaper must be executed everytime an interface comes up
  85. +# if we have dynamic interface ppp0 add wondershaper to ip-up
  86. +if [ $DEV = "ppp0" ] && ! grep -q wshaper /etc/ppp/ip-up
  87. +then
  88. + echo "/usr/sbin/wshaper" >> /etc/ppp/ip-up
  89. + chmod 755 /etc/ppp/ip-up
  90. +fi
  91. +
  92. +
  93. +
  94. +# load the needed kernel modules
  95. +for module in sch_prio sch_htb sch_sfq sch_ingress cls_tcindex cls_fw cls_route cls_u32
  96. +do
  97. + insmod $module 2> /dev/null > /dev/null
  98. +done
  99. +
  100. ###### uplink
  101. # install root HTB, point default traffic to 1:20:
  102. -tc qdisc add dev $DEV root handle 1: htb default 20
  103. +$TC qdisc add dev $DEV root handle 1: htb default 20
  104. # shape everything at $UPLINK speed - this prevents huge queues in your
  105. # DSL modem which destroy latency:
  106. -tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k
  107. +$TC class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k
  108. # high prio class 1:10:
  109. -tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
  110. +$TC class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
  111. burst 6k prio 1
  112. # bulk & default class 1:20 - gets slightly less traffic,
  113. # and a lower priority:
  114. -tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[9*$UPLINK/10]kbit \
  115. +$TC class add dev $DEV parent 1:1 classid 1:20 htb rate $((9*$UPLINK/10))kbit \
  116. burst 6k prio 2
  117. -tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[8*$UPLINK/10]kbit \
  118. +$TC class add dev $DEV parent 1:1 classid 1:30 htb rate $((8*$UPLINK/10))kbit \
  119. burst 6k prio 2
  120. # all get Stochastic Fairness:
  121. -tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
  122. -tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
  123. -tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
  124. +$TC qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
  125. +$TC qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
  126. +$TC qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
  127. # TOS Minimum Delay (ssh, NOT scp) in 1:10:
  128. -tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
  129. +$TC filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
  130. match ip tos 0x10 0xff flowid 1:10
  131. # ICMP (ip protocol 1) in the interactive class 1:10 so we
  132. # can do measurements & impress our friends:
  133. -tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
  134. +$TC filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
  135. match ip protocol 1 0xff flowid 1:10
  136. # To speed up downloads while an upload is going on, put ACK packets in
  137. # the interactive class:
  138. -tc filter add dev $DEV parent 1: protocol ip prio 10 u32 \
  139. +$TC filter add dev $DEV parent 1: protocol ip prio 10 u32 \
  140. match ip protocol 6 0xff \
  141. match u8 0x05 0x0f at 0 \
  142. match u16 0x0000 0xffc0 at 2 \
  143. @@ -101,31 +95,31 @@
  144. # some traffic however suffers a worse fate
  145. for a in $NOPRIOPORTDST
  146. do
  147. - tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \
  148. + $TC filter add dev $DEV parent 1: protocol ip prio 14 u32 \
  149. match ip dport $a 0xffff flowid 1:30
  150. done
  151. for a in $NOPRIOPORTSRC
  152. do
  153. - tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \
  154. + $TC filter add dev $DEV parent 1: protocol ip prio 15 u32 \
  155. match ip sport $a 0xffff flowid 1:30
  156. done
  157. for a in $NOPRIOHOSTSRC
  158. do
  159. - tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \
  160. + $TC filter add dev $DEV parent 1: protocol ip prio 16 u32 \
  161. match ip src $a flowid 1:30
  162. done
  163. for a in $NOPRIOHOSTDST
  164. do
  165. - tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \
  166. + $TC filter add dev $DEV parent 1: protocol ip prio 17 u32 \
  167. match ip dst $a flowid 1:30
  168. done
  169. # rest is 'non-interactive' ie 'bulk' and ends up in 1:20
  170. -tc filter add dev $DEV parent 1: protocol ip prio 18 u32 \
  171. +$TC filter add dev $DEV parent 1: protocol ip prio 18 u32 \
  172. match ip dst 0.0.0.0/0 flowid 1:20
  173. @@ -136,12 +130,12 @@
  174. #
  175. # attach ingress policer:
  176. -tc qdisc add dev $DEV handle ffff: ingress
  177. +$TC qdisc add dev $DEV handle ffff: ingress
  178. # filter *everything* to it (0.0.0.0/0), drop everything that's
  179. # coming in too fast:
  180. -tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
  181. +$TC filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
  182. 0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1