|
@@ -7,7 +7,7 @@
|
7
|
7
|
# it under the terms of the GNU General Public License version 2 as
|
8
|
8
|
# published by the Free Software Foundation.
|
9
|
9
|
#
|
10
|
|
-# Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
|
|
10
|
+# Copyright (C) 2012-5 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
|
11
|
11
|
|
12
|
12
|
# Compared to the complexity that debloat had become
|
13
|
13
|
# this cleanly shows a means of going from diffserv marking
|
|
@@ -25,13 +25,20 @@ ipt_setup() {
|
25
|
25
|
|
26
|
26
|
ipt -t mangle -N QOS_MARK_${IFACE}
|
27
|
27
|
|
28
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING}
|
29
|
|
-# You can go further with classification but...
|
30
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS1 -j MARK --set-mark 0x3${IPT_MASK_STRING}
|
31
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
32
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
33
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
34
|
|
-ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
|
28
|
+case $QDISC in
|
|
29
|
+ cake*)
|
|
30
|
+ sqm_logger cake does all the diffserv work - no need for iptables rules
|
|
31
|
+ ;;
|
|
32
|
+ *)
|
|
33
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING}
|
|
34
|
+ # You can go further with classification but...
|
|
35
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS1 -j MARK --set-mark 0x3${IPT_MASK_STRING}
|
|
36
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
|
37
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
|
38
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
|
39
|
+ ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-mark 0x1${IPT_MASK_STRING}
|
|
40
|
+ ;;
|
|
41
|
+esac
|
35
|
42
|
|
36
|
43
|
# and it might be a good idea to do it for udp tunnels too
|
37
|
44
|
|
|
@@ -43,9 +50,11 @@ ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-ma
|
43
|
50
|
if [ "$SQUASH_DSCP" = "1" ]
|
44
|
51
|
then
|
45
|
52
|
sqm_logger "Squashing differentiated services code points (DSCP) from ingress."
|
|
53
|
+CAKE_OPTS=besteffort # someday squash
|
46
|
54
|
ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be
|
47
|
55
|
else
|
48
|
56
|
sqm_logger "Keeping differentiated services code points (DSCP) from ingress."
|
|
57
|
+CAKE_OPTS=""
|
49
|
58
|
ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE}
|
50
|
59
|
fi
|
51
|
60
|
|
|
@@ -81,47 +90,53 @@ BE_CEIL=`expr $CEIL - 16` # A little slop at the top
|
81
|
90
|
LQ="quantum `get_mtu $IFACE $CEIL`"
|
82
|
91
|
|
83
|
92
|
$TC qdisc del dev $IFACE root 2> /dev/null
|
84
|
|
-$TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 12
|
85
|
|
-$TC class add dev $IFACE parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
|
86
|
|
-$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`
|
87
|
|
-$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`
|
88
|
|
-$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`
|
89
|
|
-$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`
|
90
|
|
-
|
91
|
|
-$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}
|
92
|
|
-$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}
|
93
|
|
-$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}
|
94
|
|
-
|
95
|
|
-
|
96
|
|
-# Need a catchall rule
|
97
|
|
-
|
98
|
|
-$TC filter add dev $IFACE parent 1:0 protocol all prio 999 u32 \
|
99
|
|
- match ip protocol 0 0x00 flowid 1:12
|
100
|
|
-
|
101
|
|
-# FIXME should probably change the filter here to do pre-nat
|
|
93
|
+case $QDISC in
|
|
94
|
+ cake*)
|
|
95
|
+ $TC qdisc add dev $IFACE root `get_stab_string` $QDISC bandwidth ${CEIL}kbit `get_cake_lla_string` ${EQDISC_OPTS}
|
|
96
|
+ ;;
|
|
97
|
+ *)
|
|
98
|
+ $TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 12
|
|
99
|
+ $TC class add dev $IFACE parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
|
|
100
|
+ $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`
|
|
101
|
+ $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`
|
|
102
|
+ $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`
|
|
103
|
+ $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`
|
|
104
|
+
|
|
105
|
+ $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}
|
|
106
|
+ $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}
|
|
107
|
+ $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}
|
|
108
|
+
|
|
109
|
+ # Need a catchall rule
|
|
110
|
+
|
|
111
|
+ $TC filter add dev $IFACE parent 1:0 protocol all prio 999 u32 \
|
|
112
|
+ match ip protocol 0 0x00 flowid 1:12
|
|
113
|
+
|
|
114
|
+ # FIXME should probably change the filter here to do pre-nat
|
102
|
115
|
|
103
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11
|
104
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12
|
105
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ip prio 3 handle 3 fw classid 1:13
|
|
116
|
+ $TC filter add dev $IFACE parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11
|
|
117
|
+ $TC filter add dev $IFACE parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12
|
|
118
|
+ $TC filter add dev $IFACE parent 1:0 protocol ip prio 3 handle 3 fw classid 1:13
|
106
|
119
|
|
107
|
|
-# ipv6 support. Note that the handle indicates the fw mark bucket that is looked for
|
|
120
|
+ # ipv6 support. Note that the handle indicates the fw mark bucket that is looked for
|
108
|
121
|
|
109
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 4 handle 1 fw classid 1:11
|
110
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 5 handle 2 fw classid 1:12
|
111
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 6 handle 3 fw classid 1:13
|
|
122
|
+ $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 4 handle 1 fw classid 1:11
|
|
123
|
+ $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 5 handle 2 fw classid 1:12
|
|
124
|
+ $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 6 handle 3 fw classid 1:13
|
112
|
125
|
|
113
|
|
-# Arp traffic
|
|
126
|
+ # Arp traffic
|
114
|
127
|
|
115
|
|
-$TC filter add dev $IFACE parent 1:0 protocol arp prio 7 handle 1 fw classid 1:11
|
|
128
|
+ $TC filter add dev $IFACE parent 1:0 protocol arp prio 7 handle 1 fw classid 1:11
|
116
|
129
|
|
117
|
|
-# ICMP traffic - Don't impress your friends. Deoptimize to manage ping floods
|
118
|
|
-# better instead
|
|
130
|
+ # ICMP traffic - Don't impress your friends. Deoptimize to manage ping floods
|
|
131
|
+ # better instead
|
119
|
132
|
|
120
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ip prio 8 \
|
121
|
|
- u32 match ip protocol 1 0xff flowid 1:13
|
|
133
|
+ $TC filter add dev $IFACE parent 1:0 protocol ip prio 8 \
|
|
134
|
+ u32 match ip protocol 1 0xff flowid 1:13
|
122
|
135
|
|
123
|
|
-$TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 9 \
|
124
|
|
- u32 match ip protocol 1 0xff flowid 1:13
|
|
136
|
+ $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 9 \
|
|
137
|
+ u32 match ip protocol 1 0xff flowid 1:13
|
|
138
|
+ ;;
|
|
139
|
+esac
|
125
|
140
|
|
126
|
141
|
#diffserv $IFACE
|
127
|
142
|
|
|
@@ -144,31 +159,43 @@ $TC qdisc del dev $DEV root 2> /dev/null
|
144
|
159
|
|
145
|
160
|
if [ "$SQUASH_INGRESS" = "1" ]
|
146
|
161
|
then
|
147
|
|
-sqm_logger "Do not perform DSCP based filtering on ingress. (1-tier classification)"
|
148
|
|
-# Revert to no dscp based filtering
|
149
|
|
-$TC qdisc del dev $DEV root 2>/dev/null
|
150
|
|
-$TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10
|
151
|
|
-$TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string`
|
152
|
|
-$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`
|
153
|
|
-$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}
|
|
162
|
+ sqm_logger "Do not perform DSCP based filtering on ingress. (1-tier classification)"
|
|
163
|
+ # Revert to no dscp based filtering
|
|
164
|
+ case $QDISC in
|
|
165
|
+ cake*)
|
|
166
|
+ $TC qdisc add dev $DEV root `get_stab_string` $QDISC bandwidth ${DOWNLINK}kbit besteffort `get_cake_lla_string` ${IQDISC_OPTS}
|
|
167
|
+ ;;
|
|
168
|
+ *)
|
|
169
|
+ $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10
|
|
170
|
+ $TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string`
|
|
171
|
+ $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`
|
|
172
|
+ $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}
|
|
173
|
+ ;;
|
|
174
|
+ esac
|
154
|
175
|
|
155
|
176
|
else
|
156
|
|
-sqm_logger "Perform DSCP based filtering on ingress. (3-tier classification)"
|
157
|
|
-$TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 12
|
158
|
|
-$TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
|
159
|
|
-$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`
|
160
|
|
-$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`
|
161
|
|
-$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`
|
162
|
|
-$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`
|
163
|
|
-
|
164
|
|
-# I'd prefer to use a pre-nat filter but that causes permutation...
|
165
|
|
-
|
166
|
|
-$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}
|
167
|
|
-$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}
|
168
|
|
-$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}
|
169
|
|
-
|
170
|
|
-diffserv $DEV
|
171
|
|
-
|
|
177
|
+ sqm_logger "Perform DSCP based filtering on ingress. (3-tier classification)"
|
|
178
|
+ case $QDISC in
|
|
179
|
+ cake*)
|
|
180
|
+ $TC qdisc add dev $DEV root `get_stab_string` $QDISC bandwidth ${DOWNLINK}kbit `get_cake_lla_string` $CAKE_OPTS ${IQDISC_OPTS}
|
|
181
|
+ ;;
|
|
182
|
+ *)
|
|
183
|
+ $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 12
|
|
184
|
+ $TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
|
|
185
|
+ $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`
|
|
186
|
+ $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`
|
|
187
|
+ $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`
|
|
188
|
+ $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`
|
|
189
|
+
|
|
190
|
+ # I'd prefer to use a pre-nat filter but that causes permutation...
|
|
191
|
+
|
|
192
|
+ $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}
|
|
193
|
+ $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}
|
|
194
|
+ $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}
|
|
195
|
+
|
|
196
|
+ diffserv $DEV
|
|
197
|
+ ;;
|
|
198
|
+ esac
|
172
|
199
|
fi
|
173
|
200
|
|
174
|
201
|
ifconfig $DEV up
|