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