From 933e411a10954b37e39c43d5c8349ed01850ba1c Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Tue, 28 Mar 2023 18:21:28 -0700 Subject: [PATCH] Force badly associated stations to reassociate. There appears to be a bug in the ath10k firmware for Mikrotik devices (maybe others) where a station will associate but only broadcast traffic will be passed - unicast traffic will fail. This code detects this situation and forces the device to reassociate which fixes the problem. --- .../usr/local/bin/mgr/rssi_monitor_ath10k.lua | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/files/usr/local/bin/mgr/rssi_monitor_ath10k.lua b/files/usr/local/bin/mgr/rssi_monitor_ath10k.lua index 74f704d2..53463ebb 100644 --- a/files/usr/local/bin/mgr/rssi_monitor_ath10k.lua +++ b/files/usr/local/bin/mgr/rssi_monitor_ath10k.lua @@ -38,6 +38,9 @@ local periodic_scan_time = 300 -- 5 minutes local wifiiface local last_scan_time = 0 +local IW = "/usr/sbin/iw" +local ARPING = "/usr/sbin/arping" + function rssi_monitor_10k() if not string.match(get_ifname("wifi"), "^wlan") then exit_app() @@ -88,6 +91,34 @@ function run_monitor_10k() log:flush() end last_station_count = station_count + + -- Check each station to make sure we can broadcast and unicast to them + arptable( + function (entry) + if entry.Device == wifiiface then + local ip = entry["IP address"] + local mac = entry["HW address"] + if entry["Flags"] ~= "0x0" and ip and mac then + local reassociate = false + -- Two arp pings - the first is broadcast, the second unicast + for line in io.popen(ARPING .. " -c 2 -I " .. wifiiface .. " " .. ip):lines() + do + -- If we see exactly one response then we neeed to force the station to reassociate + -- This indicates that broadcasts work, but unicasts dont + if line:match("Received 1 response") then + reassociate = true + break + end + end + if reassociate then + os.execute(IW .. " " .. wifiiface .. " station del " .. mac) + log:write("Unresponsive node forced to reassociate: ip " .. ip .. ", mac " .. mac) + log:flush() + end + end + end + end + ) end return rssi_monitor_10k