Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2469795imm; Mon, 24 Sep 2018 05:03:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV6212TN07VXE4su2TJ+0E8qFH0KxLUl0tCly8m84KB+A7UsV8C6BUBrB0qma097eMDkeZOqZ X-Received: by 2002:a63:730c:: with SMTP id o12-v6mr3045404pgc.397.1537790631341; Mon, 24 Sep 2018 05:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790631; cv=none; d=google.com; s=arc-20160816; b=D3qLpTL6H8s7Zsa9GimT+5VtPmdD1bJx2WCW/2di4VljpaC/wb/lmtx9eBPoa4YvU5 9cGSqCnOHDmTAJoUcJMUYfUo3BX6lsbsqP8q5Db+tWW7HhqKTWRN6ROCzxOI4Cbjj18a Nx1vTmGmMUsc4CsEHNxREvVbfC8kU83/6bWFCzr0ByhlanxKt2U7AJbL2h+1GHm9Z5PL ZWiJreHhHUf0l37qXmNottOduWp+WPnNK2lA0oTQPI8jJns1CUrNdarH29sxPeVzALca gNKgUGa9d4rIs7SC79MxDGjzw1F9mJH7eETuDPWt5Tb9KsNXdUvI1bufe6OO41sAhXjK stqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Hnss0oFjQ5DPTJtYueuoEXAG/D19vCR6MzuGoL61UXY=; b=H5SGJC2EAxUydLHlhuHBhI3c+23w6TmzmJTSnW2+5wfXjMbMsNb4vVYFFuEYCExD7M EzEjwjllappAzlUfFiotyQh7kltF5ldAWhYaFdPyyJbYUClW9fszgX8lErqPpVwjH87T abd1xBWhXbGziFDjBMFgIwRfiBp9qlf29W0ghg5G/60I1778Uf+wvMGGMQls6dTOJ2Dh JzNyxTp6BHZ0iCQSR9CIyxGlRcKMhsWkrSJFQUJaYG9AXq+on08DyWJJlv3qdF3K+ySk mrKv5HN+3Vz+C++36zPz8r6eNQWgDdVFlqYY1U5ejD4s1Gial2LCOyNPtjjp97Ia5f5q +3UA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si676889pgm.679.2018.09.24.05.03.35; Mon, 24 Sep 2018 05:03:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730965AbeIXSEi (ORCPT + 99 others); Mon, 24 Sep 2018 14:04:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53772 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729932AbeIXSEh (ORCPT ); Mon, 24 Sep 2018 14:04:37 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B949D64; Mon, 24 Sep 2018 12:02:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manikanta Pubbisetty , Johannes Berg , Sasha Levin Subject: [PATCH 4.9 031/111] mac80211: restrict delayed tailroom needed decrement Date: Mon, 24 Sep 2018 13:51:58 +0200 Message-Id: <20180924113107.687176869@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manikanta Pubbisetty [ Upstream commit 133bf90dbb8b873286f8ec2e81ba26e863114b8c ] 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 Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/mac80211/cfg.c | 2 +- net/mac80211/key.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -454,7 +454,7 @@ static int ieee80211_del_key(struct wiph goto out_unlock; } - ieee80211_key_free(key, true); + ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION); ret = 0; out_unlock: --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -648,11 +648,15 @@ int ieee80211_key_link(struct ieee80211_ { struct ieee80211_local *local = sdata->local; struct ieee80211_key *old_key; - int idx, ret; - bool pairwise; - - pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; - idx = key->conf.keyidx; + int idx = key->conf.keyidx; + bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; + /* + * We want to delay tailroom updates only for station - in that + * case it helps roaming speed, but in other cases it hurts and + * can cause warnings to appear. + */ + bool delay_tailroom = sdata->vif.type == NL80211_IFTYPE_STATION; + int ret; mutex_lock(&sdata->local->key_mtx); @@ -680,14 +684,14 @@ int ieee80211_key_link(struct ieee80211_ 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, delay_tailroom); 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, delay_tailroom); } else { ret = 0; } @@ -922,7 +926,8 @@ void ieee80211_free_sta_keys(struct ieee 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++) { @@ -932,7 +937,8 @@ void ieee80211_free_sta_keys(struct ieee 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);