From: Felix Fietkau Date: Mon, 21 Feb 2011 01:33:27 +0000 (+0000) Subject: qos-scripts: drop the use of IMQ, use ifb and act_connmark instead X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=fca74c3a44ec734916a39e979e8f0286accbe7d0;p=openwrt%2Fstaging%2Frmilecki.git qos-scripts: drop the use of IMQ, use ifb and act_connmark instead SVN-Revision: 25640 --- diff --git a/package/qos-scripts/Makefile b/package/qos-scripts/Makefile index c999e7e6794..b721765ab0f 100644 --- a/package/qos-scripts/Makefile +++ b/package/qos-scripts/Makefile @@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk define Package/qos-scripts SECTION:=utils CATEGORY:=Base system - DEPENDS:=+tc +kmod-sched +iptables +iptables-mod-filter +iptables-mod-ipopt +iptables-mod-conntrack-extra +iptables-mod-imq + DEPENDS:=+tc +kmod-sched +iptables +iptables-mod-filter +iptables-mod-ipopt +iptables-mod-conntrack-extra TITLE:=QoS scripts PKGARCH:=all endef diff --git a/package/qos-scripts/files/usr/bin/qos-stat b/package/qos-scripts/files/usr/bin/qos-stat index d7858d7a11c..8a39df08470 100755 --- a/package/qos-scripts/files/usr/bin/qos-stat +++ b/package/qos-scripts/files/usr/bin/qos-stat @@ -33,26 +33,34 @@ print_comments() { echo '' } +get_device() { + ( config_load network; scan_interfaces; config_get "$1" ifname ) +} + interface_stats() { local interface="$1" local device - config_get device "$interface" device + device="$(get_device "$interface")" + [ -z "$device" ] && config_get device "$interface" device config_get_bool enabled "$interface" enabled 1 [ -z "$device" -o 1 -ne "$enabled" ] && { return 1 } - config_get_bool halfduplex "$interface" halfduplex + config_get_bool halfduplex "$interface" halfduplex 0 - [ 1 -ne "$halfduplex" ] && { + if [ 1 -ne "$halfduplex" ]; then unset halfduplex print_comments "$interface" "Egress" "Start" tc -s class show dev "$device" print_comments "$interface" "Egress" "End" - } + id="root" + else + id="" + fi print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start" - tc -s class show dev "$(iptables -v -L PREROUTING -t mangle | awk '/IMQ: todev .*$/ && $6 ~ /'$device'/ {print "imq"$12}')" + tc -s class show dev "$(tc filter show dev $device $id | grep mirred | sed -e 's,.*\(ifb.*\)).*,\1,')" print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End" } diff --git a/package/qos-scripts/files/usr/bin/qos-stop b/package/qos-scripts/files/usr/bin/qos-stop index 2275ea12dc6..d0243bea13c 100755 --- a/package/qos-scripts/files/usr/bin/qos-stop +++ b/package/qos-scripts/files/usr/bin/qos-stop @@ -1,6 +1,7 @@ #!/bin/sh -for iface in $(tc qdisc show | grep hfsc | awk '{print $5}'); do - tc qdisc del dev "$iface" root +for iface in $(tc qdisc show | grep -E '(hfsc|ingress)' | awk '{print $5}'); do + tc qdisc del dev "$iface" ingress 2>&- >&- + tc qdisc del dev "$iface" root 2>&- >&- done iptables -t mangle -F iptables -t mangle -X diff --git a/package/qos-scripts/files/usr/lib/qos/generate.sh b/package/qos-scripts/files/usr/lib/qos/generate.sh index 6b5db3d7dc0..9bd3b47850c 100755 --- a/package/qos-scripts/files/usr/lib/qos/generate.sh +++ b/package/qos-scripts/files/usr/lib/qos/generate.sh @@ -210,7 +210,7 @@ config_cb() { config_get_bool enabled "$CONFIG_SECTION" enabled 1 [ 1 -eq "$enabled" ] || return 0 config_get classgroup "$CONFIG_SECTION" classgroup - config_set "$CONFIG_SECTION" imqdev "$C" + config_set "$CONFIG_SECTION" ifbdev "$C" C=$(($C+1)) append INTERFACES "$CONFIG_SECTION" config_set "$classgroup" enabled 1 @@ -274,7 +274,7 @@ tcrules() { start_interface() { local iface="$1" - local num_imq="$2" + local num_ifb="$2" config_get device "$iface" device config_get_bool enabled "$iface" enabled 1 [ -z "$device" -o 1 -ne "$enabled" ] && { @@ -298,10 +298,10 @@ start_interface() { prefix="cls" ;; down) - [ "$(ls -d /proc/sys/net/ipv4/conf/imq* 2>&- | wc -l)" -ne "$num_imq" ] && add_insmod imq numdevs="$num_imq" - config_get imqdev "$iface" imqdev + [ "$(ls -d /proc/sys/net/ipv4/conf/ifb* 2>&- | wc -l)" -ne "$num_ifb" ] && add_insmod ifb numifbs="$num_ifb" + config_get ifbdev "$iface" ifbdev [ "$overhead" = 1 ] && download=$(($download * 98 / 100 - (80 * 1024 / $download))) - dev="imq$imqdev" + dev="ifb$ifbdev" rate="$download" dl_mode=1 prefix="d_cls" @@ -326,6 +326,22 @@ tc qdisc del dev $dev root >&- 2>&- tc qdisc add dev $dev root handle 1: hfsc default ${class_default}0 tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${rate}kbit" done + [ -n "$download" ] && { + add_insmod cls_u32 + add_insmod em_u32 + add_insmod act_connmark + add_insmod act_mirred + add_insmod sch_ingress + } + if [ -n "$halfduplex" ]; then + export dev_up="tc qdisc del dev $device root >&- 2>&- +tc qdisc add dev $device root handle 1: hfsc +tc filter add dev $device parent 1: protocol ip prio 10 u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb$ifbdev" + elif [ -n "$download" ]; then + append dev_${dir} "tc qdisc del dev $device ingress >&- 2>&- +tc qdisc add dev $device ingress +tc filter add dev $device parent ffff: protocol ip prio 1 u32 match u32 0 0 flowid 1:1 action connmark action mirred egress redirect dev ifb$ifbdev" "$N" + fi add_insmod cls_fw add_insmod sch_hfsc add_insmod sch_sfq @@ -334,7 +350,7 @@ tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${r cat <