Skip to contentSkip to conversation

station: check for roam timeout before rearming

PATCH In review James Prestwood 2 participants 4 messages Aug 27, 2024 – Aug 28, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 station: check for roam timeout before rearming

A user reported a crash which was due to the roam trigger timeout being overwritten, followed by a disconnect. Post-disconnect the timer would fire and result in a crash. Its not clear exactly where the overwrite was happening but upon code inspection it could happen in the following scenario:

1. Beacon loss event, start roam timeout
2. Signal low event, no check if timeout is running and the timeout gets overwritten.

The reported crash actually didn't appear to be from the above scenario but something else, so now all instances where the timer is rearmed we also check if there is already a timer set.

---
 src/station.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
src/station.c +5 -2
index 30a1232a..e188aed4 100644
@@ -2221,7 +2221,7 @@ static void station_roamed(struct station *station)
 	 * Schedule another roaming attempt in case the signal continues to
 	 * remain low. A subsequent high signal notification will cancel it.
 	 */
-	if (station->signal_low)
+	if (station->signal_low && L_WARN_ON(!station->roam_trigger_timeout))
 		station_roam_timeout_rearm(station, roam_retry_interval);
 
 	if (station->netconfig)
@@ -2260,7 +2260,7 @@ static void station_roam_retry(struct station *station)
 	station->roam_scan_full = false;
 	station->ap_directed_roaming = false;
 
-	if (station->signal_low)
+	if (station->signal_low && !station->roam_trigger_timeout)
 		station_roam_timeout_rearm(station, roam_retry_interval);
 }
 
@@ -3202,6 +3202,9 @@ static void station_low_rssi(struct station *station)
 	if (station_cannot_roam(station))
 		return;
 
+	if (station->roam_trigger_timeout)
+		return;
+
 	/* Set a 5-second initial timeout */
 	station_roam_timeout_rearm(station, 5);
 }
Signature · 1 line
2.34.1
#1 lore raw

Hi James,

Quoted 22 lines · James Prestwood

A user reported a crash which was due to the roam trigger timeout being overwritten, followed by a disconnect. Post-disconnect the timer would fire and result in a crash. Its not clear exactly where the overwrite was happening but upon code inspection it could happen in the following scenario:

1. Beacon loss event, start roam timeout
2. Signal low event, no check if timeout is running and the timeout gets overwritten.

The reported crash actually didn't appear to be from the above scenario but something else, so now all instances where the timer is rearmed we also check if there is already a timer set.

---
  src/station.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
src/station.c +0 -0
index 30a1232a..e188aed4 100644

src/station.c static void station_roamed(struct station *station) · line 2224

Quoted 5 lines
src/station.c +1 -1
@@ -2221,7 +2221,7 @@ static void station_roamed(struct station *station)
  	 * Schedule another roaming attempt in case the signal continues to
  	 * remain low. A subsequent high signal notification will cancel it.
  	 */
-	if (station->signal_low)
+	if (station->signal_low && L_WARN_ON(!station->roam_trigger_timeout))

I'm reading this as:
if signal_low and roam_trigger_timeout is NULL:
1. print a warning
2. rearm the timer

Is 1. intended?

Quoted 13 lines
src/station.c +1 -1
  		station_roam_timeout_rearm(station, roam_retry_interval);
 
  	if (station->netconfig)
@@ -2260,7 +2260,7 @@ static void station_roam_retry(struct station *station)
  	station->roam_scan_full = false;
  	station->ap_directed_roaming = false;
 
-	if (station->signal_low)
+	if (station->signal_low && !station->roam_trigger_timeout)
  		station_roam_timeout_rearm(station, roam_retry_interval);
  }
 

src/station.c static void station_low_rssi(struct station *station) · line 3207

Quoted 6 lines
src/station.c +3 -0
@@ -3202,6 +3202,9 @@ static void station_low_rssi(struct station *station)
  	if (station_cannot_roam(station))
  		return;
 
+	if (station->roam_trigger_timeout)
+		return;
+

One thing I'm a bit worried about with such a simple approach is that we might have different roam timeouts. For example, the 60 second roam retry interval is active and we get a low rssi event. In this case we probably should schedule a roam sooner. Maybe we should book-keep timeout information better better and make sure the timeout happens within the minimum time (active time remaining / new timeout)?

src/station.c static void station_low_rssi(struct station *station) · line 3210

Quoted 3 lines
src/station.c +0 -0
  	/* Set a 5-second initial timeout */
  	station_roam_timeout_rearm(station, 5);
  }

Regards,
-Denis

#2 lore raw

Hi Denis,

Quoted 50 lines · Denis Kenzior

Hi James,

Quoted 22 lines · James Prestwood

A user reported a crash which was due to the roam trigger timeout being overwritten, followed by a disconnect. Post-disconnect the timer would fire and result in a crash. Its not clear exactly where the overwrite was happening but upon code inspection it could happen in the following scenario:

1. Beacon loss event, start roam timeout
2. Signal low event, no check if timeout is running and the timeout gets overwritten.

The reported crash actually didn't appear to be from the above scenario but something else, so now all instances where the timer is rearmed we also check if there is already a timer set.
---
  src/station.c | 7 +++++--

  1 file changed, 5 insertions(+), 2 deletions(-)
src/station.c +0 -0
index 30a1232a..e188aed4 100644

src/station.c static void station_roamed(struct station · line 2226

Quoted 7 lines
src/station.c +1 -1
@@ -2221,7 +2221,7 @@ static void station_roamed(struct station 
 *station)
        * Schedule another roaming attempt in case the signal continues to
        * remain low. A subsequent high signal notification will cancel it.
        */
-    if (station->signal_low)
+    if (station->signal_low && 
 L_WARN_ON(!station->roam_trigger_timeout))

I'm reading this as:
if signal_low and roam_trigger_timeout is NULL:
    1. print a warning
    2. rearm the timer

Is 1. intended?

Quoted 10 lines
src/station.c +0 -0
 station_roam_timeout_rearm(station, roam_retry_interval);

        if (station->netconfig)

src/station.c +1 -0
@@ -2260,7 +2260,7 @@ static void station_roam_retry(struct station 
 *station)
       station->roam_scan_full = false;
       station->ap_directed_roaming = false;
   -    if (station->signal_low)
+    if (station->signal_low && !station->roam_trigger_timeout)
           station_roam_timeout_rearm(station, roam_retry_interval);
   }
Quoted 8 lines
Quoted 6 lines

  @@ -3202,6 +3202,9 @@ static void station_low_rssi(struct station *station) if (station_cannot_roam(station))
          return;
  +    if (station->roam_trigger_timeout)
+        return;
+

One thing I'm a bit worried about with such a simple approach is that we might have different roam timeouts.  For example, the 60 second roam retry interval is active and we get a low rssi event. In this case we probably should schedule a roam sooner.  Maybe we should book-keep timeout information better better and make sure the timeout happens within the minimum time (active time remaining / new timeout)?

Sure, the thought crossed my mind as well. Looks like there is no way to get the active timeout within the l_timeout itself, it doesn't track that so we can manually.

Quoted 7 lines
Quoted 4 lines

      /* Set a 5-second initial timeout */
      station_roam_timeout_rearm(station, 5);
  }

Regards,
-Denis

#3 lore raw

Hi James,

Quoted 3 lines
Quoted 2 lines

One thing I'm a bit worried about with such a simple approach is that we might have different roam timeouts.  For example, the 60 second roam retry interval is active and we get a low rssi event. In this case we probably should schedule a roam sooner.  Maybe we should book-keep timeout information better better and make sure the timeout happens within the minimum time (active time remaining / new timeout)?

Sure, the thought crossed my mind as well. Looks like there is no way to get the active timeout within the l_timeout itself, it doesn't track that so we can manually.

You might be able to add something into ell using timerfd_gettime.

Regards,
-Denis