mpskd: kick all 6G clients upon reload

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2024-09-23 14:57:21 +02:00
parent b2e778221e
commit 911da1bb41

View File

@@ -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(); });