From patchwork Thu Dec 28 13:14:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1880846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mw/S9qR1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EQkocp9s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T18Bn51D6z1ydb for ; Fri, 29 Dec 2023 00:15:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dHR1T2aIPqp1ruNcSRb0Qr/rpPhI5x04M90ITK+qzc8=; b=mw/S9qR13QuAaa lQHpHhd9wcGBZCY2lm2VadmDrMgQcSpxA86NA3fJj75Sd9FVIvUwbkmPBSKIAAOL6BEtPRfp8T3UN WQUJcEIYaBIQwpiFqi2Ko+hE/KWaxwpvkn/QeEtfgslYsYyor/aTUaOx2qD14dTjcgPkttHvRDyHk bXkvafP/nvUf00uOSWF0FbYTGJvGro7cNxazf3Ekuc7APAuGw+UINJ22slZqtUlgU/ih7spDnSHgJ RroMM5r+EkXAgHOqvULrCITFt4bX62d6Dlepglm3Bad3K3kzHHQ6iA9a/gO5lXEXstKVJi1r02/ck i8DPwuUsMqjkAQsFw1ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDs-00GtrZ-0a; Thu, 28 Dec 2023 13:14:52 +0000 Received: from mgamail.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDq-00GtrA-0K for hostap@lists.infradead.org; Thu, 28 Dec 2023 13:14:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703769290; x=1735305290; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=G9Kdjx8h6J3S6wOblIJeJNxeCeqVSwtDeX4MlnpOcsI=; b=EQkocp9so0qmnfqINKBpv6YD5Pn+ItMyDNMLNHkCAsqZmJ5/M9c/4kgO ZlFFGS2iJpbMY/abD28vasMPrSSfbokSjffykAk/FBOo9X15ztjMj4sfE Nft71RFR2JjvbDR7+S8KOnl9Ut/OpXo8/7Kvf0P7DGCdvFEq4+G7ftgPn aAELrtV8XcwxJGszZ17tQV9EAWjn9jjCq1d2LHxRzsr/baHJPNgmyC83e wi57yER1qEZ/w6juCpyWhiPY/x4hTVGXzx6zUuaVtTPgh5cWApldQOUWm F9HoBKaFWFN58XUUr6vvuQOd9ds/Cj9ymGdaos3JnlP3BBvRKfmClKBWE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10936"; a="381516655" X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="381516655" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="20249972" Received: from unknown (HELO WEIS0042.iil.intel.com) ([10.12.217.211]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:48 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH 1/2] nl80211: Retrieve maxattr via genl for nl80211 Date: Thu, 28 Dec 2023 15:14:05 +0200 Message-ID: <20231228131406.2439640-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231228_051450_209008_88AF68E0 X-CRM114-Status: GOOD ( 14.50 ) X-Spam-Score: -0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg Older kernel versions may not support all attributes and may refuse commands that include them. To avoid sending too new attributes query the highest supported attribute. This allows adding appropriat [...] Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg Older kernel versions may not support all attributes and may refuse commands that include them. To avoid sending too new attributes query the highest supported attribute. This allows adding appropriate checks where needed. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 28 ++++++++++++++++++++++++++++ src/drivers/driver_nl80211.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index a3bb2d5251..b56ca852d3 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef CONFIG_LIBNL3_ROUTE #include #endif /* CONFIG_LIBNL3_ROUTE */ @@ -1938,6 +1939,8 @@ static int wpa_driver_nl80211_get_country(void *priv, char *alpha2) static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) { + struct nl_cache *cache = NULL; + struct genl_family *family = NULL; int ret; global->nl_cb = nl_cb_alloc(NL_CB_DEFAULT); @@ -2009,6 +2012,29 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) /* Continue without vendor events */ } + /* Resolve maxattr for kernel support checks */ + ret = genl_ctrl_alloc_cache(global->nl, &cache); + if (ret < 0) { + wpa_printf(MSG_DEBUG, + "nl80211: Could not allocate genl cache: %d (%s)", + ret, nl_geterror(ret)); + goto err; + } + + family = genl_ctrl_search(cache, global->nl80211_id); + if (!family) { + wpa_printf(MSG_DEBUG, + "nl80211: Could not get nl80211 family from cache: %d (%s)", + ret, nl_geterror(ret)); + goto err; + } + + global->nl80211_maxattr = genl_family_get_maxattr(family); + genl_family_put(family); + family = NULL; + nl_cache_free(cache); + cache = NULL; + nl_cb_set(global->nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, @@ -2021,6 +2047,8 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) return 0; err: + genl_family_put(family); + nl_cache_free(cache); nl_destroy_handles(&global->nl_event); nl_destroy_handles(&global->nl); nl_cb_put(global->nl_cb); diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 2b2bc9b117..315b88b01a 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -32,6 +32,7 @@ struct nl80211_global { struct nl_cb *nl_cb; struct nl_sock *nl; int nl80211_id; + int nl80211_maxattr; int nlctrl_id; int ioctl_sock; /* socket for ioctl() use */