lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

test_WAN_triple-isolate__piece_of_cake.qos (2995B)


      1 #!/bin/sh
      2 ################################################################################
      3 # test_WAN_triple-isolate__piece_of_cake.qos (Cero3 Shaper)
      4 #
      5 # Abstract:
      6 # This is a one band cake and ipv6 enabled shaping script for Ethernet
      7 # gateways. This exists for the purpose of testing cake's different isolation
      8 # options, specifically the non-directional triple-isolate feature that promises
      9 # to finally tackle the bit-torrent hole in simple.qos.
     10 # This specific version is supposed to be used on WAN interfaces:
     11 # 	the script's ingress direction equals the internet/WAN download direction
     12 # 	the script's egress direction equals the internet/WAN upload direction
     13 #
     14 ################################################################################
     15 #
     16 # This program is free software; you can redistribute it and/or modify
     17 # it under the terms of the GNU General Public License version 2 as
     18 # published by the Free Software Foundation.
     19 #
     20 #  Copyright (C) 2012-2016
     21 #    Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
     22 #
     23 ################################################################################
     24 
     25 . ${SQM_LIB_DIR}/defaults.sh
     26 
     27 ################################################################################
     28 
     29 
     30 # this will only work with cake as qdisc...
     31 QDISC=cake
     32 
     33 
     34 # to keep this as simple as possible we ignore the *_CAKE_OPTS from defaults.sh
     35 INGRESS_CAKE_OPTS="besteffort triple-isolate"
     36 EGRESS_CAKE_OPTS="besteffort triple-isolate"
     37 
     38 
     39 egress() {
     40     sqm_debug "egress"
     41     $TC qdisc del dev $IFACE root 2>/dev/null
     42     $TC qdisc add dev $IFACE root $( get_stab_string ) cake bandwidth ${UPLINK}kbit $( get_cake_lla_string ) ${EGRESS_CAKE_OPTS} ${EQDISC_OPTS}
     43 }
     44 
     45 
     46 ingress() {
     47     sqm_debug "ingress"
     48     $TC qdisc del dev $IFACE handle ffff: ingress 2>/dev/null
     49     $TC qdisc add dev $IFACE handle ffff: ingress
     50     $TC qdisc del dev $DEV root 2>/dev/null
     51     $TC qdisc add dev $DEV root $( get_stab_string ) cake bandwidth ${DOWNLINK}kbit $( get_cake_lla_string ) ${INGRESS_CAKE_OPTS} ${IQDISC_OPTS}
     52 
     53     $IP link set dev $DEV up
     54 
     55     # redirect all IP packets arriving in $IFACE to ifb0
     56 
     57     $TC filter add dev $IFACE parent ffff: protocol all prio 10 u32 \
     58 	match u32 0 0 flowid 1:1 action mirred egress redirect dev $DEV
     59 }
     60 
     61 sqm_start() {
     62     [ -n "$IFACE" ] || return 1
     63     do_modules
     64     verify_qdisc $QDISC "cake" || return 1
     65     sqm_debug "Starting ${SCRIPT}"
     66 
     67     [ -z "$DEV" ] && DEV=$( get_ifb_for_if ${IFACE} )
     68 
     69 
     70     if [ "${UPLINK}" -ne 0 ];
     71     then
     72         egress
     73         sqm_debug "egress shaping activated"
     74     else
     75         sqm_debug "egress shaping deactivated"
     76         $TC qdisc del dev ${IFACE} root 2> /dev/null
     77     fi
     78     if [ "${DOWNLINK}" -ne 0 ];
     79     then
     80 	verify_qdisc ingress "ingress" || return 1
     81         ingress
     82         sqm_debug "ingress shaping activated"
     83     else
     84         sqm_debug "ingress shaping deactivated"
     85         $TC qdisc del dev ${DEV} root 2> /dev/null
     86         $TC qdisc del dev ${IFACE} ingress 2> /dev/null
     87     fi
     88     return 0
     89 }