From 4f7c745d2549fa4cc942eaa5897ee8dee7bf87ed Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 11 Sep 2005 11:10:40 +0000 Subject: [PATCH] add wondershaper package from leh. thx SVN-Revision: 1899 --- openwrt/package/Config.in | 1 + openwrt/package/Makefile | 1 + openwrt/package/wondershaper/Config.in | 8 + openwrt/package/wondershaper/Makefile | 35 +++ .../wondershaper/ipkg/wondershaper.control | 7 + .../patches/wondershaper-OpenWrt.patch | 280 ++++++++++++++++++ 6 files changed, 332 insertions(+) create mode 100644 openwrt/package/wondershaper/Config.in create mode 100644 openwrt/package/wondershaper/Makefile create mode 100644 openwrt/package/wondershaper/ipkg/wondershaper.control create mode 100644 openwrt/package/wondershaper/patches/wondershaper-OpenWrt.patch diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in index 905fca2def..fe2c82b91a 100644 --- a/openwrt/package/Config.in +++ b/openwrt/package/Config.in @@ -115,6 +115,7 @@ source "package/wput/Config.in" source "package/xinetd/Config.in" source "package/wificonf/Config.in" source "package/wiviz/Config.in" +source "package/wondershaper/Config.in" comment "Libraries" source "package/cgilib/Config.in" diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile index 86a84a4755..8515787076 100644 --- a/openwrt/package/Makefile +++ b/openwrt/package/Makefile @@ -168,6 +168,7 @@ package-$(BR2_PACKAGE_WIFICONF) += wificonf package-$(BR2_PACKAGE_WIVIZ) += wiviz package-$(BR2_PACKAGE_WIRELESS_TOOLS) += wireless-tools package-$(BR2_PACKAGE_WOL) += wol +package-$(BR2_PACKAGE_WONDERSHAPER) += wondershaper package-$(BR2_PACKAGE_WPA_SUPPLICANT) += wpa_supplicant package-$(BR2_PACKAGE_WPUT) += wput package-$(BR2_PACKAGE_XINETD) += xinetd diff --git a/openwrt/package/wondershaper/Config.in b/openwrt/package/wondershaper/Config.in new file mode 100644 index 0000000000..020b92b919 --- /dev/null +++ b/openwrt/package/wondershaper/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_WONDERSHAPER + tristate "WonderShaper - The Wonder Shaper" + default m if CONFIG_DEVEL + select BR2_PACKAGE_IPROUTE2_TC + help + WonderShaper is a tc based traffic shaping tool. + + Depends: tc diff --git a/openwrt/package/wondershaper/Makefile b/openwrt/package/wondershaper/Makefile new file mode 100644 index 0000000000..b4cea59777 --- /dev/null +++ b/openwrt/package/wondershaper/Makefile @@ -0,0 +1,35 @@ +# $Id$ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=wondershaper +PKG_VERSION:=1.1a +PKG_RELEASE:=1 +PKG_MD5SUM:=bbc5a3a4485ab286e337ce8550e7b990 + +PKG_SOURCE_URL:=http://lartc.org/wondershaper/ +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_CAT:=zcat + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install + +include $(TOPDIR)/package/rules.mk + +$(eval $(call PKG_template,WONDERSHAPER,wondershaper,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH))) + +$(PKG_BUILD_DIR)/.configured: + touch $@ + +$(PKG_BUILD_DIR)/.built: + mkdir -p $(PKG_INSTALL_DIR) + touch $@ + +$(IPKG_WONDERSHAPER): + install -d -m0755 $(IDIR_WONDERSHAPER)/usr/sbin + install -d -m0755 $(IDIR_WONDERSHAPER)/etc/init.d + cp -fpR $(PKG_BUILD_DIR)/wshaper.htb $(IDIR_WONDERSHAPER)/usr/sbin/wshaper + cp -fpR $(PKG_BUILD_DIR)/wshaper.conf $(IDIR_WONDERSHAPER)/etc/wshaper.conf + ln -s /usr/sbin/wshaper $(IDIR_WONDERSHAPER)/etc/init.d/S60wondershaper + $(IPKG_BUILD) $(IDIR_WONDERSHAPER) $(PACKAGE_DIR) + diff --git a/openwrt/package/wondershaper/ipkg/wondershaper.control b/openwrt/package/wondershaper/ipkg/wondershaper.control new file mode 100644 index 0000000000..c60a2370cf --- /dev/null +++ b/openwrt/package/wondershaper/ipkg/wondershaper.control @@ -0,0 +1,7 @@ +Package: wondershaper +Priority: optional +Section: net +Maintainer: Daniel Lehmann +Source: buildroot internal +Depends: tc +Description: WonderShaper is a tc based traffic shaping tool. diff --git a/openwrt/package/wondershaper/patches/wondershaper-OpenWrt.patch b/openwrt/package/wondershaper/patches/wondershaper-OpenWrt.patch new file mode 100644 index 0000000000..a748a4b551 --- /dev/null +++ b/openwrt/package/wondershaper/patches/wondershaper-OpenWrt.patch @@ -0,0 +1,280 @@ +diff -Nur wondershaper-1.1a/wshaper wondershaper-1.1a_openwrt/wshaper +--- wondershaper-1.1a/wshaper 2002-04-16 16:26:35.000000000 +0200 ++++ wondershaper-1.1a_openwrt/wshaper 2005-09-09 00:46:22.095406568 +0200 +@@ -1,33 +1,7 @@ +-#!/bin/bash +- ++#!/bin/sh + # Wonder Shaper +-# please read the README before filling out these values +-# +-# 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. +-DOWNLINK=800 +-UPLINK=220 +-DEV=eth0 +- +-# low priority OUTGOING traffic - you can leave this blank if you want +-# low priority source netmasks +-NOPRIOHOSTSRC=80 +- +-# low priority destination netmasks +-NOPRIOHOSTDST= +- +-# low priority source ports +-NOPRIOPORTSRC= +- +-# low priority destination ports +-NOPRIOPORTDST= +- +-# Now remove the following two lines :-) +- +-echo Please read the documentation in 'README' first :-\) +-exit +- +-######################################################### ++. /etc/functions.sh ++. /etc/wshaper.conf + + if [ "$1" = "status" ] + then +@@ -46,6 +20,8 @@ + exit + fi + ++ ++ + ###### uplink + + # install root CBQ +@@ -67,12 +43,12 @@ + # bulk and default class 1:20 - gets slightly less traffic, + # and a lower priority: + +-tc class add dev $DEV parent 1:1 classid 1:20 cbq rate $[9*$UPLINK/10]kbit \ ++tc class add dev $DEV parent 1:1 classid 1:20 cbq rate $((9*$UPLINK/10))kbit \ + allot 1600 prio 2 avpkt 1000 + + # 'traffic we hate' + +-tc class add dev $DEV parent 1:1 classid 1:30 cbq rate $[8*$UPLINK/10]kbit \ ++tc class add dev $DEV parent 1:1 classid 1:30 cbq rate $((8*$UPLINK/10))kbit \ + allot 1600 prio 2 avpkt 1000 + + # all get Stochastic Fairness: +diff -Nur wondershaper-1.1a/wshaper.conf wondershaper-1.1a_openwrt/wshaper.conf +--- wondershaper-1.1a/wshaper.conf 1970-01-01 01:00:00.000000000 +0100 ++++ wondershaper-1.1a_openwrt/wshaper.conf 2005-09-09 00:31:54.239340744 +0200 +@@ -0,0 +1,27 @@ ++# Wonder Shaper ++# please read the README before filling out these values ++# ++# Set the following values to somewhat less than your actual download ++# and uplink speed. In kilobits. ++DOWNLINK=1000 ++UPLINK=220 ++ ++# low priority OUTGOING traffic - you can leave this blank if you want ++# low priority source netmasks ++NOPRIOHOSTSRC=80 ++ ++# low priority destination netmasks ++NOPRIOHOSTDST= ++ ++# low priority source ports ++NOPRIOPORTSRC= ++ ++# low priority destination ports ++NOPRIOPORTDST= ++ ++# WAN device ++DEV=$(nvram get wan_ifname) ++ ++# tc location ++TC=/usr/sbin/tc ++ +diff -Nur wondershaper-1.1a/wshaper.htb wondershaper-1.1a_openwrt/wshaper.htb +--- wondershaper-1.1a/wshaper.htb 2002-04-16 16:26:51.000000000 +0200 ++++ wondershaper-1.1a_openwrt/wshaper.htb 2005-09-11 12:03:39.756950000 +0200 +@@ -1,44 +1,22 @@ +-#!/bin/bash ++#!/bin/ash + # Wonder Shaper +-# please read the README before filling out these values +-# +-# 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. +- +-DOWNLINK=800 +-UPLINK=220 +-DEV=ppp0 +- +-# low priority OUTGOING traffic - you can leave this blank if you want +-# low priority source netmasks +-NOPRIOHOSTSRC= +- +-# low priority destination netmasks +-NOPRIOHOSTDST= ++. /etc/functions.sh ++. /etc/wshaper.conf + +-# low priority source ports +-NOPRIOPORTSRC= + +-# low priority destination ports +-NOPRIOPORTDST= +- +- +-# Now remove the following two lines :-) +- +-echo Please read the documentation in 'README' first +-exit ++# do the magic + + if [ "$1" = "status" ] + then +- tc -s qdisc ls dev $DEV +- tc -s class ls dev $DEV ++ $TC -s qdisc ls dev $DEV ++ $TC -s class ls dev $DEV + exit + fi + + + # clean existing down- and uplink qdiscs, hide errors +-tc qdisc del dev $DEV root 2> /dev/null > /dev/null +-tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null ++$TC qdisc del dev $DEV root 2> /dev/null > /dev/null ++$TC qdisc del dev $DEV ingress 2> /dev/null > /dev/null + + if [ "$1" = "stop" ] + then +@@ -46,50 +24,65 @@ + fi + + ++# wondershaper must be executed everytime an interface comes up ++# if we have dynamic interface ppp0 add wondershaper to ip-up ++if [ $DEV = "ppp0" ] && ! grep -q wshaper /etc/ppp/ip-up ++then ++ echo "/usr/sbin/wshaper" >> /etc/ppp/ip-up ++fi ++ ++ ++ ++# load the needed kernel modules ++for module in sch_prio sch_htb sch_sfq sch_ingress cls_tcindex cls_fw cls_route cls_u32 ++do ++ insmod $module 2> /dev/null > /dev/null ++done ++ + ###### uplink + + # install root HTB, point default traffic to 1:20: + +-tc qdisc add dev $DEV root handle 1: htb default 20 ++$TC qdisc add dev $DEV root handle 1: htb default 20 + + # shape everything at $UPLINK speed - this prevents huge queues in your + # DSL modem which destroy latency: + +-tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k ++$TC class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k + + # high prio class 1:10: + +-tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \ ++$TC class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \ + burst 6k prio 1 + + # bulk & default class 1:20 - gets slightly less traffic, + # and a lower priority: + +-tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[9*$UPLINK/10]kbit \ ++$TC class add dev $DEV parent 1:1 classid 1:20 htb rate $((9*$UPLINK/10))kbit \ + burst 6k prio 2 + +-tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[8*$UPLINK/10]kbit \ ++$TC class add dev $DEV parent 1:1 classid 1:30 htb rate $((8*$UPLINK/10))kbit \ + burst 6k prio 2 + + # all get Stochastic Fairness: +-tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 +-tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 +-tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10 ++$TC qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 ++$TC qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 ++$TC qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10 + + # TOS Minimum Delay (ssh, NOT scp) in 1:10: + +-tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \ ++$TC filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \ + match ip tos 0x10 0xff flowid 1:10 + + # ICMP (ip protocol 1) in the interactive class 1:10 so we + # can do measurements & impress our friends: +-tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \ ++$TC filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \ + match ip protocol 1 0xff flowid 1:10 + + # To speed up downloads while an upload is going on, put ACK packets in + # the interactive class: + +-tc filter add dev $DEV parent 1: protocol ip prio 10 u32 \ ++$TC filter add dev $DEV parent 1: protocol ip prio 10 u32 \ + match ip protocol 6 0xff \ + match u8 0x05 0x0f at 0 \ + match u16 0x0000 0xffc0 at 2 \ +@@ -101,31 +94,31 @@ + # some traffic however suffers a worse fate + for a in $NOPRIOPORTDST + do +- tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \ ++ $TC filter add dev $DEV parent 1: protocol ip prio 14 u32 \ + match ip dport $a 0xffff flowid 1:30 + done + + for a in $NOPRIOPORTSRC + do +- tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \ ++ $TC filter add dev $DEV parent 1: protocol ip prio 15 u32 \ + match ip sport $a 0xffff flowid 1:30 + done + + for a in $NOPRIOHOSTSRC + do +- tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \ ++ $TC filter add dev $DEV parent 1: protocol ip prio 16 u32 \ + match ip src $a flowid 1:30 + done + + for a in $NOPRIOHOSTDST + do +- tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \ ++ $TC filter add dev $DEV parent 1: protocol ip prio 17 u32 \ + match ip dst $a flowid 1:30 + done + + # rest is 'non-interactive' ie 'bulk' and ends up in 1:20 + +-tc filter add dev $DEV parent 1: protocol ip prio 18 u32 \ ++$TC filter add dev $DEV parent 1: protocol ip prio 18 u32 \ + match ip dst 0.0.0.0/0 flowid 1:20 + + +@@ -136,12 +129,12 @@ + # + # attach ingress policer: + +-tc qdisc add dev $DEV handle ffff: ingress ++$TC qdisc add dev $DEV handle ffff: ingress + + # filter *everything* to it (0.0.0.0/0), drop everything that's + # coming in too fast: + +-tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \ ++$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 + + -- 2.25.1