Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp278290ybi; Wed, 29 May 2019 21:14:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxseULoqxLGVtpTD95FDx5F7fwu1tta77DQW1zwtsxFgyRzZ6EOMckju53X1TQeLahEf2WU X-Received: by 2002:a62:1ec1:: with SMTP id e184mr1701101pfe.185.1559189669164; Wed, 29 May 2019 21:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189669; cv=none; d=google.com; s=arc-20160816; b=S8gXT/N2I//d4n1uR9Md7qatheaBZ8UryWKP4JE7K36Ue3jXEMbgshNW1R42Ccla1+ mCHwcN22tSytn/iIlyA9bpq9ejMRPbHJdUcLkF+4oVTBgImnZtROf7HdmGFi3x+G6yoN XntQryY1ETugTAs3tr3kRUwocS9f2x4EVeFqKFbUhzLjyrSutmtYwln2Ogi13Z/bwwPN VywabzfZNZML3iqNJuyn4iTtp0db+3msXqKeRRMKuWzcRyzapZCvwqUOCMGIld4m17ZP ogImdC+fbHe4iBzU32vHrszpaT9PLDbYoX/ZhPn9pmBuE2t7JQQ+6H+kSYf5Ye0Atwt2 joOw== 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:dkim-signature; bh=Ko7L5uvdgwAnvZJUYzAG025u8VXFNjZcDSQvcF+FeaU=; b=gF4r83vyGpNudsDuTwuQwaSnKVsT6pTMwYJPLFvdk5XCnh8J6ZV69kISXGIvadsImJ oj4xs+AVhBoxzX3Rdky/gvxm96VZmiQW5nkC4WeRf1FvWmeSBVTHYatJereoLRa1HV/i EaMGaou/OwG013SdCEMQf5oD34JSt6e4Bk1KKhx7RFV645TMXvTGgzDgnUKcTq+WX8j2 vuVl8Yxg+T5qgGutyJoGR9gsw5KEZC5qqwusBn2Y9SMNER9YTcDvnhOBie43xepgeG/2 4zMeEhmRqKf9114OrSVPAitoMP8e9fY7PO9d30ZC+Y6xTZokKXSmNP1G4yDCsFApLsUu ODHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rq21TnSs; 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 o128si2027421pgo.51.2019.05.29.21.14.13; Wed, 29 May 2019 21:14:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rq21TnSs; 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 S1727278AbfE3ELz (ORCPT + 99 others); Thu, 30 May 2019 00:11:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:43788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729391AbfE3DQq (ORCPT ); Wed, 29 May 2019 23:16:46 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83A3F245C1; Thu, 30 May 2019 03:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186205; bh=lfa6ubSAXCwwv7XGl9evmSVdGbNoD54IxTwiATEwgto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rq21TnSsP3c43jgXnJHt6V/UcsULfeV3SWW8JOKKeoCQ8ZWaUlQSEG9H2W3Cl4bQ/ E3JiJKCpIwGL8FK7Gw1mBXpNKOm293czlhj6qZLhIqtJd778s13upThgP0rtc2og3r zzmwL/MTFQdyBiv80xWknCflxJbOKs9v1FWQ7G+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Matyukevich , Johannes Berg , Sasha Levin Subject: [PATCH 4.19 092/276] mac80211/cfg80211: update bss channel on channel switch Date: Wed, 29 May 2019 20:04:10 -0700 Message-Id: <20190530030531.952544540@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 5dc8cdce1d722c733f8c7af14c5fb595cfedbfa8 ] FullMAC STAs have no way to update bss channel after CSA channel switch completion. As a result, user-space tools may provide inconsistent channel info. For instance, consider the following two commands: $ sudo iw dev wlan0 link $ sudo iw dev wlan0 info The latter command gets channel info from the hardware, so most probably its output will be correct. However the former command gets channel info from scan cache, so its output will contain outdated channel info. In fact, current bss channel info will not be updated until the next [re-]connect. Note that mac80211 STAs have a workaround for this, but it requires access to internal cfg80211 data, see ieee80211_chswitch_work: /* XXX: shouldn't really modify cfg80211-owned data! */ ifmgd->associated->channel = sdata->csa_chandef.chan; This patch suggests to convert mac80211 workaround into cfg80211 behavior and to update current bss channel in cfg80211_ch_switch_notify. Signed-off-by: Sergey Matyukevich Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/mac80211/mlme.c | 3 --- net/wireless/nl80211.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 3dbecae4be73c..2ac749c4a6b26 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1156,9 +1156,6 @@ static void ieee80211_chswitch_work(struct work_struct *work) goto out; } - /* XXX: shouldn't really modify cfg80211-owned data! */ - ifmgd->associated->channel = sdata->csa_chandef.chan; - ifmgd->csa_waiting_bcn = true; ieee80211_sta_reset_beacon_monitor(sdata); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 048e004ed0ee8..c6711ead5e591 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -15441,6 +15441,11 @@ void cfg80211_ch_switch_notify(struct net_device *dev, wdev->chandef = *chandef; wdev->preset_chandef = *chandef; + + if (wdev->iftype == NL80211_IFTYPE_STATION && + !WARN_ON(!wdev->current_bss)) + wdev->current_bss->pub.channel = chandef->chan; + nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL, NL80211_CMD_CH_SWITCH_NOTIFY, 0); } -- 2.20.1