Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3766405rwb; Mon, 16 Jan 2023 12:39:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJm2aE7Al5UWMCzv+FDcl2qv5IVb6F3dL5zSLsAzLrPoX5TNzRii8nPUof9i8QDFQHDDbI X-Received: by 2002:a17:903:428b:b0:193:3bf7:40e6 with SMTP id ju11-20020a170903428b00b001933bf740e6mr21010336plb.53.1673901540965; Mon, 16 Jan 2023 12:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673901540; cv=none; d=google.com; s=arc-20160816; b=G3iuxNPAJsTnc4T16WWeKuS002A5TgciztpPSYfWjsC/InHgei8oEz7jrumPVADqRq C8VY7CBGCIG/GN0JCS300jqeJj8Sd84H5AXtVE/kMcynz2MzCJUN5L0FXkKCHR2vWYZ8 K8cK7XYXsTBgVjY+EuiuKmPx3rmnVsSGyberKIp9O3I2AlH3K/f6VxoXa5nsbgisFm5B 8RmZ0JMAHkxZmcPwpg2s2x0xecmPDn3iNA6zFJRJ0bR//PNrP/dq+8VATZ5pvRbzGzz3 7ajSKDpjnmklH0C6hbmqFlvRDXkNJQ+aF8dz2FqFl1wPukAu1nk5weZASYtt/EC4acjk tLYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IiJYuOlBmU0RcgmFiitXKtaXart9FqS66MFzruNWBFs=; b=C3ahWU99/cytl5ONHDMNfw8MwhIdLYiudu++FQtwlw5oIv1lKzP/sid+0UFERfx+IF fWIsWjKriCGJAq8MW+UmYIPLhKKL+N8RyclNGf9/6FVi23r8kolBRXF63P4t4vQKOjXh FJuubkZl6uxtGLN4egG4rdh2GCPC7gi13CXfBwALkum4oAKvWivoibfyNB761t/DA5qT xVp2iT92JXFEv4QP+weUey94HQBmYUbuGx3DSazQVvfhueiKAIwj1X68KCXXWBro2rQY C/THjySpuasYNJh7Cn1KZ54fSN3XUPZSvEYgWjwTsA04F+HPm5KC7BrieGlqg2zdH2+J jRVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@schmorgal.com header.s=google header.b=Nz5TVA75; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=schmorgal.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a17090282cc00b00190fde95ac5si29526967plz.411.2023.01.16.12.38.53; Mon, 16 Jan 2023 12:39:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@schmorgal.com header.s=google header.b=Nz5TVA75; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=schmorgal.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233911AbjAPUZB (ORCPT + 63 others); Mon, 16 Jan 2023 15:25:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233779AbjAPUYx (ORCPT ); Mon, 16 Jan 2023 15:24:53 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4BD026595 for ; Mon, 16 Jan 2023 12:24:51 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id z13so3592706plg.6 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=LjMmdZbEXd2pBpw0dwzYtrmdS25Im/epmM9EMsV4ysbA5pEoUh0Fo+t92Vuva6NQ66 dBCcDxGMHSL1xBdtYP3rmu5qbLwzwQgJi/Fwj5sXV6dUgrEcq7r2Q69F7UlhTMcmfCTC dxlLeqZDSgvTDEStGw8GggXz1iWQI6A5I6XesflGHxIi6gyXZc3w9hfhOhzCvHC4bOQr vMkFTvDLANg/6wWaVZJfqnJZ4drnBPJKORwU9dbLYdEKlMiiJOrFESR90D4TQV/QpcOA dvFd+0zJeKCLqGbgFe+wqHicb1XnBx0jN4vxwRmKmKxC+OAJNmu+Z/gVXS6n8GFDQieN wrcw== X-Gm-Message-State: AFqh2kq0ZvWdpbvWWSMwUDARznJF9FhSYy2VwnbZ83DJoE3rg+/ADr/A pDopQQbutrHNlyCVJCsGg+VO4Q== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.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 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 = -- 2.34.1