Patchwork hostap: Add fuzz to idle-timer calculations.

login
register
mail settings
Submitter Ben Greear
Date April 4, 2012, 5:12 a.m.
Message ID <1333516373-28307-1-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/150597/
State Accepted
Commit ce28e2795ad6a416731c3c57df310168a5c32537
Headers show

Comments

Ben Greear - April 4, 2012, 5:12 a.m.
From: Ben Greear <greearb@candelatech.com>

This should keep us from getting into a state where we bounce
large numbers of interfaces all at once.  Spreading out the
bounce should cause less stress on the network as the idle
stations won't all be trying to reconnect at once.

Signed-hostap: Ben Greear <greearb@candelatech.com>
---
:100644 100644 d8b5621... 3411f71... M	src/ap/sta_info.c
 src/ap/sta_info.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Jouni Malinen - April 6, 2012, 8:49 a.m.
On Tue, Apr 03, 2012 at 10:12:53PM -0700, greearb@candelatech.com wrote:
> This should keep us from getting into a state where we bounce
> large numbers of interfaces all at once.  Spreading out the
> bounce should cause less stress on the network as the idle
> stations won't all be trying to reconnect at once.

Thanks, applied.

Patch

diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index d8b5621..3411f71 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -284,6 +284,11 @@  void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
 	    (sta->timeout_next == STA_NULLFUNC ||
 	     sta->timeout_next == STA_DISASSOC)) {
 		int inactive_sec;
+		/* Add random value to timeout so that we don't end up bouncing
+		 * all stations at the same time if we have lots of associated
+		 * stations that are idle (but keep re-associating).
+		 */
+		int fuzz = os_random() % 20;
 		inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
 		if (inactive_sec == -1) {
 			wpa_msg(hapd->msg_ctx, MSG_DEBUG,
@@ -295,7 +300,7 @@  void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
 			 * Anyway, try again after the next inactivity timeout,
 			 * but do not disconnect the station now.
 			 */
-			next_time = hapd->conf->ap_max_inactivity;
+			next_time = hapd->conf->ap_max_inactivity + fuzz;
 		} else if (inactive_sec < hapd->conf->ap_max_inactivity &&
 			   sta->flags & WLAN_STA_ASSOC) {
 			/* station activity detected; reset timeout state */
@@ -303,7 +308,7 @@  void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
 				"Station " MACSTR " has been active %is ago",
 				MAC2STR(sta->addr), inactive_sec);
 			sta->timeout_next = STA_NULLFUNC;
-			next_time = hapd->conf->ap_max_inactivity -
+			next_time = hapd->conf->ap_max_inactivity + fuzz -
 				inactive_sec;
 		} else {
 			wpa_msg(hapd->msg_ctx, MSG_DEBUG,