diff mbox series

[usteer,v3,3/9] Added a countdown before kicking the station like described in IEEE

Message ID 20241107112313.507-4-n.rottgardt@gmail.com
State New
Headers show
Series Better handling of unfriendly STAs / IEEE enhancements / MBO | expand

Commit Message

Nils Hendrik Rottgardt Nov. 7, 2024, 11:23 a.m. UTC
- Disassociation Timer will run a countdown before disassociate the station if roam_kick_delay is longer than validity_period (actually fixed to 100 beacon intervals)
- Supporting multiple transisiton requests if validity period is run out

Signed-off-by: Nils Hendrik Rottgardt <n.rottgardt@gmail.com>
---
 band_steering.c | 23 ++++++++++++-----------
 policy.c        | 10 +++++++---
 usteer.h        |  1 +
 3 files changed, 20 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/band_steering.c b/band_steering.c
index d680d02..17eca32 100644
--- a/band_steering.c
+++ b/band_steering.c
@@ -83,8 +83,6 @@  void usteer_band_steering_perform_steer(struct usteer_local_node *ln)
 	ln->band_steering_interval = 0;
 
 	list_for_each_entry(si, &ln->node.sta_info, node_list) {
-		/* TODO: Steer only if Client supports > 4000 Frequency */
-
 		/* Check if client is eligable to be steerd */
 		if (!usteer_policy_can_perform_roam(si))
 			continue;
@@ -95,17 +93,20 @@  void usteer_band_steering_perform_steer(struct usteer_local_node *ln)
 			continue;
 		}
 
+		/* Skip if in validity period */
+		if (current_time < si->roam_transition_request_validity_end)
+			continue;
+
 		if (si->bss_transition) {
-			if (!si->kick_time && si->sta->aggressive) {
-				si->kick_time = current_time + config.roam_kick_delay;
-				validity_period = 10000 / usteer_local_node_get_beacon_interval(ln); /* ~ 10 seconds */
+			si->roam_transition_request_validity_end = current_time + 10000;
+			validity_period = 10000 / usteer_local_node_get_beacon_interval(ln); /* ~ 10 seconds */
+			if (si->sta->aggressive) {
+				if (!si->kick_time)
+					si->kick_time = current_time + config.roam_kick_delay;
 				disassoc_timer = (si->kick_time - current_time) / usteer_local_node_get_beacon_interval(ln);
-
-				if (si->sta->aggressive)
-					usteer_ubus_band_steering_request(si, 0, true, disassoc_timer, true, validity_period);
-				else
-					usteer_ubus_band_steering_request(si, 0, false, 0, true, validity_period);
-			}
+				usteer_ubus_band_steering_request(si, 0, true, disassoc_timer, true, validity_period);
+			} else
+				usteer_ubus_band_steering_request(si, 0, false, 0, true, validity_period);
 		}
 
 		si->band_steering.below_snr = false;
diff --git a/policy.c b/policy.c
index b3af22b..b6b393f 100644
--- a/policy.c
+++ b/policy.c
@@ -373,11 +373,11 @@  usteer_roam_trigger_sm(struct usteer_local_node *ln, struct sta_info *si)
 			break;
 		}
 
-		if (!si->kick_time && si->sta->aggressive)
-			si->kick_time = current_time + config.roam_kick_delay;
-
+		si->roam_transition_request_validity_end = current_time + 10000;
 		validity_period = 10000 / usteer_local_node_get_beacon_interval(ln); /* ~ 10 seconds */
 		if (si->sta->aggressive) {
+			if (!si->kick_time)
+				si->kick_time = current_time + config.roam_kick_delay;
 			disassoc_timer = (si->kick_time - current_time) / usteer_local_node_get_beacon_interval(ln);
 			usteer_ubus_bss_transition_request(si, 1, true, disassoc_timer, true, validity_period, candidate->node);
 		} else {
@@ -401,6 +401,10 @@  bool usteer_policy_can_perform_roam(struct sta_info *si)
 	if (si->kick_time && si->kick_time <= current_time)
 		return false;
 
+	/* Skip if in validity period */
+	if (current_time < si->roam_transition_request_validity_end)
+		return false;
+
 	/* Skip on rejected transition */
 	if (si->bss_transition_response.status_code && current_time - si->bss_transition_response.timestamp < config.steer_reject_timeout)
 		return false;
diff --git a/usteer.h b/usteer.h
index 7a399db..ec6e251 100644
--- a/usteer.h
+++ b/usteer.h
@@ -258,6 +258,7 @@  struct sta_info {
 	enum roam_trigger_state roam_state;
 	uint8_t roam_tries;
 	uint64_t roam_event;
+	uint64_t roam_transition_request_validity_end;
 	uint64_t roam_kick;
 	uint64_t roam_scan_start;
 	uint64_t roam_scan_timeout_start;