Disabled SQM instance, but still active


I want to create two (2) SQM instances. One for gaming and one for normal WEB surfing.

Gaming SQM instance is throttled down to 80% of the speeds I pay for, giving me a triple A+ in bufferbload, quality, speed. That's fine.

My problem is that if I create a new one for usual full speed WEB surfing, it gets active even though it's not ticked.

I've test it in DSL reports webpage.

My router is a TP-LINK ND1043v4 with 17.01.0-rc2.

Any help would be appreciated.

Why you don't just disable Sqm from startup when you want Web surfing?

I was hoping to create a list of instances in the future so I could test them on the fly.
Apparently there is a problem.

How did you enable/disable the instances?

sqm has an in "enabled" switch for each sqm instance in the config file /etc/config/sqm

If you set that to '0' in the config file for each sqm section, the section should stay disabled. Does it not work that way?

Edit it to be active ("1") only for that section that you currently want.

I enabled/disabled from gui. Do you mean I should try with a command from shell?

GUI should edit the same SQM config file, so it should make no difference.

But you get more exact control when you edit /etc/config/sqm from console shell, and then use "/etc/init.d/sqm restart" to get the new config activated.

I tested that and noticed something strange. I had two config sections in the SQM config file. First had enabled 1 for eth0.2 interface, while the second instance had enabled 0 for the same interface. When I then restarted SQM, it first evaluated the first block and started SQM but then found the next block that disabled it...

root@LEDE:~# /etc/init.d/sqm restart
SQM: Starting SQM script: simple.qos on eth0.2, in: 85000 Kbps, out: 10000 Kbps
SQM: simple.qos was started on eth0.2 successfully
SQM: Stopping SQM on eth0.2


config queue 'eth0'
        option enabled '1'
        option interface 'eth0.2'
        option download '85000'

config queue 'ethkoe'
        option enabled '0'
        option interface 'eth0.2'
        option download '85000'

So, I do not think that the curent startup script logic in SQM really supports multiple alternative settings blocks for the same interface. You might need to edit the interface from eth0.2 to eth0.44 (something non-existing) in the disabled block to get it properly ignored.


1 Like

Thanks mate. Though it seems more like a workaround rather than a fix.

Well, this an issue we fixed in upstream sqm-scripts. But since that version contains more restructuring the quickest potential fix (you would still need to test it I only mocked this up here in the discourse editor) would be to replace /usr/lib/sqm/run.sh's content with the following:

 # 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-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
 . /lib/functions.sh
 . /etc/sqm/sqm.conf
 [ -d "${SQM_QDISC_STATE_DIR}" ] || ${SQM_LIB_DIR}/update-available-qdiscs
 # Stopping all active interfaces
 if [ "$ACTION" = "stop" -a -z "$RUN_IFACE" ]; then
     for f in ${SQM_STATE_DIR}/*.state; do
         # Source the state file prior to stopping; we need the $IFACE and
         # $SCRIPT variables saved in there.
     exit 0
 config_load sqm
 run_sqm_scripts() {
     local section="$1"
     export IFACE=$(config_get "$section" interface)
     [ -z "$RUN_IFACE" -o "$RUN_IFACE" = "$IFACE" ] || return

     [ $(config_get "$section" enabled) -ne 1 ] && SECTION_ACTION=stop
     export UPLINK=$(config_get "$section" upload)
     export DOWNLINK=$(config_get "$section" download)
     export LLAM=$(config_get "$section" linklayer_adaptation_mechanism)
     export LINKLAYER=$(config_get "$section" linklayer)
     export OVERHEAD=$(config_get "$section" overhead)
     export STAB_MTU=$(config_get "$section" tcMTU)
     export STAB_TSIZE=$(config_get "$section" tcTSIZE)
     export STAB_MPU=$(config_get "$section" tcMPU)
     export ILIMIT=$(config_get "$section" ilimit)
     export ELIMIT=$(config_get "$section" elimit)
     export ITARGET=$(config_get "$section" itarget)
     export ETARGET=$(config_get "$section" etarget)
     export IECN=$(config_get "$section" ingress_ecn)
     export EECN=$(config_get "$section" egress_ecn)
     export IQDISC_OPTS=$(config_get "$section" iqdisc_opts)
     export EQDISC_OPTS=$(config_get "$section" eqdisc_opts)
     export TARGET=$(config_get "$section" target)
     export SHAPER_BURST=$(config_get "$section" shaper_burst)
     export HTB_QUANTUM_FUNCTION=$(config_get "$section" htb_quantum_function)
     export QDISC=$(config_get "$section" qdisc)
     export SCRIPT=$(config_get "$section" script)
     # The UCI names for these two variables are confusing and should have been
     # changed ages ago. For now, keep the bad UCI names but use meaningful
     # variable names in the scripts to not break user configs.
     export ZERO_DSCP=$(config_get "$section" squash_dscp)
     export IGNORE_DSCP=$(config_get "$section" squash_ingress)
     #sm: if SQM_DEBUG or SQM_VERBOSITY_* were passed in via the command line make them available to the other scripts
     #	this allows to override sqm's log level as set in the GUI for quick debugging without GUI accesss.
     [ -n "$SQM_DEBUG" ] && export SQM_DEBUG || export SQM_DEBUG=$(config_get "$section" debug_logging)
     [ -n "$SQM_VERBOSITY_MAX" ] && export SQM_VERBOSITY_MAX || export SQM_VERBOSITY_MAX=$(config_get "$section" verbosity)
     [ -n "$SQM_VERBOSITY_MIN" ] && export SQM_VERBOSITY_MIN
     #sm: only stop-sqm if there is something running
     if [ -f "${CUR_STATE_FILE}" ]; then

    [ "$SECTION_ACTION" = "start" ] && "${SQM_LIB_DIR}/start-sqm"
 config_foreach run_sqm_scripts

That hopefully will make multiple sections for the same interface work. The reason for the problems is that /etc/config/sqm can be edited multiple times before being processed by /etc/init.d/sqm, so we have no certainty that what ever instances are running are in any way related to the config file. But have a look at https://github.com/tohojo/sqm-scripts/blob/master/src/run-openwrt.sh for how @tohojo solved this issue for good.

Best Regards

1 Like

Thank you so much for your response @moeller0 .Keep up the good work.
Can you pls explain which part should I replace in my /usr/lib/sqm/run.sh because I'm not very good with Linux.
The red part? The green part in the code window ? The blue part ? All together ?
The screenshot is from your reply.


Or if it's easier can you upload the modified file?

@moeller0 You can use the "Preformatted text" option in the editor menu to markup scripts or thelike.

Thanks Tmomas,

I had forgotten to do this and hence the post looked terribly confusing, sorry Sgt_Greco. I hope this is clear enough, and hopefully it will be suffiecient to copy and paste from the discourse page..

1 Like