From b877ab2750050fd90368c4d7fc8b7dae11f4236d Mon Sep 17 00:00:00 2001 From: jow Date: Fri, 14 Oct 2011 12:35:19 +0000 Subject: [PATCH] [PATCH] Wondershaper uci config and modules fix Hi, this patch adds uci config style for wshaper and also fixes a small problem with the loaded modules (act_police needs to be loaded). Signed-off-by: Manuel Munz git-svn-id: svn://svn.openwrt.org/openwrt/packages@28454 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/wshaper/Makefile | 3 ++- net/wshaper/files/wshaper.config | 4 ++++ net/wshaper/files/wshaper.htb | 31 +++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 net/wshaper/files/wshaper.config diff --git a/net/wshaper/Makefile b/net/wshaper/Makefile index 987086bd4..5ea1bc92a 100644 --- a/net/wshaper/Makefile +++ b/net/wshaper/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wshaper -PKG_VERSION:=0.1 +PKG_VERSION:=0.2 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -44,6 +44,7 @@ define Package/wshaper/install $(INSTALL_DIR) $(1)/usr/sbin/ $(1)/etc/init.d $(INSTALL_BIN) ./files/wshaper.htb $(1)/usr/sbin/ $(INSTALL_BIN) ./files/wshaper.init $(1)/etc/init.d/wshaper + $(INSTALL_DATA) ./files/wshaper.config $(1)/etc/config/wshaper endef $(eval $(call BuildPackage,wshaper)) diff --git a/net/wshaper/files/wshaper.config b/net/wshaper/files/wshaper.config new file mode 100644 index 000000000..ed857c529 --- /dev/null +++ b/net/wshaper/files/wshaper.config @@ -0,0 +1,4 @@ +config 'wshaper' 'settings' + option 'network' 'wan' + option 'downlink' '2000' + option 'uplink' '240' diff --git a/net/wshaper/files/wshaper.htb b/net/wshaper/files/wshaper.htb index d912f4dca..96f29cc46 100755 --- a/net/wshaper/files/wshaper.htb +++ b/net/wshaper/files/wshaper.htb @@ -5,23 +5,36 @@ # Set the following values to somewhat less than your actual download # and uplink speed. In kilobits. Also set the device that is to be shaped. -MODULES='sch_ingress sch_sfq sch_htb cls_u32' -DOWNLINK=2000 -UPLINK=240 -DEV=eth0 +# All config needs to be done in /etc/config/wshaper + +. /etc/functions.sh +config_load wshaper +for s in downlink uplink network nopriohostdst nopriohostsrc noprioportdst noprioportsrc; do + config_get $s settings $s +done + +device=$(uci_get_state network "$network" device) +[ -z "$device" ] && logger -t wondershaper "Error: Could not find the device for network $network, aborting." && exit 1 +[ -z "$downlink" ] && logger -t wondershaper "Error: Downlink speed not set, aborting." && exit 1 +[ -z "$uplink" ] && logger -t wondershaper "Error: Uplink speed not set, aborting." && exit 1 + +MODULES='sch_ingress sch_sfq sch_htb cls_u32 act_police' +DOWNLINK="$downlink" +UPLINK="$uplink" +DEV="$device" # low priority OUTGOING traffic - you can leave this blank if you want # low priority source netmasks -NOPRIOHOSTSRC= +NOPRIOHOSTSRC="$nopriohostsrc" # low priority destination netmasks -NOPRIOHOSTDST= +NOPRIOHOSTDST="$nopriohostdst" # low priority source ports -NOPRIOPORTSRC= +NOPRIOPORTSRC="$noprioportsrc" # low priority destination ports -NOPRIOPORTDST="21" +NOPRIOPORTDST="$noprioportdst" if [ "$1" = "status" ] then @@ -144,3 +157,5 @@ tc qdisc add dev $DEV handle ffff: ingress tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \ 0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1 + +logger -t wondershaper "Wondershaper was started on device $device."