From patchwork Wed Apr 4 20:44:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0JTQvNC40YLRgNC40Lkg0JvQtdCx0LXQtNGM?= X-Patchwork-Id: 895165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HMlzeJ7L"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NWuX3ObV"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40GdHv4kLDz9ry1 for ; Thu, 5 Apr 2018 06:44:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GYlbhu/NI5mnU524Z4VdEMkRaoejcv98g5aFOZ4Sgsc=; b=HMlzeJ7LpOPYpTi1ZdTMrsAldo 5apM4gvBk5VHgEmU82rbqr+7Ak9ALFW74QIfj1ycPUaNFln+up7dsmof6Lm4nX6FPv2EZCnxK0HcZ xIIDV9e8tqc/wCgJNbkg21JlvUqrvKkvfbX/qcAgpNorpssRXr8tjl7ECf15L4x43EX8GYVdqLvFl i6BmaOPkeog2vP860l2uVeykuW1S3NlSWYxV0HnZmCTsxviAyCeERF9G7RVPmQEmBhVz5+Mhv0Gs6 qAUnopFp0Pjlx4aw17qkVkB7GbbhG5RW3tmStKTar8e+fRqRpvp+FjB/YTbVnTEtdCFe4lDheslcM zA2xnHsA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3pH5-0003jz-7X; Wed, 04 Apr 2018 20:44:55 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3pGt-0003Z4-Pr for hostap@lists.infradead.org; Wed, 04 Apr 2018 20:44:46 +0000 Received: by mail-wm0-x244.google.com with SMTP id t67so593128wmt.0 for ; Wed, 04 Apr 2018 13:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TAUZoMztm7aqrW2aaQWAKc8CFjhKXP7dy7LzchSRk4A=; b=NWuX3ObVaDV9pZI7XW34mtdpfeQiOv+DYvLkjMWibu3gmfmy4K2acuvpl7cVMb+930 R8BL7FSa3dFQkdLQDDY+7YXRcc3BfOco+QGSgWwKKOFdeUpDdS36V0X9ayPGIFLBgFP1 2W50LoYrc+OvsK0fw/AVbzTdXb7xMNc+9nuVkBuX25CtDKUOnjdHtZ+n2QjpotcT63nI Vm0DdD3Ql1GDTFK+0bmcyN6zX58Ogt0BZFWsQZRPZuXVoztjE6mZOE/jYgdkyAZOoMmp +Cxp1FySK9rChWK4hdyukzQaA5u35fb4snCwzt13+ztJzvJbpX9ZElaNnTE6Njg96xSD DZ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TAUZoMztm7aqrW2aaQWAKc8CFjhKXP7dy7LzchSRk4A=; b=P0Kz381DGhWkMGVEU6lSNhqHz1RhuLDpbvE20FLv1ITIjs0KtbR12nbl0Rn3z2+4Gf NHD9sb80FP81bT+QaahPe7YUrypJR1Qfp+JWjZjbHWEkuFwEmrj2Kl517x0G1bb2EpG8 ixXfSiT0h3uhf5Pm7v+jqtL8wUmDQ1LQXbNfGwSvqoALGMPtKOx8gTEHlGMETvYFjUss ouaSy4RQyChWEJ31DO2IuDL4p6ow+iiIjjvRhh8rMiOy+DriMHMhq/F5HvSYCZHN7Nae 4cEHVTVDTCZDn6aaxePPC3JSTAm29DucU5wIX0rmVCDv9QQ5AYaRpZwAkaL6Bphzqk1h BCVw== X-Gm-Message-State: ALQs6tBVUzYuB7gchEHUkbeydP0wushNGb98vVpNqlBK6WOtYEl4vBJ8 xyS9UakHNiGAltm42JqGjoW/X2hV X-Google-Smtp-Source: AIpwx48E5F6HVIe3CpO+7l2n+V776UM2F+FAtcqYFotTYxS0XlDmP10K6ZOvbLXR0zinf1Nb+S1y/g== X-Received: by 10.46.71.12 with SMTP id u12mr12207303lja.36.1522874669467; Wed, 04 Apr 2018 13:44:29 -0700 (PDT) Received: from dimaz-laptop.quantenna.com (ip-195-182-157-78.clients.cmk.ru. [195.182.157.78]) by smtp.gmail.com with ESMTPSA id o25sm1022555lji.14.2018.04.04.13.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 13:44:28 -0700 (PDT) From: Dmitry Lebed To: hostap@lists.infradead.org Subject: [PATCH 2/2] wpa_supplicant: increase AUTH timeout if CAC is started Date: Wed, 4 Apr 2018 23:44:08 +0300 Message-Id: <20180404204408.4396-2-lebed.dmitry@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180404204408.4396-1-lebed.dmitry@gmail.com> References: <20180404204408.4396-1-lebed.dmitry@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180404_134443_911217_0F184C23 X-CRM114-Status: GOOD ( 19.48 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lebed.dmitry[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Lebed MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Dmitry Lebed Increase AUTH timeout if CAC is started while AUTH timeout is active. Timeout is increased by dfs_cac_ms from channel data, or by max CAC time (10 minutes) if dfs_cac_ms is not defined. It's needed for some complex cases, e.g. when STA is acting as active slave with DFS offload enabled and decided to start CAC after receiving CONNECT command, in such case 10s timeout is too small and wpa_supplicant need to wait for CAC completion or CAC timeout (up to 10 minutes). Without such timeout modification wpa_supplicant will unable to connect to AP on DFS channel, since default AUTH timeout (10s) is smaller than minumum CAC time (60s). Tested with nl80211 DFS offload implementation. Signed-off-by: Dmitry Lebed --- wpa_supplicant/events.c | 97 +++++++++++++++++++++++++++++++++++---- wpa_supplicant/wpa_supplicant.c | 21 +++++++++ wpa_supplicant/wpa_supplicant_i.h | 4 ++ 3 files changed, 112 insertions(+), 10 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index bb76ca93d..e6a693a7d 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3770,6 +3770,80 @@ static void wpa_supplicant_event_port_authorized(struct wpa_supplicant *wpa_s) } } +static size_t wpa_supplicant_event_cac_ms(const struct wpa_supplicant *wpa_s, + int freq) +{ + size_t i, j; + + for (i = 0; i < wpa_s->hw.num_modes; i++) { + const struct hostapd_hw_modes *mode = &wpa_s->hw.modes[i]; + + for (j = 0; j < mode->num_channels; j++) { + const struct hostapd_channel_data *chan; + + chan = &mode->channels[j]; + if (chan->freq == freq) + return chan->dfs_cac_ms; + } + } + + return 0; +} + +static void wpa_supplicant_event_dfs_cac_started(struct wpa_supplicant *wpa_s, + struct dfs_event *radar) +{ +#if defined(NEED_AP_MLME) && defined(CONFIG_AP) + if (wpa_s->ap_iface != NULL) { + wpas_ap_event_dfs_cac_started(wpa_s, radar); + } else +#endif + { + size_t cac_time = wpa_supplicant_event_cac_ms(wpa_s, + radar->freq); + + cac_time /= 1000; /* convert from ms to sec */ + + if (!cac_time) + cac_time = 10 * 60; /* max timeout - 10 minutes */ + + /* restart auth timeout: CAC time added to initial timeout */ + wpa_supplicant_auth_timeout_restart(wpa_s, cac_time); + } +} + + +static void wpa_supplicant_event_dfs_cac_finished(struct wpa_supplicant *wpa_s, + struct dfs_event *radar) +{ +#if defined(NEED_AP_MLME) && defined(CONFIG_AP) + if (wpa_s->ap_iface != NULL) { + wpas_ap_event_dfs_cac_finished(wpa_s, radar); + } else +#endif + { + /* restart auth timeout with original value + * after CAC is finished */ + wpa_supplicant_auth_timeout_restart(wpa_s, 0); + } +} + + +static void wpa_supplicant_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s, + struct dfs_event *radar) +{ +#if defined(NEED_AP_MLME) && defined(CONFIG_AP) + if (wpa_s->ap_iface != NULL) { + wpas_ap_event_dfs_cac_aborted(wpa_s, radar); + } else +#endif + { + /* restart auth timeout with original value + * after CAC is aborted */ + wpa_supplicant_auth_timeout_restart(wpa_s, 0); + } +} + static void wpa_supplicant_event_assoc_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) @@ -4185,25 +4259,28 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, if (data) wpas_ap_event_dfs_radar_detected(wpa_s, &data->dfs_event); break; + case EVENT_DFS_NOP_FINISHED: + if (data) + wpas_ap_event_dfs_cac_nop_finished(wpa_s, + &data->dfs_event); + break; +#endif /* NEED_AP_MLME */ +#endif /* CONFIG_AP */ case EVENT_DFS_CAC_STARTED: if (data) - wpas_ap_event_dfs_cac_started(wpa_s, &data->dfs_event); + wpa_supplicant_event_dfs_cac_started(wpa_s, + &data->dfs_event); break; case EVENT_DFS_CAC_FINISHED: if (data) - wpas_ap_event_dfs_cac_finished(wpa_s, &data->dfs_event); + wpa_supplicant_event_dfs_cac_finished(wpa_s, + &data->dfs_event); break; case EVENT_DFS_CAC_ABORTED: if (data) - wpas_ap_event_dfs_cac_aborted(wpa_s, &data->dfs_event); - break; - case EVENT_DFS_NOP_FINISHED: - if (data) - wpas_ap_event_dfs_cac_nop_finished(wpa_s, - &data->dfs_event); + wpa_supplicant_event_dfs_cac_aborted(wpa_s, + &data->dfs_event); break; -#endif /* NEED_AP_MLME */ -#endif /* CONFIG_AP */ case EVENT_RX_MGMT: { u16 fc, stype; const struct ieee80211_mgmt *mgmt; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index dcec68a03..b9fed8136 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -243,10 +243,31 @@ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, wpa_dbg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec " "%d usec", sec, usec); eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL); + wpa_s->last_auth_timeout_sec = sec; eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL); } +/* + * wpa_supplicant_auth_timeout_restart - Restart and change timeout + * @wpa_s: Pointer to wpa_supplicant data + * @sec_diff: difference in seconds applied to original timeout value + */ +void wpa_supplicant_auth_timeout_restart(struct wpa_supplicant *wpa_s, + int sec_diff) +{ + int new_sec = wpa_s->last_auth_timeout_sec + sec_diff; + + if (eloop_is_timeout_registered(wpa_supplicant_timeout, wpa_s, NULL)) { + wpa_dbg(wpa_s, MSG_DEBUG, + "Authentication timeout restart: %d sec ", new_sec); + eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL); + eloop_register_timeout(new_sec, 0, wpa_supplicant_timeout, + wpa_s, NULL); + } +} + + /** * wpa_supplicant_cancel_auth_timeout - Cancel authentication timeout * @wpa_s: Pointer to wpa_supplicant data diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d5bfa7ddf..3f3f6b755 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1182,6 +1182,8 @@ struct wpa_supplicant { /* RIC elements for FT protocol */ struct wpabuf *ric_ies; + int last_auth_timeout_sec; + #ifdef CONFIG_DPP struct dl_list dpp_bootstrap; /* struct dpp_bootstrap_info */ struct dl_list dpp_configurator; /* struct dpp_configurator */ @@ -1255,6 +1257,8 @@ void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s); void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr); void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, int sec, int usec); +void wpa_supplicant_auth_timeout_restart(struct wpa_supplicant *wpa_s, + int sec_diff); void wpa_supplicant_reinit_autoscan(struct wpa_supplicant *wpa_s); void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, enum wpa_states state);