]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- support for limiting downstream and upstream traffic on whole interface
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 22 Aug 2002 13:21:25 +0000 (13:21 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 22 Aug 2002 13:21:25 +0000 (13:21 +0000)
  (cbq, htb, tbf)

svn-id: @1039

sysconfig/interfaces/ifcfg-description
sysconfig/network-scripts/ifdown-post
sysconfig/network-scripts/ifup-post

index 2baae17f3f874601f527b90f2330efe26f278767..6a4f959759419f7618a00becec848e286b2eb5f3 100644 (file)
@@ -1,4 +1,4 @@
-#      $Id: ifcfg-description,v 1.15 2002/07/13 16:25:06 misiek Exp $
+#      $Id: ifcfg-description,v 1.16 2002/08/22 13:21:22 misiek Exp $
 DEVICE=<name>
 [ BOOTPROTO={none|bootp|dhcp|pump} ]
   You can specify which dhcp client to use with the DHCP_CLIENT, if
@@ -46,7 +46,12 @@ fi
 [ MTU= ]
 [ METRIC= ]
 
-[ QDISC= ]
+QDISC=[sfq|teql0|red|prio|...] (queueing discipline)
+QDISC_CLASS=[htb|cbq|none]     (use cbq|htb as class based discipline;
+                                if none specified and bandwidth_out present
+                                then tbf is used)
+BANDWIDTH_IN=[upstream limit in kilobites, supported on 2.4 only]
+BANDWIDTH_OUT=[downstream limit in kilobites]
 
 [ DEFAULTHANDLING=yes|no ] (used in configuration for ATM interfaces,
                            obsolete variable)
index ef78ec66b4b07ea015ea79152647e477d9ec4670..c1320348a28ca3cec5ac693bbb69a8b7559a27ae 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#      $Id: ifdown-post,v 1.13 2002/05/11 09:50:53 misiek Exp $
+#      $Id: ifdown-post,v 1.14 2002/08/22 13:21:25 misiek Exp $
 #
 # This should be called whenever an interface goes down, not just when
 # it is brought down explicitly.
@@ -20,9 +20,23 @@ setup_ip_param
 # set REALDEVICE
 get_ppp_device_and_pid
 
-# Delete root queueing discipline
-if [ -n "$QDISC" ]; then
-       tc qdisc del dev "$REALDEVICE" root $QDISC
+# (QoS) Delete root queueing discipline
+if [ -n "${BANDWIDTH_OUT}" ]; then
+    if [ "${QDISC_CLASS}" = "htb" -o "${QDISC_CLASS}" = "cbq" ]; then
+       tc qdisc del dev ${REALDEVICE} root
+    elif [ -z "${QDISC}" -o "${QDISC}" = "tbf" ]; then
+       tc qdisc del dev ${REALDEVICE} root
+    elif [ -n "${QDISC}" ]; then
+       tc qdisc del dev ${REALDEVICE} root
+    fi
+else
+    if [ -n "${QDISC}" ]; then
+       tc qdisc add dev ${REALDEVICE} root
+    fi
+fi
+
+if [ -n "${BANDWIDTH_IN}" ]; then
+    tc qdisc del dev ${REALDEVICE} ingress
 fi
 
 # execute run_down() function (if available in device configuration file)
index ea164561fb6e8bbb397650bbed64f36e17faaa76..778ceca816a459996431b8e23e16245e86348d2e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#      $Id: ifup-post,v 1.26 2002/08/11 17:05:09 misiek Exp $
+#      $Id: ifup-post,v 1.27 2002/08/22 13:21:25 misiek Exp $
 #
 
 run_up() { :; }
@@ -19,10 +19,37 @@ setup_ip_param
 # set REALDEVICE
 get_ppp_device_and_pid
 
-if [ -n "$QDISC" ]; then
-# Set the queuing discipline
-#    eg: sfq for better link sharing or teql0 for link equalizer
-       tc qdisc add dev "$REALDEVICE" root $QDISC
+# Simple QoS support (bandwidth limit)
+if [ -n "${BANDWIDTH_OUT}" ]; then
+    if [ "${QDISC_CLASS}" = "htb" -o "${QDISC_CLASS}" = "cbq" ]; then
+        case "${QDISC_CLASS}" in
+            htb)
+                tc qdisc add dev ${REALDEVICE} root handle 1: htb default 10
+                tc class add dev ${REALDEVICE} parent 1: classid 1:10 htb rate ${BANDWIDTH_OUT}kbit ceil ${BANDWIDTH_OUT}kbit
+                [ -n "${QDISC}" ] && tc qdisc add dev ${REALDEVICE} parent 1:10 ${QDISC}
+                ;;
+            cbq)
+               # FIXME: hardcoded ethernet speed (bandwidth)
+                tc qdisc add dev ${REALDEVICE} root handle 1: cbq bandwidth 100000kbit cell 8 avpkt 1000 mpu 64
+                tc class add dev ${REALDEVICE} parent 1: classid 1:10 cbq bandwidth 100000kbit rate ${BANDWIDTH_OUT}kbit maxburst 5 avpkt 1000 allot 1514 bounded
+                [ -n "${QDISC}" ] && tc qdisc add dev ${REALDEVICE} parent 1:10 ${QDISC}
+               tc filter add dev ${REALDEVICE} protocol ip parent 1: u32 match ip src 0.0.0.0/0 flowid 1:10
+                ;;
+        esac
+    elif [ -z "${QDISC}" -o "${QDISC}" = "tbf" ]; then
+       tc qdisc add dev ${REALDEVICE} root tbf rate ${BANDWIDTH_OUT}kbit latency 50ms burst 51200
+    elif [ -n "${QDISC}" ]; then
+       tc qdisc add dev ${REALDEVICE} root ${QDISC}
+    fi
+else
+    if [ -n "${QDISC}" ]; then
+       tc qdisc add dev ${REALDEVICE} root ${QDISC}
+    fi
+fi
+
+if [ -n "${BANDWIDTH_IN}" ]; then
+    tc qdisc add dev ${REALDEVICE} handle ffff: ingress
+    tc filter add dev ${REALDEVICE} parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate ${BANDWIDTH_IN}kbit burst 10k drop flowid :3
 fi
 
 /etc/sysconfig/network-scripts/ifup-aliases ${CONFIG}
This page took 0.042345 seconds and 4 git commands to generate.