From patchwork Fri Jul 31 13:19:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 38509 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6VDKSu5000668 for ; Fri, 31 Jul 2009 13:20:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbZGaNTt (ORCPT ); Fri, 31 Jul 2009 09:19:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752745AbZGaNTt (ORCPT ); Fri, 31 Jul 2009 09:19:49 -0400 Received: from mail-fx0-f217.google.com ([209.85.220.217]:59233 "EHLO mail-fx0-f217.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752712AbZGaNTq (ORCPT ); Fri, 31 Jul 2009 09:19:46 -0400 Received: by fxm17 with SMTP id 17so1362234fxm.37 for ; Fri, 31 Jul 2009 06:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer; bh=sBpezKm3S2K4JWcm+sTShltV10uHuHR3KGSUI8iion0=; b=hHZqSwXD/nK/iCHcZsPLWBwtLcqYg4eJJagFF/FXGQPGVBgf8NGduwsy9BmorZ4Z8/ daYKJ8zW8WUMhdZtz+D3i9KNWyiH8IWsyVkB7t3lq8HrQVmGzpSBSI5Vf3gNc2QQvwe3 qYCHXGRBEOCmQE+Ljmo6v0V1ge8GJQpuN4OAc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer; b=o1b1uP+yxU2XthvdxS2GLcRQe797X2Ibc+R2YFiHxqFIZyW5Ubf0LwmeA1uL9UJdiN NAN0K3VZnpBNzCZSy5+7i1pO11EbPbwqouvY6RCkd2nH6jf1zepDNzMJAReoLCDP3Blo cT51/KQATgfl7wp/EfVZ/XV+KIa5Z9+mVPYJg= Received: by 10.103.224.8 with SMTP id b8mr1501813mur.118.1249046385561; Fri, 31 Jul 2009 06:19:45 -0700 (PDT) Received: from ?10.1.0.2? ([77.127.66.12]) by mx.google.com with ESMTPS id n10sm19263703mue.49.2009.07.31.06.19.42 (version=SSLv3 cipher=RC4-MD5); Fri, 31 Jul 2009 06:19:44 -0700 (PDT) Subject: Re: [PATCH] mac80211: use beacons for connection monitoring From: Maxim Levitsky To: Johannes Berg Cc: Reinette Chatre , linville@tuxdriver.com, linux-wireless@vger.kernel.org In-Reply-To: <1249026181.29587.14.camel@johannes.local> References: <1248903159-17024-1-git-send-email-reinette.chatre@intel.com> <1249024097.7653.6.camel@maxim-laptop> <1249026181.29587.14.camel@johannes.local> Date: Fri, 31 Jul 2009 16:19:40 +0300 Message-Id: <1249046380.6418.6.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 2009-07-31 at 09:43 +0200, Johannes Berg wrote: > On Fri, 2009-07-31 at 10:08 +0300, Maxim Levitsky wrote: > > On Wed, 2009-07-29 at 14:32 -0700, Reinette Chatre wrote: > > > From: Reinette Chatre > > > > > > The connection monitor currently relies on probe requests paired > > > with probe responses to ensure that a connection is alive. This is > > > fragile in some environments where probe responses can get lost. > > > When we receive beacons we can also consider the connection to be > > > alive, so cancel connection poll instance when we receive a beacon. > > > > > > The debug message "cancelling probereq poll due to a received beacon" > > > is removed as part of this change as this case is hit very often after > > > the above change and debug log receives significant number of these messages. > > > > In my opinion this is the correct solution > > I did plenty of wireless monitoring, and I see that nobody sends probe > > requests at that rate (1 per second it seems). This is ridiculous. > > Fix it then. Offer an implementation of your superior solution. We've > done pretty much exactly what you're all pointing out _forever_ in > mac80211, ever since it was initially merged. Now that it's more > explicit in the code, people are complaining? > > johannes Here it is: First patch makes the probe requests be retried (and with it and only it, my connection is very stable, it never retries more that 3 times, and I set max retries to 5) Second patch, trivial one bumps up the timeouts (30 for ping, and 1/2 for response, so device won't send out frames too often) I attach the patches, since I afraid my mailer would mangle them. Here they are in-line too: ------------------------------------------------------------------------------------------------- [MAC80211] Retry probe request few times, before assuming that AP is out of range From: Maxim Levitsky Fixes very often reconnects while connected to nearby APs Signed-off-by: Maxim Levitky --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) [MAC80211] Retry probe request few times, before assuming that AP is out of range From: Maxim Levitsky Fixes very often reconnects while connected to nearby APs Signed-off-by: Maxim Levitky --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index aec6853..ac2489b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -280,6 +280,7 @@ struct ieee80211_if_managed { struct work_struct beacon_loss_work; unsigned long probe_timeout; + unsigned long probe_miss_count; struct mutex mtx; struct ieee80211_bss *associated; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ee83125..38ef7f2 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -31,6 +31,7 @@ #define IEEE80211_AUTH_MAX_TRIES 3 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) #define IEEE80211_ASSOC_MAX_TRIES 3 +#define IEEE80211_ASSOC_RETRIES 5 /* * beacon loss detection timeout @@ -1209,6 +1210,7 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, ieee80211_recalc_ps(sdata->local, -1); mutex_unlock(&sdata->local->iflist_mtx); + sdata->u.mgd.probe_miss_count = 0; ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, ssid + 2, ssid[1], NULL, 0); @@ -2072,17 +2074,36 @@ static void ieee80211_sta_work(struct work_struct *work) if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | IEEE80211_STA_CONNECTION_POLL) && ifmgd->associated) { + + u8 bssid[ETH_ALEN]; + const u8 *ssid; + + memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); + if (time_is_after_jiffies(ifmgd->probe_timeout)) run_again(ifmgd, ifmgd->probe_timeout); - else { - u8 bssid[ETH_ALEN]; + + else if (ifmgd->probe_miss_count < IEEE80211_ASSOC_RETRIES) { + + printk(KERN_DEBUG "No probe response from AP %pM" + " after %dms, try %d\n", bssid, + (1000 * IEEE80211_PROBE_WAIT)/HZ, + (int)ifmgd->probe_miss_count); + + ifmgd->probe_miss_count++; + ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT; + run_again(ifmgd, ifmgd->probe_timeout); + + ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); + ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, + ssid + 2, ssid[1], NULL, 0); + } else { /* * We actually lost the connection ... or did we? * Let's make sure! */ ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | IEEE80211_STA_BEACON_POLL); - memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); printk(KERN_DEBUG "No probe response from AP %pM" " after %dms, disconnecting.\n", bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); [MAC80211] Increase timeouts for AP polling From: Maxim Levitsky Do a poll every 30 seconds, and wait for response half a second Signed-off-by: Maxim Levitsky --- net/mac80211/mlme.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 38ef7f2..a8ab40c 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -42,13 +42,13 @@ * Time the connection can be idle before we probe * it to see if we can still talk to the AP. */ -#define IEEE80211_CONNECTION_IDLE_TIME (2 * HZ) +#define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ) /* * Time we wait for a probe response after sending * a probe request because of beacon loss or for * checking the connection still works. */ -#define IEEE80211_PROBE_WAIT (HZ / 5) +#define IEEE80211_PROBE_WAIT (HZ / 2) #define TMR_RUNNING_TIMER 0 #define TMR_RUNNING_CHANSW 1 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index aec6853..ac2489b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -280,6 +280,7 @@ struct ieee80211_if_managed { struct work_struct beacon_loss_work; unsigned long probe_timeout; + unsigned long probe_miss_count; struct mutex mtx; struct ieee80211_bss *associated; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ee83125..38ef7f2 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -31,6 +31,7 @@ #define IEEE80211_AUTH_MAX_TRIES 3 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) #define IEEE80211_ASSOC_MAX_TRIES 3 +#define IEEE80211_ASSOC_RETRIES 5 /* * beacon loss detection timeout @@ -1209,6 +1210,7 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, ieee80211_recalc_ps(sdata->local, -1); mutex_unlock(&sdata->local->iflist_mtx); + sdata->u.mgd.probe_miss_count = 0; ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, ssid + 2, ssid[1], NULL, 0); @@ -2072,17 +2074,36 @@ static void ieee80211_sta_work(struct work_struct *work) if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | IEEE80211_STA_CONNECTION_POLL) && ifmgd->associated) { + + u8 bssid[ETH_ALEN]; + const u8 *ssid; + + memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); + if (time_is_after_jiffies(ifmgd->probe_timeout)) run_again(ifmgd, ifmgd->probe_timeout); - else { - u8 bssid[ETH_ALEN]; + + else if (ifmgd->probe_miss_count < IEEE80211_ASSOC_RETRIES) { + + printk(KERN_DEBUG "No probe response from AP %pM" + " after %dms, try %d\n", bssid, + (1000 * IEEE80211_PROBE_WAIT)/HZ, + (int)ifmgd->probe_miss_count); + + ifmgd->probe_miss_count++; + ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT; + run_again(ifmgd, ifmgd->probe_timeout); + + ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); + ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, + ssid + 2, ssid[1], NULL, 0); + } else { /* * We actually lost the connection ... or did we? * Let's make sure! */ ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | IEEE80211_STA_BEACON_POLL); - memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); printk(KERN_DEBUG "No probe response from AP %pM" " after %dms, disconnecting.\n", bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); ------------------------------------------------------------------------------------------ [MAC80211] Increase timeouts for AP polling From: Maxim Levitsky Do a poll every 30 seconds, and wait for response half a second Signed-off-by: Maxim Levitsky --- net/mac80211/mlme.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 38ef7f2..a8ab40c 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -42,13 +42,13 @@ * Time the connection can be idle before we probe * it to see if we can still talk to the AP. */ -#define IEEE80211_CONNECTION_IDLE_TIME (2 * HZ) +#define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ) /* * Time we wait for a probe response after sending * a probe request because of beacon loss or for * checking the connection still works. */ -#define IEEE80211_PROBE_WAIT (HZ / 5) +#define IEEE80211_PROBE_WAIT (HZ / 2) #define TMR_RUNNING_TIMER 0 #define TMR_RUNNING_CHANSW 1