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