From 1f9238ed3ffa3a41e2c06c0c5f43742c6ed78334 Mon Sep 17 00:00:00 2001 From: Dave Taht Date: Thu, 19 Feb 2015 14:03:59 -0800 Subject: [PATCH] sqm-scripts: Support the cake qdisc. Signed-off-by: Dave Taht --- net/sqm-scripts/Makefile | 2 +- net/sqm-scripts/files/usr/lib/sqm/simple.qos | 25 ++++++++++++++++--- .../files/usr/lib/sqm/simplest.qos | 10 ++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/net/sqm-scripts/Makefile b/net/sqm-scripts/Makefile index 68a599063e..daf8f5d38a 100644 --- a/net/sqm-scripts/Makefile +++ b/net/sqm-scripts/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sqm-scripts PKG_VERSION:=8 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_LICENSE:=GPLv2 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/net/sqm-scripts/files/usr/lib/sqm/simple.qos b/net/sqm-scripts/files/usr/lib/sqm/simple.qos index 6e5af4a941..34a4dd8bd9 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/simple.qos +++ b/net/sqm-scripts/files/usr/lib/sqm/simple.qos @@ -25,13 +25,17 @@ ipt_setup() { ipt -t mangle -N QOS_MARK_${IFACE} -ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING} +case $QDISC in + cake*) sqm_logger cake does all the diffserv work - no need for iptables rules ;; + *) +ipt -t mangle -A QOS_MARK_${IFACE} -j MARK --set-mark 0x2${IPT_MASK_STRING} # You can go further with classification but... ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS1 -j MARK --set-mark 0x3${IPT_MASK_STRING} ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class CS6 -j MARK --set-mark 0x1${IPT_MASK_STRING} ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class EF -j MARK --set-mark 0x1${IPT_MASK_STRING} ipt -t mangle -A QOS_MARK_${IFACE} -m dscp --dscp-class AF42 -j MARK --set-mark 0x1${IPT_MASK_STRING} ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-mark 0x1${IPT_MASK_STRING} +esac # and it might be a good idea to do it for udp tunnels too @@ -43,9 +47,11 @@ ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-ma if [ "$SQUASH_DSCP" = "1" ] then sqm_logger "Squashing differentiated services code points (DSCP) from ingress." +CAKE_OPTS=besteffort # someday squash ipt -t mangle -I PREROUTING -i $IFACE -m dscp ! --dscp 0 -j DSCP --set-dscp-class be else sqm_logger "Keeping differentiated services code points (DSCP) from ingress." +CAKE_OPTS="" ipt -t mangle -A PREROUTING -i $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE} fi @@ -81,6 +87,9 @@ BE_CEIL=`expr $CEIL - 16` # A little slop at the top LQ="quantum `get_mtu $IFACE $CEIL`" $TC qdisc del dev $IFACE root 2> /dev/null +case $QDISC in + cake*) $TC qdisc add dev $IFACE root $QDISC bandwidth ${CEIL}kbit ;; + *) $TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 12 $TC class add dev $IFACE parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string` $TC class add dev $IFACE parent 1:1 classid 1:10 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit prio 0 `get_htb_adsll_string` @@ -92,7 +101,6 @@ $TC qdisc add dev $IFACE parent 1:11 handle 110: $QDISC `get_limit ${ELIMIT}` `g $TC qdisc add dev $IFACE parent 1:12 handle 120: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BE_RATE}` ${EQDISC_OPTS} $TC qdisc add dev $IFACE parent 1:13 handle 130: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${EQDISC_OPTS} - # Need a catchall rule $TC filter add dev $IFACE parent 1:0 protocol all prio 999 u32 \ @@ -122,6 +130,8 @@ $TC filter add dev $IFACE parent 1:0 protocol ip prio 8 \ $TC filter add dev $IFACE parent 1:0 protocol ipv6 prio 9 \ u32 match ip protocol 1 0xff flowid 1:13 +;; +esac #diffserv $IFACE @@ -146,14 +156,21 @@ if [ "$SQUASH_INGRESS" = "1" ] then sqm_logger "Do not perform DSCP based filtering on ingress. (1-tier classification)" # Revert to no dscp based filtering -$TC qdisc del dev $DEV root 2>/dev/null +case $QDISC in + cake*) $TC qdisc add dev $DEV root $QDISC bandwidth ${DOWNLINK}kbit besteffort ;; + *) $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10 $TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string` $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit prio 0 `get_htb_adsll_string` $TC qdisc add dev $DEV parent 1:10 handle 110: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_flows ${DOWNLINK}` ${IQDISC_OPTS} +;; +esac else sqm_logger "Perform DSCP based filtering on ingress. (3-tier classification)" +case $QDISC in + cake*) $TC qdisc add dev $IFACE root $QDISC bandwidth ${DOWNLINK}kbit $CAKE_OPTS;; + *) $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 12 $TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit `get_htb_adsll_string` $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ rate ${CEIL}kbit ceil ${CEIL}kbit prio 0 `get_htb_adsll_string` @@ -168,6 +185,8 @@ $TC qdisc add dev $DEV parent 1:12 handle 120: $QDISC `get_limit ${ILIMIT}` `get $TC qdisc add dev $DEV parent 1:13 handle 130: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${IQDISC_OPTS} diffserv $DEV +;; +esac fi diff --git a/net/sqm-scripts/files/usr/lib/sqm/simplest.qos b/net/sqm-scripts/files/usr/lib/sqm/simplest.qos index f06c25211e..e0cff2afe1 100755 --- a/net/sqm-scripts/files/usr/lib/sqm/simplest.qos +++ b/net/sqm-scripts/files/usr/lib/sqm/simplest.qos @@ -17,10 +17,15 @@ egress() { LQ="quantum `get_mtu $IFACE ${UPLINK}`" $TC qdisc del dev $IFACE root 2>/dev/null +case $QDISC in + cake*) $TC qdisc add dev $IFACE root cake bandwidth ${UPLINK}kbit besteffort ;; + *) $TC qdisc add dev $IFACE root handle 1: `get_stab_string` htb default 10 $TC class add dev $IFACE parent 1: classid 1:1 htb $LQ rate ${UPLINK}kbit ceil ${UPLINK}kbit `get_htb_adsll_string` $TC class add dev $IFACE parent 1:1 classid 1:10 htb $LQ rate ${UPLINK}kbit ceil ${UPLINK}kbit prio 0 `get_htb_adsll_string` $TC qdisc add dev $IFACE parent 1:10 handle 110: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_flows ${UPLINK}` ${EQDISC_OPTS} +;; +esac } @@ -33,6 +38,9 @@ $TC qdisc add dev $IFACE handle ffff: ingress LQ="quantum `get_mtu $IFACE ${DOWNLINK}`" $TC qdisc del dev $DEV root 2>/dev/null +case $QDISC in + cake*) $TC qdisc add dev $DEV root cake bandwidth ${DOWNLINK}kbit besteffort ;; + *) $TC qdisc add dev $DEV root handle 1: `get_stab_string` htb default 10 $TC class add dev $DEV parent 1: classid 1:1 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit `get_htb_adsll_string` $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ rate ${DOWNLINK}kbit ceil ${DOWNLINK}kbit prio 0 `get_htb_adsll_string` @@ -43,6 +51,8 @@ $TC class add dev $DEV parent 1:1 classid 1:10 htb $LQ rate ${DOWNLINK}kbit ceil # Most high rate flows are REALLY close. This stomps on those harder, but hurts on high rate long distance #$TC qdisc add dev $DEV parent 1:10 handle 110: $QDISC limit $LIMIT $ECN interval 20ms target 3ms `get_flows ${DOWNLINK}` $TC qdisc add dev $DEV parent 1:10 handle 110: $QDISC `get_limit ${ILIMIT}` `get_target "${ITARGET}" ${DOWNLINK}` `get_ecn ${IECN}` `get_flows ${DOWNLINK}` ${IQDISC_OPTS} +;; +esac ifconfig $DEV up -- 2.30.2