Enable ECN for egress if class bandwith is larger than 3 Mbit/s

This commit is contained in:
hk 2017-01-13 08:32:09 +01:00
parent bf64a15ea5
commit 46a4125980
1 changed files with 14 additions and 3 deletions

View File

@ -158,6 +158,17 @@ get_fq_codel_quantum () {
fi fi
} }
get_ecn () {
# Takes input rate in mbit/s as parameter
local RATE=$1
if [[ ${RATE} -gt 3 ]]; then
echo "ecn"
else
echo "noecn"
fi
}
get_mtu () { get_mtu () {
# Takes interface as parameter # Takes interface as parameter
cat /sys/class/net/${1}/mtu cat /sys/class/net/${1}/mtu
@ -266,7 +277,7 @@ apply_egress_shaping () {
limit $(get_limit ${CEIL_RATE}) \ limit $(get_limit ${CEIL_RATE}) \
target $(get_target ${CEIL_RATE} $(get_mtu ${IF_NAME})) \ target $(get_target ${CEIL_RATE} $(get_mtu ${IF_NAME})) \
$(get_fq_codel_quantum ${CEIL_RATE}) \ $(get_fq_codel_quantum ${CEIL_RATE}) \
noecn $(get_ecn ${CEIL_RATE})
${TC} filter add dev ${IF_NAME} parent 1: protocol all \ ${TC} filter add dev ${IF_NAME} parent 1: protocol all \
handle ${FWMARK} fw classid 1:${CLASS_ID} handle ${FWMARK} fw classid 1:${CLASS_ID}
@ -278,12 +289,12 @@ apply_egress_shaping () {
ceil ${UP_RATE}mbit prio ${DEFAULT_PRIO} \ ceil ${UP_RATE}mbit prio ${DEFAULT_PRIO} \
quantum $(get_htb_quantum ${UP_RATE}) quantum $(get_htb_quantum ${UP_RATE})
# Set qdisc to fq_codel. Disabling ECN is recommended for egress # Set qdisc to fq_codel
${TC} qdisc replace dev ${IF_NAME} parent 1:99 handle 99: fq_codel \ ${TC} qdisc replace dev ${IF_NAME} parent 1:99 handle 99: fq_codel \
limit $(get_limit ${UP_RATE}) \ limit $(get_limit ${UP_RATE}) \
target $(get_target ${UP_RATE} $(get_mtu ${IF_NAME})) \ target $(get_target ${UP_RATE} $(get_mtu ${IF_NAME})) \
$(get_fq_codel_quantum ${UP_RATE}) \ $(get_fq_codel_quantum ${UP_RATE}) \
noecn $(get_ecn ${UP_RATE})
} }
apply_ingress_shaping () { apply_ingress_shaping () {