NFT QOS MONITOR: Error: syntax error, unexpected handle

Hi,

in my log file (WRT1900ACS, current, but this error message is present since a lot of time) I found following error message:

Fri Nov  6 21:31:30 2020 user.notice nft-qos-monitor: ACTION=remove, MACADDR=00:1c:85:0c:63:7e, IPADDR=192.168.0.200, HOSTNAME=
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]: Error: syntax error, unexpected handle
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]: delete handle 15
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]:        ^^^^^^
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]: Error: syntax error, unexpected handle
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]: delete handle 16
Fri Nov  6 21:31:30 2020 daemon.debug dnsmasq-script[5531]:        ^^^^^^
Fri Nov  6 21:31:30 2020 user.notice nft-qos-dynamic: ACTION=remove, MACADDR=00:1c:85:0c:63:7e, IPADDR=192.168.0.200, HOSTNAME=

This happens for IP addresses, which have not a static name for the DHCP ( i.e. unknown devices for guest smartphones):

Fri Nov  6 20:01:28 2020 daemon.info dnsmasq-dhcp[5531]: DHCPREQUEST(br-lan) 192.168.0.200 00:1c:85:0c:63:7e
Fri Nov  6 20:01:28 2020 daemon.info dnsmasq-dhcp[5531]: DHCPACK(br-lan) 192.168.0.200 00:1c:85:0c:63:7e
Fri Nov  6 20:01:28 2020 user.notice nft-qos-monitor: ACTION=add, MACADDR=00:1c:85:0c:63:7e, IPADDR=192.168.0.200, HOSTNAME=
Fri Nov  6 20:01:29 2020 user.notice nft-qos-dynamic: ACTION=add, MACADDR=00:1c:85:0c:63:7e, IPADDR=192.168.0.200, HOSTNAME=

How to fix it?

Best regards
dyha

Sorry for Necro but I noticed the same issue with 22.03.2 and it is pretty obvious that this package has not worked for some time if ever and this was the best description I found with google.

qosdef_monitor_del() { # <mac> <ip> <hostname>
	local handle_dl handle_ul
	handle_dl=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY download $2)
	handle_ul=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY upload $2)
	[ -n "$handle_dl" ] && nft delete handle $handle_dl
	[ -n "$handle_ul" ] && nft delete handle $handle_ul
}

qosdev_monitor_get_ip_handle returns a single integer but handles are not globally unique:

table inet nft-qos-monitor { # handle 2
        chain upload { # handle 1
                type filter hook postrouting priority filter; policy accept;
                ip saddr 172.30.10.51 counter packets 24985469 bytes 1425810120 # handle 4
                ip saddr 172.30.10.110 counter packets 13935 bytes 1177371 # handle 6
                ip saddr 172.30.10.163 counter packets 130115 bytes 8272477 # handle 8
                ip saddr 172.30.10.122 counter packets 6422 bytes 1355883 # handle 10
                ip saddr 172.30.10.66 counter packets 5187 bytes 605130 # handle 12
                ip saddr 172.30.10.50 counter packets 1536382 bytes 83014391 # handle 14
        }

        chain download { # handle 2
                type filter hook prerouting priority filter; policy accept;
                ip daddr 172.30.10.51 counter packets 37770445 bytes 69937293926 # handle 3
                ip daddr 172.30.10.110 counter packets 11827 bytes 1780560 # handle 5
                ip daddr 172.30.10.163 counter packets 199212 bytes 256918082 # handle 7
                ip daddr 172.30.10.122 counter packets 9034 bytes 7631704 # handle 9
                ip daddr 172.30.10.66 counter packets 4841 bytes 722932 # handle 11
                ip daddr 172.30.10.50 counter packets 5720999 bytes 8725274742 # handle 13
        }
}

the delete syntax should be:
nft delete rule <family> <table> <chain> handle <handle>

Testing /lib/nft-qos/monitor.sh like this:

        [ -n "$handle_dl" ] && nft delete rule $NFT_QOS_INET_FAMILY nft-qos-monitor download handle $handle_dl
        [ -n "$handle_ul" ] && nft delete rule $NFT_QOS_INET_FAMILY nft-qos-monitor upload handle $handle_ul