[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 <freifunk@somakoma.de>


git-svn-id: svn://svn.openwrt.org/openwrt/packages@28454 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2011-10-14 12:35:19 +00:00
parent a29fc4a78b
commit b877ab2750
3 changed files with 29 additions and 9 deletions

View File

@ -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))

View File

@ -0,0 +1,4 @@
config 'wshaper' 'settings'
option 'network' 'wan'
option 'downlink' '2000'
option 'uplink' '240'

View File

@ -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."