diff mbox series

[usteer] policy: avoid creating kick loop for client

Message ID 20211004214715.748719-1-mail@david-bauer.net
State Under Review
Delegated to: David Bauer
Headers show
Series [usteer] policy: avoid creating kick loop for client | expand

Commit Message

David Bauer Oct. 4, 2021, 9:47 p.m. UTC
When checking whether a client is allowed to associate to a node, the
lower ceiling for kicking clients was not taken into account when
assoc-steering is disabled.

The problem behind this is, that a configured lower barrier for
disassociating clients (kicking) would kick the client immediatly after
association. In the worst scenario the client immediatly associates
again to the station and ends up in a kick loop.

Don't allow associating when a min_snr is configured and the client
signal is below this value.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 policy.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/policy.c b/policy.c
index c1a992f..91ff613 100644
--- a/policy.c
+++ b/policy.c
@@ -155,8 +155,22 @@  usteer_check_request(struct sta_info *si, enum usteer_event_type type)
 	if (type == EVENT_TYPE_AUTH)
 		goto out;
 
-	if (type == EVENT_TYPE_ASSOC && !config.assoc_steering)
-		goto out;
+	if (type == EVENT_TYPE_ASSOC) {
+		/* Check if assoc request has lower signal than min_signal.
+		 * If this is the case, block assoc even when assoc steering is enabled.
+		 *
+		 * Otherwise, the client potentially ends up in a assoc - kick loop.
+		 */
+		if (config.min_snr && si->signal < snr_to_signal(si->node, config.min_snr)) {
+			ev.reason = UEV_REASON_LOW_SIGNAL;
+			ev.threshold.cur = si->signal;
+			ev.threshold.ref = min_signal;
+			ret = false;
+			goto out;
+		} else if (!config.assoc_steering) {
+			goto out;
+		}
+	}
 
 	min_signal = snr_to_signal(si->node, config.min_connect_snr);
 	if (si->signal < min_signal) {