Firewall + SQM

It appears that sqm is dependant on the firewall being enabled. Why is this?

If you run iptables-save with and without SQM then the difference might give you an idea.

I'll have to try that. I didn't think it had any bearing since even manually setting up qdiscs/shapers didn't involve iptables. Unless it was IMQ in my experience; more to learn.

As I remember there is a SQM shell script in the firewall config file to invoke. Take a look in there.

I've seen some that involve iptables but those were pre-composed scripts. I'm mainly referring to cake unless there are other dependent scripts that I haven't seen e.g. piece of cake.qos

I was referring to the SQM script in /etc/config/firewall.

Can you post this? I'm currently at work...

There is nothing sqm related in the firewall config, nor in /etc/firewall.user for that matter....

How did you reach that conclusion? I am not doubting you, I am asking for how to recreate/repeat your test, so I can start looking into this.

It would be helpful, if you could post the output of:

cat /etc/config/sqm
tc -s qdisc
 SQM_DEBUG=1 SQM_VERBOSITY_MAX=11 /etc/init.d/sqm stop ; SQM_DEBUG=1 SQM_VERBOSITY_MAX=11 /etc/init.d/sqm start

My bad. I was going by memory and confused it with something else.

1 Like

Oh, I was not sure about that at all, so I had to check on my actual router :wink:

@moeller0 my bitw will disable sqm if the the firewall is disabled under luci:system:startup or "/etc/init.d/firewall disable" confirmed with v18.06.04-v19.07.01.

From /etc/config/ucitrack

config firewall                   
        option init 'firewall'    
        list affects 'luci-splash'
        list affects 'qos'      
        list affects 'miniupnpd'
        list affects 'sqm'

Okay, but what happens if you run
SQM_DEBUG=1 SQM_VERBOSITY_MAX=11 /etc/init.d/sqm start
after you disabled the firewall?

This is coming from luci-app-sqm actually from uci-defaults-sqm

It seems to only happens after a reboot and yes sqm is set to automatically to startup.

@moeller0

SQM: Acquired run lock
/usr/lib/sqm/run.sh: line 57: can't create : nonexistent directory
SQM: 
SQM: Sat Feb 29 13:52:42 UTC 2020: Starting.
SQM: Starting SQM script: piece_of_cake.qos on eth0.1, in: 0 Kbps, out: 45000 Kbps
SQM: fn_exists: function candidate name: sqm_start
SQM: fn_exists: TYPE_OUTPUT: sqm_start: not found
SQM: fn_exists: return value: 1
SQM: Using generic sqm_start_default function.
SQM: fn_exists: function candidate name: sqm_prepare_script
SQM: fn_exists: TYPE_OUTPUT: sqm_prepare_script is a function
SQM: fn_exists: return value: 0
SQM: sqm_start_default: starting sqm_prepare_script
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: QDISC cake is useable.
SQM: cmd_wrapper: COMMAND: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: COMMAND: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: QDISC cake is useable.
SQM: cmd_wrapper: COMMAND: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: COMMAND: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: sqm_start_default: Starting piece_of_cake.qos
SQM: ifb associated with interface eth0.1: 
SQM: Currently no ifb is associated with eth0.1, this is normal during starting of the sqm system.
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name ifb4eth0.1 type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name ifb4eth0.1 type ifb
SQM: fn_exists: function candidate name: egress
SQM: fn_exists: TYPE_OUTPUT: egress is a function
SQM: fn_exists: return value: 0
SQM: egress
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev eth0.1 root
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev eth0.1 root
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: cake link layer adjustments:  overhead 22 mpu 0
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc add dev eth0.1 root cake bandwidth 45000kbit overhead 22 mpu 0 besteffort dual-dsthost ingress wash
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc add dev eth0.1 root cake bandwidth 45000kbit overhead 22 mpu 0 besteffort dual-dsthost ingress wash
SQM: sqm_start_default: egress shaping activated
SQM: sqm_start_default: ingress shaping deactivated
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev ifb4eth0.1 root
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev ifb4eth0.1 root
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev eth0.1 ingress
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev eth0.1 ingress
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: piece_of_cake.qos was started on eth0.1 successfully
SQM: 
SQM: Sat Feb 29 13:52:43 UTC 2020: Starting.
SQM: Starting SQM script: piece_of_cake.qos on eth0.2, in: 0 Kbps, out: 9000 Kbps
SQM: fn_exists: function candidate name: sqm_start
SQM: fn_exists: TYPE_OUTPUT: sqm_start: not found
SQM: fn_exists: return value: 1
SQM: Using generic sqm_start_default function.
SQM: fn_exists: function candidate name: sqm_prepare_script
SQM: fn_exists: TYPE_OUTPUT: sqm_prepare_script is a function
SQM: fn_exists: return value: 0
SQM: sqm_start_default: starting sqm_prepare_script
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: QDISC cake is useable.
SQM: cmd_wrapper: COMMAND: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: COMMAND: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc replace dev TMP_IFB_4_SQM root cake
SQM: QDISC cake is useable.
SQM: cmd_wrapper: COMMAND: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link set dev TMP_IFB_4_SQM down
SQM: cmd_wrapper: COMMAND: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link delete TMP_IFB_4_SQM type ifb
SQM: sqm_start_default: Starting piece_of_cake.qos
SQM: ifb associated with interface eth0.2: 
SQM: Currently no ifb is associated with eth0.2, this is normal during starting of the sqm system.
SQM: cmd_wrapper: COMMAND: /sbin/ip link add name ifb4eth0.2 type ifb
SQM: cmd_wrapper: ip: SUCCESS: /sbin/ip link add name ifb4eth0.2 type ifb
SQM: fn_exists: function candidate name: egress
SQM: fn_exists: TYPE_OUTPUT: egress is a function
SQM: fn_exists: return value: 0
SQM: egress
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev eth0.2 root
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev eth0.2 root
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: cake link layer adjustments:  overhead 22 mpu 0
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc add dev eth0.2 root cake bandwidth 9000kbit overhead 22 mpu 0 besteffort dual-dsthost wash
SQM: cmd_wrapper: tc: SUCCESS: /usr/sbin/tc qdisc add dev eth0.2 root cake bandwidth 9000kbit overhead 22 mpu 0 besteffort dual-dsthost wash
SQM: sqm_start_default: egress shaping activated
SQM: sqm_start_default: ingress shaping deactivated
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev ifb4eth0.2 root
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev ifb4eth0.2 root
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: cmd_wrapper: tc: invocation silenced by request, FAILURE either expected or acceptable.
SQM: cmd_wrapper: COMMAND: /usr/sbin/tc qdisc del dev eth0.2 ingress
SQM: cmd_wrapper: tc: FAILURE (2): /usr/sbin/tc qdisc del dev eth0.2 ingress
SQM: cmd_wrapper: tc: LAST ERROR: RTNETLINK answers: No such file or directory
SQM: piece_of_cake.qos was started on eth0.2 successfully

sqm has now started after issuing those commands.

So it seems luci-app-sqm drags this in, but I am note sure why? @tohojo do you remember why luci-app-sqm's uci-defauls-sqm links sqm to the firewall?

I think the idea was that we want to reload sqm-scripts when the firewall is reloaded, to make sure any iptables rules installed by sqm-scripts will get re-applied. It certainly isn't supposed to be a hard dependency - sqm-scripts should work without the firewall.

Not sure how to express that to UCI, though?