From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DF70BA49 for ; Tue, 7 Mar 2023 18:40:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66D49C433D2; Tue, 7 Mar 2023 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678214452; bh=7N2pMwa4SDfRJ7shCeCE8DlvnepL3d6wkMGP3F6k94k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e3QpD5v5WCv8syGb4+I9J5qQ0IIFYC6i7rDTeSdzDta1CsJIARuGJGwrgG1Vs+jU8 fSlc25X7vCS6GKTqGmROIlMgpBOb33BdMUDHv8I0EbtbXq23jlhX2GLyc2b1E15Rn6 nectSSB5RiLLUp0EU0nxGCN183gVh7C+jerb+iOI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yohan Prodhomme , Marc Bornand , Johannes Berg Subject: [PATCH 6.1 800/885] wifi: cfg80211: Set SSID if it is not already set Date: Tue, 7 Mar 2023 18:02:14 +0100 Message-Id: <20230307170036.656887462@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170001.594919529@linuxfoundation.org> References: <20230307170001.594919529@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Marc Bornand commit c38c701851011c94ce3be1ccb3593678d2933fd8 upstream. When a connection was established without going through NL80211_CMD_CONNECT, the ssid was never set in the wireless_dev struct. Now we set it in __cfg80211_connect_result() when it is not already set. When using a userspace configuration that does not call cfg80211_connect() (can be checked with breakpoints in the kernel), this patch should allow `networkctl status device_name` to output the SSID instead of null. Cc: stable@vger.kernel.org Reported-by: Yohan Prod'homme Fixes: 7b0a0e3c3a88 (wifi: cfg80211: do some rework towards MLO link APIs) Link: https://bugzilla.kernel.org/show_bug.cgi?id=216711 Signed-off-by: Marc Bornand Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/sme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -736,6 +736,7 @@ void __cfg80211_connect_result(struct ne { struct wireless_dev *wdev = dev->ieee80211_ptr; const struct element *country_elem = NULL; + const struct element *ssid; const u8 *country_data; u8 country_datalen; #ifdef CONFIG_CFG80211_WEXT @@ -881,6 +882,22 @@ void __cfg80211_connect_result(struct ne country_data, country_datalen); kfree(country_data); + if (!wdev->u.client.ssid_len) { + rcu_read_lock(); + for_each_valid_link(cr, link) { + ssid = ieee80211_bss_get_elem(cr->links[link].bss, + WLAN_EID_SSID); + + if (!ssid || !ssid->datalen) + continue; + + memcpy(wdev->u.client.ssid, ssid->data, ssid->datalen); + wdev->u.client.ssid_len = ssid->datalen; + break; + } + rcu_read_unlock(); + } + return; out: for_each_valid_link(cr, link)