From patchwork Wed Feb 15 08:47:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Bornand X-Patchwork-Id: 13141453 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E43DC6379F for ; Wed, 15 Feb 2023 08:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjBOIsE (ORCPT ); Wed, 15 Feb 2023 03:48:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbjBOIsD (ORCPT ); Wed, 15 Feb 2023 03:48:03 -0500 Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B06192E0FC; Wed, 15 Feb 2023 00:48:01 -0800 (PST) Date: Wed, 15 Feb 2023 08:47:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemb.ch; s=protonmail; t=1676450879; x=1676710079; bh=E7nP9FVYArp+l+shpevPrDGeTZGYU48EbnTnQ2n7ch4=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=F/wEF9zb5AlqSOsqRdPkZEDaTX/ON9DLNOmGZHc3s6eCKKVW40n+fnHehEKp/bS+P XLUBkIbhIbcUHauBt0nU+GUCRL2DbpjVp26K1rW0n/XUdjwabpbCrX5AiPbk9ByXZ7 AOrVMa5QNW2lXdjdyQx7bweJDGhMj2GZoB7fVBYvZ3euGQeuVe+JBpEtfWbYc+ElX0 A8FzZ1lKQt+gJZLka/NUJCnjtQrrK8s/iGpVO7U4pVYLCbFRzM4nFmtzBoJdLji19y EEw1Z3JubySk/zxQ9uf2eQHkq9TsYgaqDiAYlMUgN8jQC9Zw8Y5VAH+dXpBMRIP9U7 Cilma7VKOVXrQ== To: Johannes Berg , linux-wireless@vger.kernel.org From: Marc Bornand Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Valo , Marc Bornand , Yohan Prod'homme , Denis Kirjanov , stable@vger.kernel.org Subject: [PATCH wireless v5] wifi: cfg80211: Set SSID if it is not already set Message-ID: <20230215084722.231535-1-dev.mbornand@systemb.ch> Feedback-ID: 65519157:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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. Reported-by: Yohan Prod'homme Fixes: 7b0a0e3c3a88 (wifi: cfg80211: do some rework towards MLO link APIs) CC: Kalle Valo Cc: Denis Kirjanov Cc: linux-wireless@vger.kernel.org Cc: stable@vger.kernel.org Link: https://bugzilla.kernel.org/show_bug.cgi?id=216711 Signed-off-by: Marc Bornand --- changes since v4: - style: use xmas tree - better fixes tag - fix typo in commit message - explain how to test the patch - fix fixes tag - move change log - changing the title to something better changes since v3: - add missing NULL check - add missing break changes since v2: - The code was tottaly rewritten based on the disscution of the v2 patch. - the ssid is set in __cfg80211_connect_result() and only if the ssid is not already set. - Do not add an other ssid reset path since it is already done in __cfg80211_disconnected() --- net/wireless/sme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.39.2 diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 4b5b6ee0fe01..032464a38787 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -724,6 +724,7 @@ void __cfg80211_connect_result(struct net_device *dev, { 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 @@ -883,6 +884,22 @@ void __cfg80211_connect_result(struct net_device *dev, country_data, country_datalen); kfree(country_data); + if (wdev->u.client.ssid_len == 0) { + 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 == 0) + 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)