From patchwork Sun Nov 10 20:26:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 3165891 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D70B29F3A0 for ; Sun, 10 Nov 2013 20:33:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9C0220373 for ; Sun, 10 Nov 2013 20:33:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07A1C2035D for ; Sun, 10 Nov 2013 20:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752101Ab3KJUdg (ORCPT ); Sun, 10 Nov 2013 15:33:36 -0500 Received: from mail-oa0-f46.google.com ([209.85.219.46]:45751 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882Ab3KJUdf (ORCPT ); Sun, 10 Nov 2013 15:33:35 -0500 Received: by mail-oa0-f46.google.com with SMTP id m1so1443782oag.33 for ; Sun, 10 Nov 2013 12:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=g2kVu6z9PJM5KhKNeqTQyWpf8x/dp7LA2gzN137n05s=; b=hLq+PNUVyN4/CWeC54135BnzSH7ut8Fm46eePwe4wVTa2gghwON1ghx/KAWGIX1y+q h7WZYDYGIvOOnBdwBX6uIpBkkMuzhXFMDYjMJosEi8mbLRz1SRae4jamB2K/WyMfpcto a1tpPdnuvkKN+/XuhIfck/IObC9jxy6yqk3O7UjLjT0jtLWDLHTDPoXyzltfBNKhd7M8 ze5cigkAB5M8W/0P325Ijnx0KrdUatUgoJ0IN/P7t7F00JmLHCVTz3yoe0o+snCrYJSV gzV6LvctgZ0+lFWOOuM+EGIKCI4Z3NQo3dmq5Zr3ql3Nsx8cSk8Jq96T3sBignGVLQTt 81/w== X-Received: by 10.182.213.97 with SMTP id nr1mr2501906obc.48.1384115615049; Sun, 10 Nov 2013 12:33:35 -0800 (PST) Received: from localhost (187-162-140-241.static.axtel.net. [187.162.140.241]) by mx.google.com with ESMTPSA id xr8sm21442810obc.12.2013.11.10.12.33.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Nov 2013 12:33:34 -0800 (PST) From: Felipe Contreras To: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, "John W. Linville" , Johannes Berg , "David S. Miller" , Felipe Contreras Subject: [PATCH] mac80211: add assoc beacon timeout logic Date: Sun, 10 Nov 2013 14:26:45 -0600 Message-Id: <1384115205-3820-1-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.8.4.2+fc1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We don't want to be waiting forever for a beacon that will never come, just continue the association. Signed-off-by: Felipe Contreras --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 611abfc..e1f858d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -358,6 +358,7 @@ struct ieee80211_mgd_assoc_data { const u8 *supp_rates; unsigned long timeout; + unsigned long beacon_timeout; int tries; u16 capability; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 529cef6..1c14484 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -38,6 +38,7 @@ #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) #define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2) #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) +#define IEEE80211_ASSOC_BEACON_TIMEOUT 2 * HZ #define IEEE80211_ASSOC_MAX_TRIES 3 static int max_nullfunc_tries = 2; @@ -3537,10 +3538,18 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) if (assoc_data && assoc_data->timeout_started) { if (time_after(jiffies, assoc_data->timeout)) { - if ((assoc_data->need_beacon && !ifmgd->have_beacon) || - ieee80211_do_assoc(sdata)) { - struct cfg80211_bss *bss = assoc_data->bss; - + struct cfg80211_bss *bss = assoc_data->bss; + + if (assoc_data->need_beacon && !ifmgd->have_beacon) { + if (time_after(jiffies, assoc_data->beacon_timeout)) { + sdata_info(sdata, "no beacon from %pM\n", bss->bssid); + assoc_data->need_beacon = false; + assoc_data->timeout = jiffies; + } else { + assoc_data->timeout = TU_TO_EXP_TIME(bss->beacon_interval); + } + run_again(sdata, assoc_data->timeout); + } else if (ieee80211_do_assoc(sdata)) { ieee80211_destroy_assoc_data(sdata, false); cfg80211_assoc_timeout(sdata->dev, bss); } @@ -4341,6 +4350,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, sdata_info(sdata, "waiting for beacon from %pM\n", ifmgd->bssid); assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval); + assoc_data->beacon_timeout = jiffies + IEEE80211_ASSOC_BEACON_TIMEOUT; assoc_data->timeout_started = true; assoc_data->need_beacon = true; } else if (beacon_ies) {