From 911da1bb417cfc143ee4bc86ec21e86ef5deda36 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 23 Sep 2024 14:57:21 +0200 Subject: [PATCH] mpskd: kick all 6G clients upon reload Signed-off-by: John Crispin --- feeds/ipq807x_v5.4/hostapd/files/mpskd | 30 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/feeds/ipq807x_v5.4/hostapd/files/mpskd b/feeds/ipq807x_v5.4/hostapd/files/mpskd index a03034b89..b95674041 100644 --- a/feeds/ipq807x_v5.4/hostapd/files/mpskd +++ b/feeds/ipq807x_v5.4/hostapd/files/mpskd @@ -9,8 +9,7 @@ let ubus = libubus.connect(); let interfaces = {}; let ssids = {}; let cache = {}; -let sub_6g = []; -let sub_6g_obj; +let subs_hapd = []; let reload_timer; let gc_timer; @@ -66,10 +65,9 @@ function event_cb(req) { } function create_6g_subscriber() { - for (let cur_sub in sub_6g) + for (let cur_sub in subs_hapd) cur_sub.remove(); - sub_6g = []; - + subs_hapd = []; for (let ifname, iface in interfaces) { let obj = 'hostapd.' + ifname; let cur_sub; @@ -78,7 +76,7 @@ function create_6g_subscriber() { else cur_sub = ubus.subscriber((req) => event_cb(req)); cur_sub.subscribe(obj); - push(sub_6g, cur_sub); + push(subs_hapd, cur_sub); printf(`subscribe ${ifname}\n`); ubus.call(obj, 'notify_response', { notify_response: 1 }); } @@ -314,12 +312,30 @@ let ubus_methods = { return { interfaces, ssids, - cache + cache, }; }, args: { } }, + flush: { + call: function() { + for (let ssid, data in ssids) { + let band = '6g'; + let iface = data.bands[band]; + if (!iface) + continue; + let clients = ubus.call('hostapd.' + iface, 'get_clients'); + for (let addr, client in clients.clients) { + if (!cache[ssid]) + continue; + delete cache[ssid][addr]; + ubus.call('hostapd.' + iface, 'del_client', { addr }); + } + } + }, + args: {} + }, }; reload_timer = uloop.timer(-1, () => { netifd_reload(); });