uspot: accounting: send RADIUS acct Stop on disconnect

If a client "disappears" from wireless, spotfilter eventually wipes
their state data before the accounting removal occurs. Thus in
radius_acct(), the ubus call returns empty and no RADIUS accounting Stop
frame is sent in this condition, leaving a dangling accounting for the
client.

This commit solves this issue by maintaining a local copy of the most
recent accounting data and sending that when the live data is no longer
available.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
Thibaut VARÈNE
2023-05-24 17:45:14 +02:00
committed by John Crispin
parent e30cfbf36b
commit ec924ea3d7

View File

@@ -60,7 +60,7 @@ function radius_acct(interface, mac, payload) {
let state = ubus.call('spotfilter', 'client_get', {
interface,
address: mac
});
}) || clients[interface][mac]; // fallback to last known state
if (!state)
return;
@@ -111,7 +111,20 @@ function radius_interim(interface, mac) {
function client_interim(interface, mac, time) {
let client = clients[interface][mac];
if (!client.accounting || !client.interval)
if (!client.accounting)
return;
// preserve a copy of last spotfilter stats for use in disconnect case
let state = ubus.call('spotfilter', 'client_get', {
interface,
address: mac
});
if (!state)
return;
client.acct_data = state.acct_data;
if (!client.interval)
return;
if (time >= client.next_interim) {
@@ -146,6 +159,9 @@ function client_add(interface, mac, state) {
session,
idle,
max_total,
data: {
connect: state.data.connect,
}
};
if (state.ip4addr)
clients[interface][mac].ip4addr = state.ip4addr;