From patchwork Tue Jul 10 11:18:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Pubbisetty X-Patchwork-Id: 10516849 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDBC26020F for ; Tue, 10 Jul 2018 11:18:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAF73289EF for ; Tue, 10 Jul 2018 11:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EB5928D53; Tue, 10 Jul 2018 11:18:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 200C6289EF for ; Tue, 10 Jul 2018 11:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933129AbeGJLSu (ORCPT ); Tue, 10 Jul 2018 07:18:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36758 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751992AbeGJLSt (ORCPT ); Tue, 10 Jul 2018 07:18:49 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DEC01606AC; Tue, 10 Jul 2018 11:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531221528; bh=nOwyiN6X6cfUHW4AwiZpWqCUdD5fB4Awg7b+iud8KU0=; h=From:To:Cc:Subject:Date:From; b=JlP76nGbbPlJN4DMblKs6TTIrDFfpyWNLy62bgSzwl7RqtVlu2PGAdnEG6iyLoVg0 CplPbK3vq4Yx+w6EP5plMCh0r9Ni+SO5uYxXq4U+lUCKNtJ/IkASPn9QWxIK3mGauD A+S/B2lBZMWmm/VsirkawqL4Qas+6PT7x2tdORdQ= Received: from tejas.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mpubbise@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 28BF5601CF; Tue, 10 Jul 2018 11:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531221528; bh=nOwyiN6X6cfUHW4AwiZpWqCUdD5fB4Awg7b+iud8KU0=; h=From:To:Cc:Subject:Date:From; b=JlP76nGbbPlJN4DMblKs6TTIrDFfpyWNLy62bgSzwl7RqtVlu2PGAdnEG6iyLoVg0 CplPbK3vq4Yx+w6EP5plMCh0r9Ni+SO5uYxXq4U+lUCKNtJ/IkASPn9QWxIK3mGauD A+S/B2lBZMWmm/VsirkawqL4Qas+6PT7x2tdORdQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 28BF5601CF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mpubbise@codeaurora.org From: Manikanta Pubbisetty To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Manikanta Pubbisetty Subject: [PATCHv2] mac80211: restrict delayed tailroom needed decrement Date: Tue, 10 Jul 2018 16:48:27 +0530 Message-Id: <1531221507-28610-1-git-send-email-mpubbise@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As explained in ieee80211_delayed_tailroom_dec(), during roam, keys of the old AP will be destroyed and new keys will be installed. Deletion of the old key causes crypto_tx_tailroom_needed_cnt to go from 1 to 0 and the new key installation causes a transition from 0 to 1. Whenever crypto_tx_tailroom_needed_cnt transitions from 0 to 1, we invoke synchronize_net(); the reason for doing this is to avoid a race in the TX path as explained in increment_tailroom_need_count(). This synchronize_net() operation can be slow and can affect the station roam time. To avoid this, decrementing the crypto_tx_tailroom_needed_cnt is delayed for a while so that upon installation of new key the transition would be from 1 to 2 instead of 0 to 1 and thereby improving the roam time. This is all correct for a STA iftype, but deferring the tailroom_needed decrement for other iftypes may be unnecessary. For example, let's consider the case of a 4-addr client connecting to an AP for which AP_VLAN interface is also created, let the initial value for tailroom_needed on the AP be 1. * 4-addr client connects to the AP (AP: tailroom_needed = 1) * AP will clear old keys, delay decrement of tailroom_needed count * AP_VLAN is created, it takes the tailroom count from master (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1) * Install new key for the station, assume key is plumbed in the HW, there won't be any change in tailroom_needed count on AP iface * Delayed decrement of tailroom_needed count on AP (AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1) Because of the delayed decrement on AP iface, tailroom_needed count goes out of sync between AP(master iface) and AP_VLAN(slave iface) and there would be unnecessary tailroom created for the packets going through AP_VLAN iface. Also, WARN_ONs were observed while trying to bring down the AP_VLAN interface: (warn_slowpath_common) (warn_slowpath_null+0x18/0x20) (warn_slowpath_null) (ieee80211_free_keys+0x114/0x1e4) (ieee80211_free_keys) (ieee80211_del_virtual_monitor+0x51c/0x850) (ieee80211_del_virtual_monitor) (ieee80211_stop+0x30/0x3c) (ieee80211_stop) (__dev_close_many+0x94/0xb8) (__dev_close_many) (dev_close_many+0x5c/0xc8) Restricting delayed decrement to station interface alone fixes the problem and it makes sense to do so because delayed decrement is done to improve roam time which is applicable only for client devices. Signed-off-by: Manikanta Pubbisetty --- V2: * Updated commit log * Addressed V1 comments net/mac80211/cfg.c | 2 +- net/mac80211/key.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 02f3672..d25da0e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -495,7 +495,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, goto out_unlock; } - ieee80211_key_free(key, true); + ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION); ret = 0; out_unlock: diff --git a/net/mac80211/key.c b/net/mac80211/key.c index ee0d0cc..f7e4c2d 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -657,9 +657,10 @@ int ieee80211_key_link(struct ieee80211_key *key, struct ieee80211_local *local = sdata->local; struct ieee80211_key *old_key; int idx, ret; - bool pairwise; + bool pairwise, iftype_sta; pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; + iftype_sta = sdata->vif.type == NL80211_IFTYPE_STATION; idx = key->conf.keyidx; mutex_lock(&sdata->local->key_mtx); @@ -688,14 +689,14 @@ int ieee80211_key_link(struct ieee80211_key *key, increment_tailroom_need_count(sdata); ieee80211_key_replace(sdata, sta, pairwise, old_key, key); - ieee80211_key_destroy(old_key, true); + ieee80211_key_destroy(old_key, iftype_sta); ieee80211_debugfs_key_add(key); if (!local->wowlan) { ret = ieee80211_key_enable_hw_accel(key); if (ret) - ieee80211_key_free(key, true); + ieee80211_key_free(key, iftype_sta); } else { ret = 0; } @@ -930,7 +931,8 @@ void ieee80211_free_sta_keys(struct ieee80211_local *local, ieee80211_key_replace(key->sdata, key->sta, key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, key, NULL); - __ieee80211_key_destroy(key, true); + __ieee80211_key_destroy(key, key->sdata->vif.type == + NL80211_IFTYPE_STATION); } for (i = 0; i < NUM_DEFAULT_KEYS; i++) { @@ -940,7 +942,8 @@ void ieee80211_free_sta_keys(struct ieee80211_local *local, ieee80211_key_replace(key->sdata, key->sta, key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, key, NULL); - __ieee80211_key_destroy(key, true); + __ieee80211_key_destroy(key, key->sdata->vif.type == + NL80211_IFTYPE_STATION); } mutex_unlock(&local->key_mtx);