2023-04-01 10:00:13 +08:00

86 lines
2.9 KiB
Plaintext

################################################################################
# simplest_tbf.qos (Simple TBF shaper)
#
# Abstract:
# This is a single band fq_codel and ipv6 enabled shaping script for Ethernet
# gateways. This is nearly the simplest possible. With FQ_CODEL, the sparseness
# priority will work pretty well for a casual network. Flow-hashes should not
# overlap much with only a few users.
#
# Uses TBF instead of HTB as that may give better performance on some
# architectures.
#
# References:
# This alternate shaper attempts to go for 1/u performance in a clever way
# http://git.coverfire.com/?p=linux-qos-scripts.git;a=blob;f=src-3tos.sh;hb=HEAD
#
################################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# Copyright (C) 2012-2017
# Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
#
################################################################################
. ${SQM_LIB_DIR}/defaults.sh
################################################################################
egress() {
MTU=$(get_mtu $IFACE)
BURST="$(get_burst ${MTU:-1514} ${UPLINK} ${ESHAPER_BURST_DUR_US})"
BURST=${BURST:-1514}
SILENT=1 $TC qdisc del dev $IFACE root
$TC qdisc add dev $IFACE root handle 1: $(get_stab_string) tbf \
rate ${UPLINK}kbit burst $BURST latency 300ms $(get_htb_adsll_string)
$TC qdisc add dev $IFACE parent 1: handle 110: $QDISC \
$(get_limit ${ELIMIT}) $(get_target "${ETARGET}" ${UPLINK}) \
$(get_ecn ${EECN}) $(get_flows ${UPLINK}) ${EQDISC_OPTS}
}
ingress() {
sqm_debug "ingress"
SILENT=1 $TC qdisc del dev $IFACE handle ffff: ingress
$TC qdisc add dev $IFACE handle ffff: ingress
MTU=$(get_mtu $IFACE)
BURST="$(get_burst ${MTU:-1514} ${DOWNLINK} ${ISHAPER_BURST_DUR_US})"
BURST=${BURST:-1514}
SILENT=1 $TC qdisc del dev $DEV root
$TC qdisc add dev $DEV root handle 1: $(get_stab_string) tbf \
rate ${DOWNLINK}kbit burst $BURST latency 300ms $(get_htb_adsll_string)
$TC qdisc add dev $DEV parent 1: handle 110: $QDISC \
$(get_limit ${ILIMIT}) $(get_target "${ITARGET}" ${DOWNLINK}) \
$(get_ecn ${IECN}) $(get_flows ${DOWNLINK}) ${IQDISC_OPTS}
$IP link set dev $DEV up
# redirect all IP packets arriving in $IFACE to ifb0
$TC filter add dev $IFACE parent ffff: protocol all prio 10 u32 \
match u32 0 0 flowid 1:1 action mirred egress redirect dev $DEV
}
sqm_prepare_script() {
do_modules
verify_qdisc "tbf" || return 1
case $QDISC in
cake*)
sqm_warn "Cake is not supported with this script; falling back to FQ-CoDel"
QDISC=fq_codel ;;
esac
}
################################################################################