|
@@ -6,19 +6,14 @@
|
|
|
|
|
|
#improve the logread output, but allow silencing it, if verbosity is set to 0
|
|
|
sqm_logger() {
|
|
|
- local CUR_VERBOSITY=""
|
|
|
- [ -z "$2" ] && REQUESTED_LOG_LEVEL=${VERBOSITY_NORMAL} || REQUESTED_LOG_LEVEL=${2}
|
|
|
-
|
|
|
if [ "$SQM_VERBOSITY" -gt "$VERBOSITY_SILENT" ] ; then
|
|
|
- if [ "${SQM_VERBOSITY}" -ge "${REQUESTED_LOG_LEVEL}" ] ; then
|
|
|
- if [ "$SQM_SYSLOG" -eq "1" ]; then
|
|
|
- logger -t SQM -s "$*"
|
|
|
- else
|
|
|
- echo "$@" >&2
|
|
|
- fi
|
|
|
- #sm: slightly dangerous as this will keep adding to the log file
|
|
|
- [ -n "${SQM_DEBUG}" -a "${SQM_DEBUG}" == 1 ] && echo "$@" >> ${SQM_DEBUG_LOG}
|
|
|
+ if [ "$SQM_SYSLOG" -eq "1" ]; then
|
|
|
+ logger -t SQM -s "$*"
|
|
|
+ else
|
|
|
+ echo "$@" >&2
|
|
|
fi
|
|
|
+ #sm: slightly dangerous as this will keep adding to the log file
|
|
|
+ [ -n "${SQM_DEBUG}" -a "${SQM_DEBUG}" == 1 ] && echo "$@" >> ${SQM_DEBUG_LOG}
|
|
|
fi
|
|
|
}
|
|
|
|
|
@@ -47,7 +42,7 @@ ipt() {
|
|
|
#sm: wrapper to call tc to allow debug logging
|
|
|
tc_wrapper() {
|
|
|
tc_args=$*
|
|
|
- sqm_logger "tc arguments: $tc_args" "${VERBOSITY_TOO_MUCH}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_VERBOSE" ] && sqm_logger "tc arguments: $tc_args"
|
|
|
[ "${SQM_DEBUG}" == 1 ] && echo "${TC_BINARY} $*" >> ${SQM_DEBUG_LOG}
|
|
|
${TC_BINARY} $* >> ${OUTPUT_TARGET} 2>&1
|
|
|
}
|
|
@@ -55,7 +50,7 @@ tc_wrapper() {
|
|
|
#sm: wrapper to call tc to allow debug logging
|
|
|
ip_wrapper() {
|
|
|
ip_args=$*
|
|
|
- sqm_logger "ip arguments: $ip_args" "${VERBOSITY_TOO_MUCH}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_VERBOSE" ] && sqm_logger "ip arguments: $ip_args"
|
|
|
[ "${SQM_DEBUG}" == 1 ] && echo "${IP_BINARY} $*" >> ${SQM_DEBUG_LOG}
|
|
|
${IP_BINARY} $* >> ${OUTPUT_TARGET} 2>&1
|
|
|
}
|
|
@@ -85,7 +80,7 @@ get_ifb_associated_with_if() {
|
|
|
# CUR_IFB=$( $TC -p filter show parent ffff: dev ${CUR_IF} | grep -o -e ifb'[[:digit:]]\+' )
|
|
|
#local CUR_IFB=$( $TC -p filter show parent ffff: dev ${CUR_IF} | grep -o -e ifb'[^)]\+' ) # my editor's syntax coloration is limitied so I need a single quote in this line (between eiditor and s)
|
|
|
local CUR_IFB=$( $TC -p filter show parent ffff: dev ${CUR_IF} | grep -o -E ifb'[^)\ ]+' ) # my editor's syntax coloration is limitied so I need a single quote in this line (between eiditor and s)
|
|
|
- sqm_logger "ifb associated with interface ${CUR_IF}: ${CUR_IFB}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "ifb associated with interface ${CUR_IF}: ${CUR_IFB}"
|
|
|
#sm: we could not detect an associated IFB for CUR_IF
|
|
|
if [ -z "${CUR_IFB}" ];
|
|
|
then
|
|
@@ -99,7 +94,7 @@ get_ifb_associated_with_if() {
|
|
|
sqm_logger "Please report this as an issue at https://github.com/tohojo/sqm-scripts"
|
|
|
sqm_logger "Please copy and paste everything below the cut-here line into your issue report, thanks."
|
|
|
else
|
|
|
- sqm_logger "Currently no ifb is associated with ${CUR_IF}, this is normal during starting of the sqm system." "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "Currently no ifb is associated with ${CUR_IF}, this is normal during starting of the sqm system."
|
|
|
fi
|
|
|
fi
|
|
|
echo ${CUR_IFB}
|
|
@@ -152,7 +147,7 @@ get_ifb_for_if() {
|
|
|
# if an ifb is already associated return that
|
|
|
local CUR_IFB=$( get_ifb_associated_with_if ${CUR_IF} )
|
|
|
[ -z "$CUR_IFB" ] && CUR_IFB=$( create_new_ifb_for_if ${CUR_IF} )
|
|
|
- [ -z "$CUR_IFB" ] && sqm_logger "Could not find existing IFB for ${CUR_IF}, nor create a new IFB instead..." "${VERBOSITY_NORMAL}"
|
|
|
+ [ -z "$CUR_IFB" ] && sqm_logger "Could not find existing IFB for ${CUR_IF}, nor create a new IFB instead..."
|
|
|
echo ${CUR_IFB}
|
|
|
}
|
|
|
|
|
@@ -185,7 +180,7 @@ verify_qdisc() {
|
|
|
$TC qdisc replace dev $ifb $root_string $qdisc #>>${OUTPUT_TARGET} 2>&1
|
|
|
res=$?
|
|
|
[ "$res" = "0" ] || not="NOT "
|
|
|
- [ "$res" != "0" -o "(" "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ")" ] && sqm_logger "QDISC $qdisc is ${not}useable." "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$res" != "0" -o "(" "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ")" ] && sqm_logger "QDISC $qdisc is ${not}useable."
|
|
|
delete_ifb $ifb
|
|
|
return $res
|
|
|
}
|
|
@@ -198,7 +193,7 @@ get_htb_adsll_string() {
|
|
|
# HTB defaults to MTU 1600 and an implicit fixed TSIZE of 256, but HTB as of around 3.10.0
|
|
|
# does not actually use a table in the kernel
|
|
|
ADSLL="mpu ${STAB_MPU} linklayer ${LINKLAYER} overhead ${OVERHEAD} mtu ${STAB_MTU}"
|
|
|
- sqm_logger "ADSLL: ${ADSLL}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "ADSLL: ${ADSLL}"
|
|
|
fi
|
|
|
echo ${ADSLL}
|
|
|
}
|
|
@@ -208,7 +203,7 @@ get_stab_string() {
|
|
|
if [ "${LLAM}" = "tc_stab" -a "$LINKLAYER" != "none" ];
|
|
|
then
|
|
|
STABSTRING="stab mtu ${STAB_MTU} tsize ${STAB_TSIZE} mpu ${STAB_MPU} overhead ${OVERHEAD} linklayer ${LINKLAYER}"
|
|
|
- sqm_logger "STAB: ${STABSTRING}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "STAB: ${STABSTRING}"
|
|
|
fi
|
|
|
echo ${STABSTRING}
|
|
|
}
|
|
@@ -224,7 +219,7 @@ get_cake_lla_string() {
|
|
|
fi
|
|
|
|
|
|
STABSTRING="${STABSTRING} overhead ${OVERHEAD}"
|
|
|
- sqm_logger "cake link layer adjustments: ${STABSTRING}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "cake link layer adjustments: ${STABSTRING}"
|
|
|
fi
|
|
|
echo ${STABSTRING}
|
|
|
}
|
|
@@ -234,7 +229,7 @@ sqm_stop() {
|
|
|
$TC qdisc del dev $IFACE ingress #2>> ${OUTPUT_TARGET}
|
|
|
$TC qdisc del dev $IFACE root #2>> ${OUTPUT_TARGET}
|
|
|
[ -n "$CUR_IFB" ] && $TC qdisc del dev $CUR_IFB root #2>> ${OUTPUT_TARGET}
|
|
|
- [ -n "$CUR_IFB" ] && sqm_logger "${0}: ${CUR_IFB} shaper deleted" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ -n "$CUR_IFB" -a "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "${0}: ${CUR_IFB} shaper deleted"
|
|
|
|
|
|
[ -n "$CUR_IFB" ] && ipt -t mangle -D POSTROUTING -o $CUR_IFB -m mark --mark 0x00 -g QOS_MARK_${IFACE}
|
|
|
ipt -t mangle -D POSTROUTING -o $IFACE -m mark --mark 0x00${IPT_MASK_STRING} -g QOS_MARK_${IFACE}
|
|
@@ -250,7 +245,7 @@ sqm_stop() {
|
|
|
|
|
|
[ -n "$CUR_IFB" ] && $IP link set dev ${CUR_IFB} down
|
|
|
[ -n "$CUR_IFB" ] && $IP link delete ${CUR_IFB} type ifb
|
|
|
- [ -n "$CUR_IFB" ] && sqm_logger "${0}: ${CUR_IFB} interface deleted" "${VERBOSITY_NORMAL}"
|
|
|
+ [ -n "$CUR_IFB" ] && sqm_logger "${0}: ${CUR_IFB} interface deleted"
|
|
|
}
|
|
|
# Note this has side effects on the prio variable
|
|
|
# and depends on the interface global too
|
|
@@ -321,7 +316,7 @@ get_htb_quantum() {
|
|
|
CUR_QUANTUM=$((${CUR_QUANTUM} * 2))
|
|
|
fi
|
|
|
|
|
|
- sqm_logger "CUR_HTB_QUANTUM: ${CUR_QUANTUM}, BANDWIDTH: ${BANDWIDTH}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "CUR_HTB_QUANTUM: ${CUR_QUANTUM}, BANDWIDTH: ${BANDWIDTH}"
|
|
|
|
|
|
echo $CUR_QUANTUM
|
|
|
}
|
|
@@ -331,7 +326,7 @@ get_htb_quantum() {
|
|
|
# but I fear we actually need the wire size of the whole thing not so much the MTU
|
|
|
get_mtu() {
|
|
|
CUR_MTU=$(cat /sys/class/net/$1/mtu)
|
|
|
- sqm_logger "IFACE: ${1} MTU: ${CUR_MTU}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "IFACE: ${1} MTU: ${CUR_MTU}"
|
|
|
echo ${CUR_MTU}
|
|
|
}
|
|
|
|
|
@@ -375,7 +370,7 @@ get_flows_count() {
|
|
|
get_target() {
|
|
|
local CUR_TARGET=${1}
|
|
|
local CUR_LINK_KBPS=${2}
|
|
|
- [ ! -z "$CUR_TARGET" ] && sqm_logger "cur_target: ${CUR_TARGET} cur_bandwidth: ${CUR_LINK_KBPS}" "${VERBOSITY_NORMAL}"
|
|
|
+ [ ! -z "$CUR_TARGET" ] && sqm_logger "cur_target: ${CUR_TARGET} cur_bandwidth: ${CUR_LINK_KBPS}"
|
|
|
CUR_TARGET_STRING=
|
|
|
# either e.g. 100ms or auto
|
|
|
CUR_TARGET_VALUE=$( echo ${CUR_TARGET} | grep -o -e \^'[[:digit:]]\+' )
|
|
@@ -407,9 +402,9 @@ get_target() {
|
|
|
TMP_INTERVAL_STRING=$( adapt_interval_to_slow_link $TMP_TARGET_US )
|
|
|
CUR_TARGET_STRING="target ${TMP_TARGET_US}us ${TMP_INTERVAL_STRING}"
|
|
|
AUTO_TARGET="1"
|
|
|
- sqm_logger "get_target defaulting to auto." "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "get_target defaulting to auto."
|
|
|
else
|
|
|
- sqm_logger "required link bandwidth in kbps not passed to get_target()." "${VERBOSITY_NORMAL}"
|
|
|
+ sqm_logger "required link bandwidth in kbps not passed to get_target()."
|
|
|
fi
|
|
|
fi
|
|
|
# but still allow explicit use of the keyword auto for backward compatibility
|
|
@@ -422,7 +417,7 @@ get_target() {
|
|
|
CUR_TARGET_STRING="target ${TMP_TARGET_US}us ${TMP_INTERVAL_STRING}"
|
|
|
AUTO_TARGET="1"
|
|
|
else
|
|
|
- sqm_logger "required link bandwidth in kbps not passed to get_target()." "${VERBOSITY_NORMAL}"
|
|
|
+ sqm_logger "required link bandwidth in kbps not passed to get_target()."
|
|
|
fi
|
|
|
;;
|
|
|
esac
|
|
@@ -433,9 +428,9 @@ get_target() {
|
|
|
then
|
|
|
CUR_TARGET_STRING="" # return nothing so the default target is not over-ridden...
|
|
|
AUTO_TARGET="1"
|
|
|
- sqm_logger "get_target using qdisc default, no explicit target string passed." "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "get_target using qdisc default, no explicit target string passed."
|
|
|
else
|
|
|
- sqm_logger "required link bandwidth in kbps not passed to get_target()." "${VERBOSITY_NORMAL}"
|
|
|
+ sqm_logger "required link bandwidth in kbps not passed to get_target()."
|
|
|
fi
|
|
|
;;
|
|
|
esac
|
|
@@ -443,7 +438,7 @@ get_target() {
|
|
|
then
|
|
|
if [ -z "${CUR_TARGET_VALUE}" -o -z "${UNIT_VALID}" ];
|
|
|
then
|
|
|
- [ -z "$AUTO_TARGET" ] && sqm_logger "${CUR_TARGET} is not a well formed tc target specifier; e.g.: 5ms (or s, us), or one of the strings auto or default." "${VERBOSITY_NORMAL}"
|
|
|
+ [ -z "$AUTO_TARGET" ] && sqm_logger "${CUR_TARGET} is not a well formed tc target specifier; e.g.: 5ms (or s, us), or one of the strings auto or default."
|
|
|
fi
|
|
|
fi
|
|
|
;;
|
|
@@ -504,10 +499,10 @@ get_limit() {
|
|
|
;;
|
|
|
bfifo) [ -z "$CURLIMIT" ] && [ ! -z "$LIMIT" ] && CURLIMIT=$(( ${LIMIT} * $( cat /sys/class/net/${IFACE}/mtu ) )) # bfifo defaults to txquelength * MTU,
|
|
|
;;
|
|
|
- *) sqm_logger "${QDISC} does not support a limit" "${VERBOSITY_NORMAL}"
|
|
|
+ *) sqm_logger "${QDISC} does not support a limit"
|
|
|
;;
|
|
|
esac
|
|
|
- sqm_logger "get_limit: $1 CURLIMIT: ${CURLIMIT}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "get_limit: $1 CURLIMIT: ${CURLIMIT}"
|
|
|
|
|
|
if [ ! -z "$CURLIMIT" ]
|
|
|
then
|
|
@@ -540,10 +535,10 @@ get_ecn() {
|
|
|
esac
|
|
|
;;
|
|
|
*)
|
|
|
- sqm_logger "ecn value $1 not handled" "${VERBOSITY_NORMAL}"
|
|
|
+ sqm_logger "ecn value $1 not handled"
|
|
|
;;
|
|
|
esac
|
|
|
- sqm_logger "get_ECN: $1 CURECN: ${CURECN} IECN: ${IECN} EECN: ${EECN}" "${VERBOSITY_VERBOSE}"
|
|
|
+ [ "$SQM_VERBOSITY" -gt "$VERBOSITY_NORMAL" ] && sqm_logger "get_ECN: $1 CURECN: ${CURECN} IECN: ${IECN} EECN: ${EECN}"
|
|
|
echo ${CURECN}
|
|
|
|
|
|
}
|