Add prio class support to IFB interface using -C

This commit is contained in:
hk 2018-02-01 01:26:42 +01:00
parent 4ae592d477
commit 0eb3e34ea0
1 changed files with 30 additions and 10 deletions

View File

@ -43,12 +43,11 @@ OPTIONS
ignored. ignored.
-c "<fwmark>:<rate>:<ceil>:<prio>,<fwmark2>:<rate2>:<ceil2>:<prio2>,..." -c "<fwmark>:<rate>:<ceil>:<prio>,<fwmark2>:<rate2>:<ceil2>:<prio2>,..."
Define extra leaf classes if you want to slice up and guarantee Define extra leaf classes if you want to slice up and guarantee
bandwith between different kinds of traffic using fw marks. The default bandwith between different kinds of traffic using fw marks on egress.
class has a priority of 4. If this is not set all the bandwith is The default class has a priority of 4. If this is not set all the
given to the default class which is sufficient for most use cases. bandwith is given to the default class which is sufficient for most
These classes are only used for egress shaping. use cases. If ceil is not set it will default to UP_RATE. If prio is
If ceil is not set it will default to UP_RATE. If prio is not not set, it will default to the same priority as the default class.
set, it will default to the same priority as the default class.
Example: Example:
-c "107:50::,109:1400k:7M:2" -c "107:50::,109:1400k:7M:2"
@ -59,6 +58,8 @@ OPTIONS
available in the root class and has the same priority as the default available in the root class and has the same priority as the default
class. The next leaf class has a fw mark of 109, a rate of 1400 kbit/s, class. The next leaf class has a fw mark of 109, a rate of 1400 kbit/s,
a ceil of 7 mbit/s and a priority of 2. a ceil of 7 mbit/s and a priority of 2.
-C "<fwmark>:<rate>:<ceil>:<prio>,<fwmark2>:<rate2>:<ceil2>:<prio2>,..."
Same as `-c` but for ingress on IFB interface.
-x -x
Clear all traffic control config on interface. Clear all traffic control config on interface.
-V -V
@ -265,7 +266,7 @@ add_prio_classes () {
[[ -n ${CONFIG[3]} ]] && PRIO=${CONFIG[3]} [[ -n ${CONFIG[3]} ]] && PRIO=${CONFIG[3]}
if [[ ${CEIL_RATE} -gt ${MAX_RATE} ]]; then if [[ ${CEIL_RATE} -gt ${MAX_RATE} ]]; then
echo "ERROR: ceiling value should not be larger than total max rate" >&2 echo "ERROR: ceiling value should not be larger than total max rate"
exit 1 exit 1
fi fi
@ -354,10 +355,21 @@ apply_ingress_shaping () {
${TC} class add dev ${IFB_IF_NAME} parent 1: classid 1:1 htb \ ${TC} class add dev ${IFB_IF_NAME} parent 1: classid 1:1 htb \
rate ${DOWN_RATE}kbit rate ${DOWN_RATE}kbit
local DEFAULT_RATE=${DOWN_RATE}
local DEFAULT_PRIO=4
if [[ -n ${IFB_CLASS_CONFIG} ]]; then
add_prio_classes \
${IFB_IF_NAME} \
"${IFB_CLASS_CONFIG}" \
${DOWN_RATE} \
${DEFAULT_PRIO}
fi
# Create class for the default priority # Create class for the default priority
${TC} class add dev ${IFB_IF_NAME} parent 1:1 classid 1:99 htb \ ${TC} class add dev ${IFB_IF_NAME} parent 1:1 classid 1:99 htb \
rate ${DOWN_RATE}kbit \ rate ${DEFAULT_RATE}kbit \
ceil ${DOWN_RATE}kbit prio 0 \ ceil ${DOWN_RATE}kbit prio ${DEFAULT_PRIO} \
quantum $(get_htb_quantum ${DOWN_RATE}) quantum $(get_htb_quantum ${DOWN_RATE})
# Set qdisc to fq_codel. Enabling ECN is recommended for ingress # Set qdisc to fq_codel. Enabling ECN is recommended for ingress
@ -424,7 +436,7 @@ convert_rate () {
} }
while getopts ":i:u:d:b:f:q:c:xV" OPT; do while getopts ":i:u:d:b:f:q:c:C:xV" OPT; do
case ${OPT} in case ${OPT} in
i) i)
IF_NAME="${OPTARG}" IF_NAME="${OPTARG}"
@ -444,6 +456,9 @@ while getopts ":i:u:d:b:f:q:c:xV" OPT; do
c) c)
CLASS_CONFIG="${OPTARG}" CLASS_CONFIG="${OPTARG}"
;; ;;
C)
IFB_CLASS_CONFIG="${OPTARG}"
;;
x) x)
CLEAR_CONFIG=1 CLEAR_CONFIG=1
;; ;;
@ -463,6 +478,11 @@ if [[ -z ${IF_NAME} ]]; then
exit 1 exit 1
fi fi
if [[ -n ${IFB_CLASS_CONFIG} && -z ${IFB_IF_NAME} ]]; then
>&2 echo "ERROR: you must define an IFB interface to use IFB priority classes"
exit 1
fi
if [[ -n ${CLEAR_CONFIG} ]]; then if [[ -n ${CLEAR_CONFIG} ]]; then
clear_all clear_all
echo "Config cleared" echo "Config cleared"