Browse Source

sqm-scripts: use masks with markings

Apply mask for markings to enable co-existence with multiwan, mwan3 etc.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Hannu Nyman 10 years ago
parent
commit
8001ca4c94

+ 1
- 1
net/sqm-scripts/Makefile View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=sqm-scripts
11 11
 PKG_VERSION:=7
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 PKG_LICENSE:=GPLv2
14 14
 
15 15
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

+ 6
- 2
net/sqm-scripts/files/usr/lib/sqm/functions.sh View File

@@ -29,6 +29,7 @@ ipt() {
29 29
 }
30 30
 
31 31
 do_modules() {
32
+#sm TODO: check first whether the modules exist and only load then
32 33
 	insmod act_ipt
33 34
 	insmod sch_$QDISC
34 35
 	insmod sch_ingress
@@ -59,15 +60,18 @@ do_modules() {
59 60
 [ -z "$IECN" ] && IECN="ECN"
60 61
 [ -z "$EECN" ] && EECN="NOECN"
61 62
 [ -z "$SQUASH_DSCP" ] && SQUASH_DSCP="1"
62
-[ -z "SQUASH_INGRESS" ] && SQUASH_INGRESS="1"
63
+[ -z "$SQUASH_INGRESS" ] && SQUASH_INGRESS="1"
63 64
 [ -z "$IQDISC_OPTS" ] && IQDISC_OPTS=""
64 65
 [ -z "$EQDISC_OPTS" ] && EQDISC_OPTS=""
65 66
 [ -z "$TC" ] && TC=`which tc`
66 67
 #[ -z "$TC" ] && TC="sqm_logger tc"# this redirects all tc calls into the log
67 68
 [ -z "$IP" ] && IP=$( which ip )
68 69
 [ -z "$INSMOD" ] && INSMOD=`which insmod`
69
-[ -z "TARGET" ] && TARGET="5ms"
70
+[ -z "$TARGET" ] && TARGET="5ms"
71
+[ -z "$IPT_MASK" ] && IPT_MASK="0xff"
72
+[ -z "$IPT_MASK_STRING" ] && IPT_MASK_STRING="/${IPT_MASK}"	# for set-mark
70 73
 
74
+#sqm_logger "${0} IPT_MASK: ${IPT_MASK_STRING}"
71 75
 
72 76
 
73 77
 

+ 9
- 9
net/sqm-scripts/files/usr/lib/sqm/simple.qos View File

@@ -25,13 +25,13 @@ 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
28
+ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING}
29 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
31
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1
32
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1
33
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1
34
-ipt -t mangle -A QOS_MARK_${IFACE} -m tos  --tos Minimize-Delay -j MARK --set-mark 0x1
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}
35 35
 
36 36
 # and it might be a good idea to do it for udp tunnels too
37 37
 
@@ -43,16 +43,16 @@ sqm_logger "Squashing differentiated services code points (DSCP) from ingress."
43 43
 ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be
44 44
 else
45 45
 sqm_logger "Keeping differentiated services code points (DSCP) from ingress."
46
-ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00 -g QOS_MARK_${IFACE} 
46
+ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE} 
47 47
 fi
48 48
 
49
-ipt -t mangle -A POSTROUTING -o $IFACE -m mark --mark 0x00 -g QOS_MARK_${IFACE} 
49
+ipt -t mangle -A POSTROUTING -o $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE} 
50 50
 
51 51
 # The Syn optimization was nice but fq_codel does it for us
52 52
 # ipt -t mangle -A PREROUTING -i s+ -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x01
53 53
 # Not sure if this will work. Encapsulation is a problem period
54 54
 
55
-ipt -t mangle -I PREROUTING -i vtun+ -p tcp -j MARK --set-mark 0x2 # tcp tunnels need ordering
55
+ipt -t mangle -I PREROUTING -i vtun+ -p tcp -j MARK --set-mark 0x2${IPT_MASK_STRING} # tcp tunnels need ordering
56 56
 
57 57
 # Emanating from router, do a little more optimization
58 58
 # but don't bother with it too much. 

+ 32
- 24
net/sqm-scripts/files/usr/lib/sqm/simple_pppoe.qos View File

@@ -19,19 +19,24 @@
19 19
 
20 20
 # You need to jiggle these parameters. Note limits are tuned towards a <10Mbit uplink <60Mbup down
21 21
 
22
-. /usr/lib/sqm/functions.sh
22
+#sm: Goal to create a set of tc filters that also apply on pppoe encapsulated packets
23
+#	but having multiple filters run in succession is slow, so look at tc filter hashing 
24
+#	(this should help cut down the number of OPs per packet considerably)
25
+
23 26
 
27
+. /usr/lib/sqm/functions.sh
28
+#sqm_logger IPT_MASK: ${IPT_MASK_STRING}
24 29
 ipt_setup() {
25 30
 
26 31
 ipt -t mangle -N QOS_MARK_${IFACE}
27 32
 
28
-ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2
33
+ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING}
29 34
 # 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
31
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1
32
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1
33
-ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1
34
-ipt -t mangle -A QOS_MARK_${IFACE} -m tos  --tos Minimize-Delay -j MARK --set-mark 0x1
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}
35 40
 
36 41
 # and it might be a good idea to do it for udp tunnels too
37 42
 
@@ -39,20 +44,20 @@ ipt -t mangle -A QOS_MARK_${IFACE} -m tos  --tos Minimize-Delay -j MARK --set-ma
39 44
 
40 45
 if [ "$SQUASH_DSCP" = "1" ]
41 46
 then
42
-sqm_logger "Squashing differentiad services code points (DSCP) from ingress."
47
+sqm_logger "Squashing differentiated services code points (DSCP) from ingress."
43 48
 ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be
44 49
 else
45 50
 sqm_logger "Keeping differentiad services code points (DSCP) from ingress."
46
-ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00 -g QOS_MARK_${IFACE} 
51
+ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE} 
47 52
 fi
48 53
 
49
-ipt -t mangle -A POSTROUTING -o $IFACE -m mark --mark 0x00 -g QOS_MARK_${IFACE} 
54
+ipt -t mangle -A POSTROUTING -o $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE} 
50 55
 
51 56
 # The Syn optimization was nice but fq_codel does it for us
52 57
 # ipt -t mangle -A PREROUTING -i s+ -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark 0x01
53 58
 # Not sure if this will work. Encapsulation is a problem period
54 59
 
55
-ipt -t mangle -I PREROUTING -i vtun+ -p tcp -j MARK --set-mark 0x2 # tcp tunnels need ordering
60
+ipt -t mangle -I PREROUTING -i vtun+ -p tcp -j MARK --set-mark 0x2${IPT_MASK_STRING} # tcp tunnels need ordering
56 61
 
57 62
 # Emanating from router, do a little more optimization
58 63
 # but don't bother with it too much. 
@@ -65,25 +70,27 @@ ipt -t mangle -A OUTPUT -p udp -m multiport --ports 123,53 -j DSCP --set-dscp-cl
65 70
 }
66 71
 
67 72
 
73
+MYBURST=1600	#sm: make burst and cburst as well as quantum configurable for ingress and egress in the GUI
68 74
 # TC rules
69 75
 
70 76
 egress() {
71 77
 
72 78
 CEIL=${UPLINK}
73
-PRIO_RATE=`expr $CEIL / 3` # Ceiling for prioirty
79
+PRIO_RATE=`expr $CEIL / 3` # Ceiling for priority
74 80
 BE_RATE=`expr $CEIL / 6`   # Min for best effort
75 81
 BK_RATE=`expr $CEIL / 6`   # Min for background
76 82
 BE_CEIL=`expr $CEIL - 16`  # A little slop at the top
77 83
 
78 84
 LQ="quantum `get_mtu $IFACE $CEIL`"
85
+HTB_BURSTS="burst ${MYBURST} cburst ${MYBURST}"
79 86
 
80 87
 $TC qdisc del dev $IFACE root 2> /dev/null
81 88
 $TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 12
82
-$TC class add dev $IFACE parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
83
-$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`
84
-$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`
85
-$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`
86
-$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`
89
+$TC class add dev $IFACE parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
90
+$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`
91
+$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`
92
+$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`
93
+$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`
87 94
 
88 95
 $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}
89 96
 $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}
@@ -301,6 +308,7 @@ BK_RATE=`expr $CEIL / 6`   # Min for background
301 308
 BE_CEIL=`expr $CEIL - 16`  # A little slop at the top
302 309
 
303 310
 LQ="quantum `get_mtu $IFACE $CEIL`"
311
+HTB_BURSTS="burst ${MYBURST} cburst ${MYBURST}"
304 312
 
305 313
 $TC qdisc del dev $IFACE handle ffff: ingress 2> /dev/null
306 314
 $TC qdisc add dev $IFACE handle ffff: ingress
@@ -313,18 +321,18 @@ sqm_logger "Do not perform DSCP based filtering on ingress. (1-tier classificati
313 321
 # Revert to no dscp based filtering
314 322
 $TC qdisc del dev $DEV root 2>/dev/null
315 323
 $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10
316
-$TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string`
317
-$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`
324
+$TC class add dev $DEV parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string`
325
+$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`
318 326
 $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}
319 327
 
320 328
 else
321 329
 sqm_logger "Perform DSCP based filtering on ingress. (3-tier classification)"
322 330
 $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 12
323
-$TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
324
-$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`
325
-$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`
326
-$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`
327
-$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`
331
+$TC class add dev $DEV parent 1: classid 1:1 htb $LQ ${HTB_BURSTS} rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string`
332
+$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`
333
+$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`
334
+$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`
335
+$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`
328 336
 
329 337
 # I'd prefer to use a pre-nat filter but that causes permutation...
330 338