From 3d0078f8801e3a3e63c0c1482b141119fba33b8a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 14 Oct 2011 12:41:15 +0000 Subject: [PATCH] [backfire/packages] merge r28454 SVN-Revision: 28455 --- 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 987086bd4d..5ea1bc92a9 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 0000000000..ed857c5294 --- /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 d912f4dcaf..96f29cc469 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." -- 2.30.2