policy: improve readability
authorDavid Bauer <mail@david-bauer.net>
Wed, 17 Aug 2022 00:06:08 +0000 (02:06 +0200)
committerDavid Bauer <mail@david-bauer.net>
Wed, 17 Aug 2022 20:07:42 +0000 (22:07 +0200)
Signed-off-by: David Bauer <mail@david-bauer.net>
policy.c

index 9d62b780688efb82e35cf6300f8bb789b8e94843..1a96cfa09e01a2bf99a366104438d3c479273848 100644 (file)
--- a/policy.c
+++ b/policy.c
@@ -378,6 +378,32 @@ usteer_roam_trigger_sm(struct usteer_local_node *ln, struct sta_info *si)
        return false;
 }
 
+static bool
+usteer_local_node_roam_sm_active(struct sta_info *si, int min_signal)
+{
+       /* Only trigger for connected STAs */
+       if (si->connected != STA_CONNECTED)
+               return false;
+
+       /* Signal has to be below scan / roam threshold */
+       if (si->signal >= min_signal)
+               return false;
+
+       /* Skip on pending kick */
+       if (si->kick_time)
+               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;
+
+       /* Skip on previous kick attempt */
+       if (current_time - si->roam_kick < config.roam_trigger_interval)
+               return false;
+       
+       return true;
+}
+
 static void
 usteer_local_node_roam_check(struct usteer_local_node *ln, struct uevent *ev)
 {
@@ -395,10 +421,7 @@ usteer_local_node_roam_check(struct usteer_local_node *ln, struct uevent *ev)
        min_signal = usteer_snr_to_signal(&ln->node, min_signal);
 
        list_for_each_entry(si, &ln->node.sta_info, node_list) {
-               if (si->connected != STA_CONNECTED || si->signal >= min_signal ||
-                       si->kick_time ||
-                       (si->bss_transition_response.status_code && current_time - si->bss_transition_response.timestamp < config.steer_reject_timeout) ||
-                   current_time - si->roam_kick < config.roam_trigger_interval) {
+               if (!usteer_local_node_roam_sm_active(si, min_signal)) {
                        usteer_roam_set_state(si, ROAM_TRIGGER_IDLE, ev);
                        continue;
                }