Subject: [alpine-devel] [PATCH] main/iproute2-qos: add htb burst and fix privileged class ceiling

From: Timo Teräs <[email-masked]>
Date: Tue, 1 Jun 2010 18:16:54 +0300

The HTB classifier uses a burst parameter to figure how much of
packets can be queued when the class is lending from other classes.
It should be set automatically by tc / kernel, but appears not be
set, so set it explictly. This fixes htb class not getting full
speed if difference of ceil and rate is large.

This also changes Privileged class to get ceil of the total
bandwidth instead of the previous hard limit of guaranteed rate.
While, it is consider good practices for Privileged class to have
hard ceil less than max. speed, it will cause problems links with
asymmetric speeds (e.g. ADSL 24M/1M cannot gain full download
speed if Privileged class is limited this heavily). It might be
a good idea to later have the hard ceiling configurable, but for
now it's better to ceil it to wire speed.
---
 main/iproute2-qos/APKBUILD  |    2 +-
 main/iproute2-qos/qos.initd |   22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/main/iproute2-qos/APKBUILD b/main/iproute2-qos/APKBUILD
index bb0b27a..2d3c3b8 100644
--- a/main/iproute2-qos/APKBUILD
+++ b/main/iproute2-qos/APKBUILD
@@ -1,7 +1,7 @@
 # Contributor: Ilya Strelkin <[email-masked]>
 # Maintainer: Ilya Strelkin <[email-masked]>
 pkgname=iproute2-qos
-pkgver=0.3
+pkgver=0.4
 pkgrel=0
 pkgdesc="Scripts to set up quality of service with iproute2"
 url="http://git.alpinelinux.org/cgit/aports"
diff --git a/main/iproute2-qos/qos.initd b/main/iproute2-qos/qos.initd
index 9986a8c..0967735 100644
--- a/main/iproute2-qos/qos.initd
+++ b/main/iproute2-qos/qos.initd
@@ -225,11 +225,11 @@ set_filters()
 set_htb()
 {
 	$ECHO tc qdisc add dev $DEV root handle 1 htb default 60
-		$ECHO tc class add dev $DEV parent 1: classid 1:2 htb rate $DEV_RATE
-			$ECHO tc class add dev $DEV parent 1:2 classid 1:30 htb rate $WAN_SUB_RATE
-				$ECHO tc class add dev $DEV parent 1:30 classid 1:40 htb rate $INTERACTIVE_RATE prio 1
-				$ECHO tc class add dev $DEV parent 1:30 classid 1:50 htb rate $PRIVILEGED_RATE ceil $WAN_SUB_RATE prio 3
-	    			$ECHO tc class add dev $DEV parent 1:30 classid 1:60 htb rate $BESTEFFORT_RATE ceil $WAN_SUB_RATE prio 6
+		$ECHO tc class add dev $DEV parent 1: classid 1:2 htb rate $DEV_RATE burst $(($DEV_RATE*5/4))
+			$ECHO tc class add dev $DEV parent 1:2 classid 1:30 htb rate $WAN_SUB_RATE burst $(($WAN_SUB_RATE*5/4))
+				$ECHO tc class add dev $DEV parent 1:30 classid 1:40 htb rate $INTERACTIVE_RATE ceil $WAN_SUB_RATE prio 1
+				$ECHO tc class add dev $DEV parent 1:30 classid 1:50 htb rate $PRIVILEGED_RATE ceil $WAN_SUB_RATE prio 3 burst $(($WAN_SUB_RATE*5/4))
+				$ECHO tc class add dev $DEV parent 1:30 classid 1:60 htb rate $BESTEFFORT_RATE ceil $WAN_SUB_RATE prio 6 burst $(($WAN_SUB_RATE*5/4))
 
 				if [ $OUT_OF_WAN_RATE -gt 0 ]; then
 					$ECHO tc class add dev $DEV parent 1:2 classid 1:70 htb rate $OUT_OF_WAN_RATE prio 7
@@ -250,7 +250,7 @@ set_hfsc()
 	$ECHO tc qdisc add dev $DEV root handle 1 hfsc default 60
 		$ECHO tc class add dev $DEV parent 1: classid 1:2 hfsc sc rate $DEV_RATE ul rate $DEV_RATE
 			$ECHO tc class add dev $DEV parent 1:2 classid 1:30 hfsc sc rate $WAN_SUB_RATE ul rate $WAN_SUB_RATE
-				$ECHO tc class add dev $DEV parent 1:30 classid 1:40 hfsc sc umax $INTERACTIVE_HFSC_UMAX dmax $INTERACTIVE_HFSC_DMAX rate $INTERACTIVE_RATE ul rate $INTERACTIVE_RATE
+				$ECHO tc class add dev $DEV parent 1:30 classid 1:40 hfsc sc umax $INTERACTIVE_HFSC_UMAX dmax $INTERACTIVE_HFSC_DMAX rate $INTERACTIVE_RATE ul rate $WAN_SUB_RATE
 				$ECHO tc class add dev $DEV parent 1:30 classid 1:50 hfsc sc umax $PRIVILEGED_HFSC_UMAX dmax $PRIVILEGED_HFSC_DMAX rate $PRIVILEGED_RATE ul rate $WAN_SUB_RATE
 				$ECHO tc class add dev $DEV parent 1:30 classid 1:60 hfsc sc rate $BESTEFFORT_RATE ul rate $WAN_SUB_RATE
 
@@ -272,7 +272,7 @@ set_prio()
 {
 	PARENT_CLASSID=10
 	$ECHO tc qdisc add dev $DEV root handle 1 prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # by default unclassified traffic goes to flowid 1:2
-		$ECHO tc qdisc add dev $DEV parent 1:1 handle 40: tbf rate $INTERACTIVE_RATE burst $INTERACTIVE_PRIO_BURST latency $INTERACTIVE_PRIO_LATENCY
+		$ECHO tc qdisc add dev $DEV parent 1:1 handle 40: tbf rate $INTERACTIVE_RATE burst $WAN_SUB_RATE latency $INTERACTIVE_PRIO_LATENCY
 		$ECHO tc qdisc add dev $DEV parent 1:2 handle $PARENT_CLASSID: htb default 60
 			$ECHO tc class add dev $DEV parent $PARENT_CLASSID: classid $PARENT_CLASSID:30 htb rate $WAN_SUB_RATE
 				$ECHO tc class add dev $DEV parent $PARENT_CLASSID:30 classid $PARENT_CLASSID:50 htb rate $PRIVILEGED_RATE ceil $WAN_SUB_RATE prio 3
@@ -309,7 +309,7 @@ set_police()
 #       burst = rate / 17 (taken basing on experemental results)
 
 	POLICE_BURST_SCALE=17
-        WAN_POLICE_BURST=$((WAN_RATE / POLICE_BURST_SCALE))
+	WAN_POLICE_BURST=$((WAN_RATE / POLICE_BURST_SCALE))
 
 	WAN_POLICE_FLOWID=1
 
@@ -329,9 +329,9 @@ set_cpolice()
 	#       burst = rate / 17 (taken basing on experemental results)
 
 	POLICE_BURST_SCALE=17
-        	INTERACTIVE_POLICE_BURST=$((INTERACTIVE_RATE / POLICE_BURST_SCALE))
-	        PRIVILEGED_POLICE_BURST=$((PRIVILEGED_RATE / POLICE_BURST_SCALE))
-        	BESTEFFORT_POLICE_BURST=$((BESTEFFORT_RATE / POLICE_BURST_SCALE))
+		INTERACTIVE_POLICE_BURST=$((INTERACTIVE_RATE / POLICE_BURST_SCALE))
+		PRIVILEGED_POLICE_BURST=$((PRIVILEGED_RATE / POLICE_BURST_SCALE))
+		BESTEFFORT_POLICE_BURST=$((BESTEFFORT_RATE / POLICE_BURST_SCALE))
 
 	CLASS_TYPES="INTERACTIVE PRIVILEGED"
 		INTERACTIVE_POLICE_FLOWID=1
-- 
1.7.0.4

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---