From 7509a17ff4e4b3cf067204fc75bea40bf2a99ab6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Oct 2013 13:59:45 +0200 Subject: [PATCH] Add gluon-simple-tc package --- gluon/gluon-simple-tc/Makefile | 36 +++++++++++++++++++ .../files/etc/config/gluon-simple-tc | 7 ++++ .../etc/hotplug.d/net/50-gluon-simple-tc | 30 ++++++++++++++++ .../etc/modules-boot.d/30-gluon-simple-tc | 1 + .../files/etc/modules.d/30-gluon-simple-tc | 4 +++ 5 files changed, 78 insertions(+) create mode 100644 gluon/gluon-simple-tc/Makefile create mode 100644 gluon/gluon-simple-tc/files/etc/config/gluon-simple-tc create mode 100644 gluon/gluon-simple-tc/files/etc/hotplug.d/net/50-gluon-simple-tc create mode 120000 gluon/gluon-simple-tc/files/etc/modules-boot.d/30-gluon-simple-tc create mode 100644 gluon/gluon-simple-tc/files/etc/modules.d/30-gluon-simple-tc diff --git a/gluon/gluon-simple-tc/Makefile b/gluon/gluon-simple-tc/Makefile new file mode 100644 index 0000000..c496682 --- /dev/null +++ b/gluon/gluon-simple-tc/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-simple-tc +PKG_VERSION:=1 +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/gluon-simple-tc + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Bandwidth limit support + DEPENDS:=+gluon-core +tc +kmod-sched +endef + +define Package/gluon-simple-tc/description + Gluon community wifi mesh firmware framework: tc support +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/gluon-simple-tc/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,gluon-simple-tc)) diff --git a/gluon/gluon-simple-tc/files/etc/config/gluon-simple-tc b/gluon/gluon-simple-tc/files/etc/config/gluon-simple-tc new file mode 100644 index 0000000..b24df11 --- /dev/null +++ b/gluon/gluon-simple-tc/files/etc/config/gluon-simple-tc @@ -0,0 +1,7 @@ +# Example config + +config interface 'example' + option enabled '0' + option ifname 'eth0' + option limit_egress '1000' # 1000 Kbit/s + option limit_ingress '5000' # 5000 Kbit/s \ No newline at end of file diff --git a/gluon/gluon-simple-tc/files/etc/hotplug.d/net/50-gluon-simple-tc b/gluon/gluon-simple-tc/files/etc/hotplug.d/net/50-gluon-simple-tc new file mode 100644 index 0000000..e5ea8f7 --- /dev/null +++ b/gluon/gluon-simple-tc/files/etc/hotplug.d/net/50-gluon-simple-tc @@ -0,0 +1,30 @@ +[ "$ACTION" = 'add' ] || exit 0 + +config_load gluon-simple-tc + + +tc_interface() { + local iface="$1" + + config_get ifname "$iface" ifname + + [ "$INTERFACE" = "$ifname" ] || return + + config_get_bool enabled "$iface" enabled 0 + + [ "$enabled" -eq 1 ] || return + + config_get limit_egress "$iface" limit_egress + config_get limit_ingress "$iface" limit_ingress + + if [ "$limit_egress" ]; then + tc qdisc add dev "$INTERFACE" root tbf rate "${limit_egress}kbit" latency 50ms burst 2k + fi + + if [ "$limit_ingress" ]; then + tc qdisc add dev "$INTERFACE" handle ffff: ingress + tc filter add dev "$INTERFACE" parent ffff: u32 match u8 00 00 at 0 police rate "${limit_ingress}kbit" burst 10k drop flowid :1 + fi +} + +config_foreach tc_interface 'interface' diff --git a/gluon/gluon-simple-tc/files/etc/modules-boot.d/30-gluon-simple-tc b/gluon/gluon-simple-tc/files/etc/modules-boot.d/30-gluon-simple-tc new file mode 120000 index 0000000..44318d6 --- /dev/null +++ b/gluon/gluon-simple-tc/files/etc/modules-boot.d/30-gluon-simple-tc @@ -0,0 +1 @@ +../modules.d/30-gluon-simple-tc \ No newline at end of file diff --git a/gluon/gluon-simple-tc/files/etc/modules.d/30-gluon-simple-tc b/gluon/gluon-simple-tc/files/etc/modules.d/30-gluon-simple-tc new file mode 100644 index 0000000..87cb79f --- /dev/null +++ b/gluon/gluon-simple-tc/files/etc/modules.d/30-gluon-simple-tc @@ -0,0 +1,4 @@ +sch_ingress +sch_tbf +cls_u32 +act_police