From patchwork Sun Jan 8 01:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13092343 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 B5450C63797 for ; Sun, 8 Jan 2023 01:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbjAHBa6 (ORCPT ); Sat, 7 Jan 2023 20:30:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjAHBaz (ORCPT ); Sat, 7 Jan 2023 20:30:55 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9CF035923 for ; Sat, 7 Jan 2023 17:30:54 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id d10so3631789pgm.13 for ; Sat, 07 Jan 2023 17:30:54 -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=Fe/zwNAMNgjbbOPzhmtFZNyLrxouNqQy0oXAMZ7cwS5nexp9omCvH8z+/YeBSW4sqd 8BqLE46ad32EU9xrFTP6nwTEMxfZLgWVDoR9KKxKgOlrZWc20SlgMHRBh2xlOenR/95c TREYtyflWCBHqAPIfS71u7CHqSTVkhs1PUM60= 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=qtpNe4Pao7m4q6ieWmPQyfLPOZPLU6H26koy+g1AEz6nQwR9q2NoMMYB++S8wLD5lq a7gukGI19Rtns1OTHb6XI7eL45Hms6lBxkwi1gSsR8CKLj7d1a8yVaBx6Xax4xWUvFlI YGWbyL9NFppmGCjdZ9QS2x+ubt4bkL6TQUX/hgDm+FEqTlP+jDuh647/H7zZEE59w6s2 mbaGUtUmKeXNuvNbdojsDqOUgHHmMPvK7VZMUd8TYAcKTJGo8o4D6g6VlW6URXzTtLfA 6XnIiOrK8UpUWo9/jNuNiPQehcOBNGFbP9a8mKZbCwLRn1vO3kn59jrtoHw8QLubabYJ MVsQ== X-Gm-Message-State: AFqh2koDusngu++VrkJkJrd1RilSHVIC5oloKGKKZSA5HnjmYoprPVqK Rv3LFl+Vel112enFwaNr5ywOoQ== X-Google-Smtp-Source: AMrXdXvpcdk77TT8XagZXpCHsOGivfKhMtZKjvxVygLPtMDMC+KtL3QUm6JlsOicE/Yc7+8TgSPZhw== X-Received: by 2002:a62:ea01:0:b0:582:bbc7:c61e with SMTP id t1-20020a62ea01000000b00582bbc7c61emr15686779pfh.11.1673141454073; Sat, 07 Jan 2023 17:30:54 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id x14-20020aa79a4e000000b005811c421e6csm3323714pfj.162.2023.01.07.17.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 17:30:53 -0800 (PST) From: Doug Brown To: Dan Williams , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v2 1/4] wifi: libertas: fix capitalization in mrvl_ie_data struct Date: Sat, 7 Jan 2023 17:30:13 -0800 Message-Id: <20230108013016.222494-2-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108013016.222494-1-doug@schmorgal.com> References: <20230108013016.222494-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 Sun Jan 8 01:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13092342 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 CE9F3C54EBD for ; Sun, 8 Jan 2023 01:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232111AbjAHBbD (ORCPT ); Sat, 7 Jan 2023 20:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232071AbjAHBbA (ORCPT ); Sat, 7 Jan 2023 20:31:00 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF763633D for ; Sat, 7 Jan 2023 17:30:59 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id r18so3636603pgr.12 for ; Sat, 07 Jan 2023 17:30:59 -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=gZnUzt96M2CHw2T17VotljT7ugAqa2z/W5TDXEKxdek=; b=a8Aw21mdqnBwiNQAC6YlwGKZTGrHdKVqz7GMHC9WUOUEApaCqM9bbx4CS0jeBEldiO 3EbAzVDuDCdpzpp4FLt15YdjwnY7FuBVjvKBr6HMWCbkMH6r73KxFhqJH0611ipJ9njb ZFFIyOAUDrNACu+h+usurCdIeGQ07p40ATepQ= 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=gZnUzt96M2CHw2T17VotljT7ugAqa2z/W5TDXEKxdek=; b=HFA1nbkGufiv+wkto43IqlTUHZSi5AhPhqTb38LCbck5lwIVoyc0eZotNVtJz8/nfE s/z3INV3O4kEmuj66Qf+4Gl9dwCOeVV2XW+JzVLXsyyPS1sjffrjb1hUyTVnAAtyyMDI CCPpn3qT+k4amn5VYnUdKBNUBMH9rVOj1nEK9iOlxerwAmMBTnq0GkFgyVr3AQogoYTI E9sPmGnR+tJ7SzUblOwOzgTO8Mnv7xXLTm2EsPIbWhfJe5cd+rtrWT2+n7GZ/h2NQbER yK9JEw31ALXaQpU5QDiXOq5zOc9fsLUp2oR8FjSGAD7E4B9Avq8zZrPkBX2lfqIg2FEW 3MtQ== X-Gm-Message-State: AFqh2ko+lmQHKWvpflpUni8oURWK0JldiDVGPGO+YSkkbX1CGSm1duVw KdeqrSWPVd1fRh2wD5IyJxgCMw== X-Google-Smtp-Source: AMrXdXsNEgSj+Fg3BAhdyK6itnO+JVw3YnT/0zGRBxhPgoZOvT438HNfu2sNa85PNKDMAjBFdJafhg== X-Received: by 2002:a05:6a00:1485:b0:574:251b:c5fe with SMTP id v5-20020a056a00148500b00574251bc5femr71889826pfu.20.1673141458702; Sat, 07 Jan 2023 17:30:58 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id x14-20020aa79a4e000000b005811c421e6csm3323714pfj.162.2023.01.07.17.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 17:30:58 -0800 (PST) From: Doug Brown To: Dan Williams , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v2 2/4] wifi: libertas: only add RSN/WPA IE in lbs_add_wpa_tlv Date: Sat, 7 Jan 2023 17:30:14 -0800 Message-Id: <20230108013016.222494-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108013016.222494-1-doug@schmorgal.com> References: <20230108013016.222494-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..5cd78fefbe4c 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 = wpaie->id; + wpatlv->header.len = 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 Sun Jan 8 01:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13092344 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 5C920C46467 for ; Sun, 8 Jan 2023 01:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232416AbjAHBbF (ORCPT ); Sat, 7 Jan 2023 20:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232151AbjAHBbC (ORCPT ); Sat, 7 Jan 2023 20:31:02 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A2137266 for ; Sat, 7 Jan 2023 17:31:01 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso5731787pjo.3 for ; Sat, 07 Jan 2023 17:31:01 -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=d7jWKen1UBmJo4xKDMqEumwrLLmvakr7YusikAYbcgcpPa9q295WFntzAmuHeUN1VD 3MID3tH/XlEQesAsft43vpTTBnvQneZz4iQbnKeFUeDpUqIfhyG3khwsXfHRV3dA2IvD 5//lOkMbdGQPBHdJxupXrMiBje8XbtNe/sQ6w= 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=mGyMXXjwe5N/dH5n8TvVfBsnSm/wxO0d27UxV6AztE0KES4gZdvyY9daai3jucmAey 7UGtKyArn/FFgeaTJMkMHXmzeALB6WayCsvLbMuNjzTNCq3FJMjgl2DiVVSOZ4wuDLKl K6Tk6L7bPB8OdM6fv2ygXireJZGxWWTaw7YpsVZzrHXC2tm6EsoMYfURQErOF5sZbQnW VpcXp1zPGIlTkkWIO1FGDPpLnDk/cHWMyMPJ/uV6+l1UKkYQ1D+2ef2jHNw+l4+/i/fh qh39yISHXpEgL3RMGmNGkoNO8AG/5HURiJkK0kfFjYNhIf5H5/lIjC5ro7I720ydG75q vkhA== X-Gm-Message-State: AFqh2kp8/fg8hOJ3oCYqugjP1fpDmhguKSPwxal8AQV/DCWs/YqSe1KS FuirWt4/Ax+15CPjX6E6pbgB1w== X-Google-Smtp-Source: AMrXdXvcEJL08ILiRjMh3tq2yXtYlomndnblK8Cn6RILuziDx19TkGZBoy724VK5Lx7/9OBtxUuz5A== X-Received: by 2002:a05:6a20:3c8f:b0:a3:bdd3:8cb0 with SMTP id b15-20020a056a203c8f00b000a3bdd38cb0mr88573133pzj.56.1673141461188; Sat, 07 Jan 2023 17:31:01 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id x14-20020aa79a4e000000b005811c421e6csm3323714pfj.162.2023.01.07.17.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 17:31:00 -0800 (PST) From: Doug Brown To: Dan Williams , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v2 3/4] wifi: libertas: add new TLV type for WPS enrollee IE Date: Sat, 7 Jan 2023 17:30:15 -0800 Message-Id: <20230108013016.222494-4-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108013016.222494-1-doug@schmorgal.com> References: <20230108013016.222494-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 Sun Jan 8 01:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13092345 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 589E7C46467 for ; Sun, 8 Jan 2023 01:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjAHBbT (ORCPT ); Sat, 7 Jan 2023 20:31:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232182AbjAHBbM (ORCPT ); Sat, 7 Jan 2023 20:31:12 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F3B3B907 for ; Sat, 7 Jan 2023 17:31:05 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id c85so467979pfc.8 for ; Sat, 07 Jan 2023 17:31:05 -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=F1XsLmyJLSZxFahyH+bnrRO9ogW2CStFBT/wHKkbpOs=; b=dAqKoTa0yqV8w6eb3XT5pFsi9y8g3XfsYIe2rS1/0t5CnqoGNhzHCePXIZGXBaPwI9 Ac2oUarTv5SISyiBuG7siLopcI3yQLQnr0h8kfNPf0KPGp09Y9/T+NZ51v2rco+DZTWO k+bZCedKgWMvgnt/bMIgWtPUZTQiRdiqcUf0w= 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=F1XsLmyJLSZxFahyH+bnrRO9ogW2CStFBT/wHKkbpOs=; b=mos5kIby3yp1OtS2tV95S3ij4WE/N/2KUyRD08lprEQOehdeWC9SWepaY6bGbvedth lXuIQitFX7cXz2nwfNMJTYn3boQC2EsLY4pT5ItBYAZIAXH44s5zyRzj+1kQptolAPuv gKZbLSWAvKLpwfTf971xvv79YCNPA+1JKPYfMbOOEOF5XWkMe3ICGq21oHJXFUa5g1Yt U346eIP1egz/NYjeNTHXfzRrAC3KkapssqbQ2d8puu/+mOYiqADkUPB+eEPkufOx8E6X CSGu2i8UMU1pY7dnVHHbTg7ESiu/2/PQT5lJkUwlXC2TRQEBP7NjCvUxFuOGo45cQYV4 /tTw== X-Gm-Message-State: AFqh2kr+YUw5VDFwX9pICBRdIZdrIcNLuRTcBNww97a+XCPuF7kt0jGT N68E3f2kI0DFvcn+sbxUYCFNgw== X-Google-Smtp-Source: AMrXdXvJwd3Tyv51nq/yoDQJehhVAmFPArqq8grbCdGcLQViy06OM3Vpq4nd8kgYVQ7uqUIL6C57yA== X-Received: by 2002:a62:2903:0:b0:57f:f2cd:6180 with SMTP id p3-20020a622903000000b0057ff2cd6180mr57052288pfp.0.1673141464818; Sat, 07 Jan 2023 17:31:04 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id x14-20020aa79a4e000000b005811c421e6csm3323714pfj.162.2023.01.07.17.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 17:31:04 -0800 (PST) From: Doug Brown To: Dan Williams , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v2 4/4] wifi: libertas: add support for WPS enrollee IE in probe requests Date: Sat, 7 Jan 2023 17:30:16 -0800 Message-Id: <20230108013016.222494-5-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108013016.222494-1-doug@schmorgal.com> References: <20230108013016.222494-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 --- 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 5cd78fefbe4c..ec3f35ae15fd 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 = TLV_TYPE_WPS_ENROLLEE; + wpstlv->header.len = 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 =