From patchwork Mon Jan 16 20:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13103648 X-Patchwork-Delegate: kuba@kernel.org 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 51C8DC54EBE for ; Mon, 16 Jan 2023 20:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233765AbjAPUYt (ORCPT ); Mon, 16 Jan 2023 15:24:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233406AbjAPUYp (ORCPT ); Mon, 16 Jan 2023 15:24:45 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E1F21B567 for ; Mon, 16 Jan 2023 12:24:45 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id q23-20020a17090a065700b002290913a521so12702239pje.5 for ; Mon, 16 Jan 2023 12:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vSiLXb9WJcajlY3pp2A6uRr9twRUEMwHYlZPISHDuv0=; b=XsFNuH67bnTw8UEEBNfdHE2Vcgqz23IF9D2M870dn4gSTgx06BaEVaJsExIs47mnz8 T+1zXS5SoutgfuvA6NhBNXgCPtC3nq43mDxKiISv5BzRM/2/jG9SIX/v7n1likkChona ng51M+ucV9xqMHLJco+HSEJihIooXhahUBQhs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vSiLXb9WJcajlY3pp2A6uRr9twRUEMwHYlZPISHDuv0=; b=7p/U4gilOiyPCzAbNf6WyahpzwpzBRZm2Oo7OLcvLPWzR8q5HCqbqN1YZDsbydrCEn 9HXezBEvTkmHhteWYJ2+mjb2T8YBZmVtmpuV/8NHF5nBiM+or/uNNj+YcXH5lsA271Zk 1OAtgt5G7u27r7hCZsu90HQPQE4uY27T/CsGvx0A3IOWb+vec6MBuhkZnX7J14E/GF49 obR1KEAb1IACZvFjdOkMfnNxqRmwfOjaGAYvXq96sUc9N7nZgxS3TZJ66ZEIaeIJUhuq fqlbJsFnnqiHs6wejuwVIt33fgUKhcq4vm3MDa0dyges7FJU5FJoan1Gv9kfJuh1lu1A 9CuQ== X-Gm-Message-State: AFqh2krFkvYNOtknh3FMUS8+JkHlDkVRcJkFKe2fwQ3XwSpN/OZt73Gf G29bBSXlBv22KndttSruG4BUhQ== X-Google-Smtp-Source: AMrXdXt9oe/8F3xPCM5wYGBCGrW+8/kYP//0TDcFXVVJhEeyTa/3Tq0q5sx8H89hTDujmw8X/bzfWw== X-Received: by 2002:a17:903:3312:b0:194:85db:e224 with SMTP id jk18-20020a170903331200b0019485dbe224mr1013562plb.7.1673900684529; Mon, 16 Jan 2023 12:24:44 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id v11-20020a170902f0cb00b00180033438a0sm19782636pla.106.2023.01.16.12.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 12:24:44 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v3 1/4] wifi: libertas: fix capitalization in mrvl_ie_data struct Date: Mon, 16 Jan 2023 12:21:23 -0800 Message-Id: <20230116202126.50400-2-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116202126.50400-1-doug@schmorgal.com> References: <20230116202126.50400-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This struct is currently unused, but it will be used in future patches. Fix the code style to not use camel case. Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/libertas/types.h b/drivers/net/wireless/marvell/libertas/types.h index cd4ceb6f885d..398e3272e85f 100644 --- a/drivers/net/wireless/marvell/libertas/types.h +++ b/drivers/net/wireless/marvell/libertas/types.h @@ -105,7 +105,7 @@ struct mrvl_ie_header { struct mrvl_ie_data { struct mrvl_ie_header header; - u8 Data[1]; + u8 data[1]; } __packed; struct mrvl_ie_rates_param_set { From patchwork Mon Jan 16 20:21:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13103649 X-Patchwork-Delegate: kuba@kernel.org 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 9A1ECC678D4 for ; Mon, 16 Jan 2023 20:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233856AbjAPUYu (ORCPT ); Mon, 16 Jan 2023 15:24:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbjAPUYr (ORCPT ); Mon, 16 Jan 2023 15:24:47 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9986B244AE for ; Mon, 16 Jan 2023 12:24:46 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id k12so9309364plk.0 for ; Mon, 16 Jan 2023 12:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A0fz9zHVDO2m4yGb0WkSftssKbcC8YshpBpIYHhLj7c=; b=XPqlqsns1l0j2dj0kGma04Dysnk7syDzq9rj51Ig7hKcPXe/eVEomVWcx81kHre3AT K18P2DubkZjaxqj4vLRdpmGY+t3bV0eFsD8ZUchZehwL5PMPDXL2gl80emQods+1lxb+ WFWayssPMtJKHHm1fGBjOtGyUCx4AwINGok+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A0fz9zHVDO2m4yGb0WkSftssKbcC8YshpBpIYHhLj7c=; b=FFsIPT1fY5Ah51H+QIFByzjqcZxB14lvOW/c85dv/1VuY0E8+SEgESbeAGMapCHkzt napbUZbntjT2sdxsERURUnizvKLk18nZ773+1VqiARu8ioKgw3gT3voYwXTSdXOcp3s1 cwGtuBadKaVcpAs73a4LWzeABpiom9LELWwb9TgZCfmvRsls+X96b2f6ZNGPpWRpTbkZ /0B2hOYTs6lWfcAwIrFT4OFhSln7HDlJVBPIKAaZsedRerdYEu/aKHxTC/nUrwW2rMQq tBr2DzLZEUgaqsC2+UZJTCbTFWZFx3ceXqKSFCHgvw0xeOVjBPTttDG9kbt0//lVVxKh TZiw== X-Gm-Message-State: AFqh2koF9XBHXUivb+AU4R1xHK5QM0pGG2xwYjMsNVNczH31mOr/9fEB 0AxLwFPd8kIaT9MRXcEQJXIEIA== X-Google-Smtp-Source: AMrXdXuVB+N82WcfVUCAm6fO+qNeYUUV5/9FiGcTtRz8c5rfqb8OdC7lNiVla3ptxpkgTY36/Y0MMQ== X-Received: by 2002:a17:902:b587:b0:193:6520:73a4 with SMTP id a7-20020a170902b58700b00193652073a4mr872975pls.61.1673900686217; Mon, 16 Jan 2023 12:24:46 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id v11-20020a170902f0cb00b00180033438a0sm19782636pla.106.2023.01.16.12.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 12:24:45 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v3 2/4] wifi: libertas: only add RSN/WPA IE in lbs_add_wpa_tlv Date: Mon, 16 Jan 2023 12:21:24 -0800 Message-Id: <20230116202126.50400-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116202126.50400-1-doug@schmorgal.com> References: <20230116202126.50400-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The existing code only converts the first IE to a TLV, but it returns a value that takes the length of all IEs into account. When there is more than one IE (which happens with modern wpa_supplicant versions for example), the returned length is too long and extra junk TLVs get sent to the firmware, resulting in an association failure. Fix this by finding the first RSN or WPA IE and only adding that. This has the extra benefit of working properly if the RSN/WPA IE isn't the first one in the IE buffer. While we're at it, clean up the code to use the available structs like the other lbs_add_* functions instead of directly manipulating the TLV buffer. Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/cfg.c | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 3e065cbb0af9..3f35dc7a1d7d 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -416,10 +416,20 @@ static int lbs_add_cf_param_tlv(u8 *tlv) static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) { - size_t tlv_len; + struct mrvl_ie_data *wpatlv = (struct mrvl_ie_data *)tlv; + const struct element *wpaie; + + /* Find the first RSN or WPA IE to use */ + wpaie = cfg80211_find_elem(WLAN_EID_RSN, ie, ie_len); + if (!wpaie) + wpaie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + ie, ie_len); + if (!wpaie || wpaie->datalen > 128) + return 0; /* - * We need just convert an IE to an TLV. IEs use u8 for the header, + * Convert the found IE to a TLV. IEs use u8 for the header, * u8 type * u8 len * u8[] data @@ -428,14 +438,12 @@ static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) * __le16 len * u8[] data */ - *tlv++ = *ie++; - *tlv++ = 0; - tlv_len = *tlv++ = *ie++; - *tlv++ = 0; - while (tlv_len--) - *tlv++ = *ie++; - /* the TLV is two bytes larger than the IE */ - return ie_len + 2; + wpatlv->header.type = cpu_to_le16(wpaie->id); + wpatlv->header.len = cpu_to_le16(wpaie->datalen); + memcpy(wpatlv->data, wpaie->data, wpaie->datalen); + + /* Return the total number of bytes added to the TLV buffer */ + return sizeof(struct mrvl_ie_header) + wpaie->datalen; } /* From patchwork Mon Jan 16 20:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13103650 X-Patchwork-Delegate: kuba@kernel.org 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 3569AC678D8 for ; Mon, 16 Jan 2023 20:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233710AbjAPUYw (ORCPT ); Mon, 16 Jan 2023 15:24:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233406AbjAPUYu (ORCPT ); Mon, 16 Jan 2023 15:24:50 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE8926580 for ; Mon, 16 Jan 2023 12:24:50 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id x2-20020a17090a46c200b002295ca9855aso4006240pjg.2 for ; Mon, 16 Jan 2023 12:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gauNsz6s5kFu95ogUSHoB2HkvdwI2Yd7FgOC3hoCgaY=; b=CVDrCKxTFJ3xT1epe5ulcX04NUVwF5MoYVofUUFheafxF02afSUoo6dhlJ04EQ81IX CvdsGvSRoE+5GUXp8xBpM0H0vlpayjeRqYE5qWA0/NJVLlefkMP10RThpjIv63ohAJMe YyhCZIbAxh+Rt4DchlRXIazZOiB40+Jbyk96I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gauNsz6s5kFu95ogUSHoB2HkvdwI2Yd7FgOC3hoCgaY=; b=Y5Dw4ClBHp4VIcdbjV0aDzf3/vD/CSE/P8Q7NJQVeFmSbkC1XB2zaWs2QJRhedvA/T IDi5TutGZBKamCTN8+J9Dtl8mSZWkaeVMLjyh3Fq0qINPC9874I4L4x5zwqKzW0J+bco qNpDrGbDs6Hi+ZGCtX6pWt13MGx8CDNlcLS7+AZcrVOZEEViTlylFYi3myK5k7OI/NyV PsfWsvt7NB4tXHkNrCuG7qakDcro2DP39R/EXG8pMjM01Tc6KkD3ZelHx5413f9rdqjJ e/uRow+BVHDq1NEUkRNU28I4Cy7SU0lZkCkwB6+y2kt+J44ugbZ6OS6vvrO6FjCnCwSg O37A== X-Gm-Message-State: AFqh2kqFiDwuhzxSNRh2wQm3wxLD+G0Lel53ewEr8rEYonH+Ms8bqXDs U+9wz6fHMyx6m3AdPnBSg0s22nYt0p7ZWO+TzWcIvg== X-Google-Smtp-Source: AMrXdXuqW18YgFq/Qjm5kfuN/1kxd8WVFfWKMeZoGCXuxftlEDOF5KstwkozpqayhjNsum3a5NxkzQ== X-Received: by 2002:a17:902:b105:b0:194:7a89:a436 with SMTP id q5-20020a170902b10500b001947a89a436mr910469plr.27.1673900689434; Mon, 16 Jan 2023 12:24:49 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id v11-20020a170902f0cb00b00180033438a0sm19782636pla.106.2023.01.16.12.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 12:24:49 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v3 3/4] wifi: libertas: add new TLV type for WPS enrollee IE Date: Mon, 16 Jan 2023 12:21:25 -0800 Message-Id: <20230116202126.50400-4-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116202126.50400-1-doug@schmorgal.com> References: <20230116202126.50400-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a define for the TLV type that will be used to add WPS enrollee information to probe requests. Suggested-by: Dan Williams Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/marvell/libertas/types.h b/drivers/net/wireless/marvell/libertas/types.h index 398e3272e85f..39deb2b8bc82 100644 --- a/drivers/net/wireless/marvell/libertas/types.h +++ b/drivers/net/wireless/marvell/libertas/types.h @@ -93,6 +93,7 @@ union ieee_phy_param_set { #define TLV_TYPE_TSFTIMESTAMP (PROPRIETARY_TLV_BASE_ID + 19) #define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 22) #define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 23) +#define TLV_TYPE_WPS_ENROLLEE (PROPRIETARY_TLV_BASE_ID + 27) #define TLV_TYPE_AUTH_TYPE (PROPRIETARY_TLV_BASE_ID + 31) #define TLV_TYPE_MESH_ID (PROPRIETARY_TLV_BASE_ID + 37) #define TLV_TYPE_OLD_MESH_ID (PROPRIETARY_TLV_BASE_ID + 291) From patchwork Mon Jan 16 20:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13103651 X-Patchwork-Delegate: kuba@kernel.org 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 4DE13C677F1 for ; Mon, 16 Jan 2023 20:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233912AbjAPUZB (ORCPT ); Mon, 16 Jan 2023 15:25:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233406AbjAPUYx (ORCPT ); Mon, 16 Jan 2023 15:24:53 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC7E26590 for ; Mon, 16 Jan 2023 12:24:51 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id s13-20020a17090a6e4d00b0022900843652so13418378pjm.1 for ; Mon, 16 Jan 2023 12:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IiJYuOlBmU0RcgmFiitXKtaXart9FqS66MFzruNWBFs=; b=Nz5TVA75hXDA29BpynrmMSGzNhdUl+RnLMKdZBeGr6J4Ii0QUd8VfnafeC/o8a0Jr8 +5XW5GgQuKLhKOAbgoFLTZgpQjAtS7OgJbe3usYnEeKCk7h3tamtuFk0kI32CRB9S3Ea XODJHodGHniG46XXU9Rrc4SeSLAQyjv6e2suo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IiJYuOlBmU0RcgmFiitXKtaXart9FqS66MFzruNWBFs=; b=OBWgop4dPs3uvNkv5FYxqQxqKZe9D4DesWCItZISNWFX/69roBkYVAXhoYf3SJM5pQ KKC89ShBiiPHbpQs5JjoUz+rdBR0bcpahubjCK8xrZyLJQOhpIAg5eaJ8fKMyXsBorR7 oiT1i1EEOoeCzzx8+3xM27f5qLuJ9rqzQg0Zhcu6wsTeWpCrKvOfaQx7s8zBerTb186u g/BDyjX/GiW4fmHe6chLItqumF1kKqJVioo0uXOwlj80kU8zvDY+vPJuFfZZb8xGAEC/ 8G4mLTPyjWBDdFLCdLrPnUowT7I3pGDc6YPJhIa3DWI53GJ47H38KQEm0b/hiaBrKgvG c4uQ== X-Gm-Message-State: AFqh2kqi1YZY2WNPx/pbn/uVR5l6xt0Dn3sAxwaiBVWon9IUvzicyOzA b34FoXXO13W5mqzmgtn2kdE9eQ== X-Google-Smtp-Source: AMrXdXvGOPZZRc6ofCTJypsCLJlt+Pdifreq0kL+dUOedTd8rZQkN+02QlQzCXY7XbVtrK90nD8XOw== X-Received: by 2002:a17:902:8e88:b0:194:8ddc:7d0e with SMTP id bg8-20020a1709028e8800b001948ddc7d0emr7128790plb.65.1673900691385; Mon, 16 Jan 2023 12:24:51 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id v11-20020a170902f0cb00b00180033438a0sm19782636pla.106.2023.01.16.12.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 12:24:50 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v3 4/4] wifi: libertas: add support for WPS enrollee IE in probe requests Date: Mon, 16 Jan 2023 12:21:26 -0800 Message-Id: <20230116202126.50400-5-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116202126.50400-1-doug@schmorgal.com> References: <20230116202126.50400-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add compatibility with WPS by passing on WPS enrollee information in probe requests. Ignore other IEs supplied in the scan request. This also has the added benefit of restoring compatibility with newer wpa_supplicant versions that always add scan IEs. Previously, with max_scan_ie_len set to 0, scans would always fail. Suggested-by: Dan Williams Signed-off-by: Doug Brown Reviewed-by: Dan Williams --- drivers/net/wireless/marvell/libertas/cfg.c | 48 +++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 3f35dc7a1d7d..b700c213d10c 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -446,6 +446,41 @@ static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) return sizeof(struct mrvl_ie_header) + wpaie->datalen; } +/* Add WPS enrollee TLV + */ +#define LBS_MAX_WPS_ENROLLEE_TLV_SIZE \ + (sizeof(struct mrvl_ie_header) \ + + 256) + +static int lbs_add_wps_enrollee_tlv(u8 *tlv, const u8 *ie, size_t ie_len) +{ + struct mrvl_ie_data *wpstlv = (struct mrvl_ie_data *)tlv; + const struct element *wpsie; + + /* Look for a WPS IE and add it to the probe request */ + wpsie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPS, + ie, ie_len); + if (!wpsie) + return 0; + + /* Convert the WPS IE to a TLV. The IE looks like this: + * u8 type (WLAN_EID_VENDOR_SPECIFIC) + * u8 len + * u8[] data + * but the TLV will look like this instead: + * __le16 type (TLV_TYPE_WPS_ENROLLEE) + * __le16 len + * u8[] data + */ + wpstlv->header.type = cpu_to_le16(TLV_TYPE_WPS_ENROLLEE); + wpstlv->header.len = cpu_to_le16(wpsie->datalen); + memcpy(wpstlv->data, wpsie->data, wpsie->datalen); + + /* Return the total number of bytes added to the TLV buffer */ + return sizeof(struct mrvl_ie_header) + wpsie->datalen; +} + /* * Set Channel */ @@ -672,14 +707,15 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, /* - * Our scan command contains a TLV, consting of a SSID TLV, a channel list - * TLV and a rates TLV. Determine the maximum size of them: + * Our scan command contains a TLV, consisting of a SSID TLV, a channel list + * TLV, a rates TLV, and an optional WPS IE. Determine the maximum size of them: */ #define LBS_SCAN_MAX_CMD_SIZE \ (sizeof(struct cmd_ds_802_11_scan) \ + LBS_MAX_SSID_TLV_SIZE \ + LBS_MAX_CHANNEL_LIST_TLV_SIZE \ - + LBS_MAX_RATES_TLV_SIZE) + + LBS_MAX_RATES_TLV_SIZE \ + + LBS_MAX_WPS_ENROLLEE_TLV_SIZE) /* * Assumes priv->scan_req is initialized and valid @@ -728,6 +764,11 @@ static void lbs_scan_worker(struct work_struct *work) /* add rates TLV */ tlv += lbs_add_supported_rates_tlv(tlv); + /* add optional WPS enrollee TLV */ + if (priv->scan_req->ie && priv->scan_req->ie_len) + tlv += lbs_add_wps_enrollee_tlv(tlv, priv->scan_req->ie, + priv->scan_req->ie_len); + if (priv->scan_channel < priv->scan_req->n_channels) { cancel_delayed_work(&priv->scan_work); if (netif_running(priv->dev)) @@ -2114,6 +2155,7 @@ int lbs_cfg_register(struct lbs_private *priv) int ret; wdev->wiphy->max_scan_ssids = 1; + wdev->wiphy->max_scan_ie_len = 256; wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; wdev->wiphy->interface_modes =