mirror of
https://github.com/openwrt/packages.git
synced 2025-12-22 23:24:31 +04:00
sqm-scripts: backport from trunk "Teach SQM hotplug tricks"
Backport from trunk the commit that adds support for hotplug action.
5b61cfba07
Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
This commit is contained in:
30
net/sqm-scripts/files/usr/lib/sqm/run.sh
Normal file → Executable file
30
net/sqm-scripts/files/usr/lib/sqm/run.sh
Normal file → Executable file
@@ -9,16 +9,37 @@
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
STOP=$1
|
||||
STOP=
|
||||
ACTIVE_STATE_PREFIX="SQM_active_on_"
|
||||
ACTIVE_STATE_FILE_DIR="/var/run/SQM"
|
||||
mkdir -p ${ACTIVE_STATE_FILE_DIR}
|
||||
PROTO_STATE_FILE_LIST=$( ls ${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}* 2> /dev/null )
|
||||
|
||||
|
||||
case ${1} in
|
||||
stop)
|
||||
logger -t SQM -s "run.sh stop"
|
||||
STOP=$1
|
||||
;;
|
||||
interface)
|
||||
START_ON_IF=$2 # only process this interface
|
||||
logger -t SQM -s "Re/starting sqm on interface ${START_ON_IF}"
|
||||
# TODO if $2 is empty just bail...
|
||||
if [ -z ${START_ON_IF} ] ;
|
||||
then
|
||||
logger -t SQM -s "Interface name missing, nothing to do, bailing out"
|
||||
return 0
|
||||
fi
|
||||
# only try to restart the just hotplugged interface, so reduce the list of interfaces to stop to the specified one
|
||||
PROTO_STATE_FILE_LIST=${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}${START_ON_IF}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# the current uci config file does not necessarily contain sections for all interfaces with active
|
||||
# SQM instances, so use the ACTIVE_STATE_FILES to detect the interfaces on which to stop SQM.
|
||||
# Currently the .qos scripts start with stopping any existing traffic shaping so this should not
|
||||
# effectively change anything...
|
||||
PROTO_STATE_FILE_LIST=$( ls ${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}* 2> /dev/null )
|
||||
for STATE_FILE in ${PROTO_STATE_FILE_LIST} ; do
|
||||
if [ -f ${STATE_FILE} ] ;
|
||||
then
|
||||
@@ -35,6 +56,11 @@ config_load sqm
|
||||
run_simple_qos() {
|
||||
local section="$1"
|
||||
export IFACE=$(config_get "$section" interface)
|
||||
|
||||
# If called explicitly for one interface only , so ignore anything else
|
||||
[ -n "${START_ON_IF}" -a "$START_ON_IF" != "$IFACE" ] && return
|
||||
#logger -t SQM -s "marching on..."
|
||||
|
||||
ACTIVE_STATE_FILE_FQN="${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}${IFACE}" # this marks interfaces as active with SQM
|
||||
[ -f "${ACTIVE_STATE_FILE_FQN}" ] && logger -t SQM -s "Uh, oh, ${ACTIVE_STATE_FILE_FQN} should already be stopped." # Not supposed to happen
|
||||
|
||||
|
||||
3
net/sqm-scripts/files/usr/lib/sqm/simple.qos
Normal file → Executable file
3
net/sqm-scripts/files/usr/lib/sqm/simple.qos
Normal file → Executable file
@@ -37,6 +37,9 @@ ipt -t mangle -A QOS_MARK_${IFACE} -m tos --tos Minimize-Delay -j MARK --set-ma
|
||||
|
||||
# Turn it on. Preserve classification if already performed
|
||||
|
||||
#sm: is it correct to do this in $IFACE? Should ingress not be on $DEV? since HTB acts on $DEV?
|
||||
# SQUASH also does not work on $DEV (that is the IFB will still see the incoming ToS bits whether we squash or not)
|
||||
# SQUASH is still useful to protect internal machines...
|
||||
if [ "$SQUASH_DSCP" = "1" ]
|
||||
then
|
||||
sqm_logger "Squashing differentiated services code points (DSCP) from ingress."
|
||||
|
||||
Reference in New Issue
Block a user