From patchwork Tue Nov 14 17:14:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455726 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F5C44122F for ; Tue, 14 Nov 2023 17:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eLseEZWC" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-1ef370c2e12so3495466fac.1 for ; Tue, 14 Nov 2023 09:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982143; x=1700586943; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nrDqqaZb9whfCkJyiZe+lLMc4DjlSeaJzAIqtjDAn6k=; b=eLseEZWCXxBah59UbEA6m1bVORjUzxAoeZhoVV/Pw0UE8TOOwahXhjFxuaM5qHfDpF aj66R0wAPe4QL18MTY6do8Z9lp53al34J0xnlveTlRwmWjFAXC0nbavCy+muMtMNrubd RqXU6U/i3e/4ps2sJ1e7TGiEQikmTEQUaPt4H3LYvzjZtPjvqYSpbo2skW9qlGb2wAvC JsgtuoDsJPz7wTQ4GcRTolp6Ukt4GDcdBWfbl7lSoS/X1SKDQZq3QxutrGWw7XAuxmRi IEL3ctFtCbU8Hkzm4Dkc06WGih1vOHu5zuvjKkPIHg97K4hBR4cbBOmgFr5SqNUbcJ9N keLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982143; x=1700586943; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nrDqqaZb9whfCkJyiZe+lLMc4DjlSeaJzAIqtjDAn6k=; b=kt52ce3IbsOC4JPGkOipWpfFiE3kwyTDE1BvTGMxlEJLArTH39fsG75rCbOIhgMvs8 o9xv64bHZNWVgZLaKIVabdT0Fiq2nx6nrwqhz/ZDTBfP+Ivp875ez/eQvEyHkhgQycMb OjblgMgfK+IeqKbQFCudpSmuayYJSZsHxUD5gXRUqVlCrD7WSjafg3wMAlBX9M9UsHNL 3HReqYaN2mn2tbhxiUzMIbS5Slgd8jP1CbsL4/Yc7U+tMJwyS+FJ+yd1KQ7egkPmy6Xq tymjhCArR7TAdJBD8la4sMzqEQ6bITvJvBrGXnDZWtm0zhST/u88ZrVc0/cdMHid/P/j nK2A== X-Gm-Message-State: AOJu0YyGBA7o8+uS+2v1H8JstZk2MlOkzxv0NMwrlaDDxLFkSLdYU/GB q0UcD8GqF6PeheAlCdOClZO4Gpyyzmg= X-Google-Smtp-Source: AGHT+IFNIyVr7bnDJ3X8rkDi0xinniowztiPPuOcPWzmiO2ushIFkNJo4MjwdSjT3X7S+dyF1LK33A== X-Received: by 2002:a05:6870:a54d:b0:1ea:b1c:b859 with SMTP id p13-20020a056870a54d00b001ea0b1cb859mr12901777oal.35.1699982143618; Tue, 14 Nov 2023 09:15:43 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:43 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/11] netdev: Fix obtaining reason code from deauth frames Date: Tue, 14 Nov 2023 11:14:24 -0600 Message-ID: <20231114171455.1108856-1-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The reason code from deauthentication frame was being obtained as a uint8_t instead of a uint16_t. The value was only ever used in an informational statement. Since the value was in little endian, only the first 8 bits of the reason code were obtained. Fix that. Fixes: 2bebb4bdc7ee ("netdev: Handle deauth frames prior to association") --- src/netdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/netdev.c b/src/netdev.c index 867126583215..49854b16d846 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1264,6 +1264,7 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg, uint16_t type, len; const void *data; const struct mmpdu_header *hdr = NULL; + const struct mmpdu_deauthentication *deauth; uint16_t reason_code; l_debug(""); @@ -1298,7 +1299,8 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg, if (!memcmp(hdr->address_2, netdev->addr, sizeof(netdev->addr))) return; - reason_code = l_get_u8(mmpdu_body(hdr)); + deauth = mmpdu_body(hdr); + reason_code = L_LE16_TO_CPU(deauth->reason_code); l_info("deauth event, src="MAC" dest="MAC" bssid="MAC" reason=%u", MAC_STR(hdr->address_2), MAC_STR(hdr->address_1), From patchwork Tue Nov 14 17:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455727 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D619F41233 for ; Tue, 14 Nov 2023 17:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hw/+1MEG" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-1f256362bb5so3496844fac.0 for ; Tue, 14 Nov 2023 09:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982145; x=1700586945; darn=lists.linux.dev; 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=cLJ4CbftyEwGDpwZnUaAvHEO/ek/+V6kucfAC1ivfHU=; b=Hw/+1MEGpS9cUCXEyjCJLMzzNNx/3uIIB6KZQ9749pEnPt32yZzckhW11iXKqLt+2t BcgEg65eMn/TZstWotvVwYSYuttjWXJV2zRidSM99CcxZ78ZP/hAYdU383qJug0nmZrH mO0ZkQXQL6Ojw3xszXLk0wfDL7TXpmAiUmoZP3UKz/hBdRL+7zFPC8ZJhatLUKMxslRd B2ZrF0w29CFwdRLHfTsBsP7qYg2B7kqcwKITWt2KTghFj8YTcaUo74wKak6WU4NsHMxY bDET7Q210yMF4AJlmPOKOUS8ecwrN3TSZhZBJeOF6Rmrw+cBPzerOPLtV6CiDs105Qnk e+Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982145; x=1700586945; 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=cLJ4CbftyEwGDpwZnUaAvHEO/ek/+V6kucfAC1ivfHU=; b=FCPMSRYVP5TYk3r3/AifUEIkWzOueLxEodC3DPsDbTDVu1U5EFyMN/IRWrOtYQUMS4 A0VzfwmBEwdbPZZkqGESc1fLjcX9+aT4m41hV8GNIli08bBZq3e341r6zrEdRhcbruYm vvBkDVfL2folV9WDKwPdZ5jrDKUxtGVo6qOEObIyeGmb+iHeH4vJOw0AFHsSPmk/pPzM iNW8YReUowUtzIeq9hHVv/FHdZDu66pkqAEaWzz0TS7y4TBFZgwy6O44sVzkU92Hz3gu eCQUkEt4SRF+lcKmaWtQ3t6M/aNnsVW9WSC/EHZGg1mhdQ/YcWaOuvO5UjE82ayAUk8a DT5w== X-Gm-Message-State: AOJu0YwLQcSdhTLrEtxUHq5OFMutp7bQ5zE/MjCIrD/Oge6uwC7Asl6U iBVGTjSCkxBhtnBvIb1ZAf3WPOL102A= X-Google-Smtp-Source: AGHT+IFQeRAfsAyZq1RUcSa1Tu9y5LvTFea0AG2kay/tSOe9GGAmZ9xwonHKW7s/cVpsEqZMF7YVQw== X-Received: by 2002:a05:6870:f813:b0:1f0:630c:a589 with SMTP id fr19-20020a056870f81300b001f0630ca589mr14034958oab.46.1699982144991; Tue, 14 Nov 2023 09:15:44 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:44 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/11] netdev: sa_query: Fix reason code handling Date: Tue, 14 Nov 2023 11:14:25 -0600 Message-ID: <20231114171455.1108856-2-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The reason code field was being obtained as a uint8_t value, while it is actually a uint16_t in little-endian byte order. Fixes: f3cc96499c44 ("netdev: added support for SA Query") --- src/netdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 49854b16d846..72876f3a39a1 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -4956,8 +4956,7 @@ static void netdev_unprot_disconnect_event(struct l_genl_msg *msg, if (!hdr) return; - /* get reason code, first byte of frame */ - reason_code = l_get_u8(mmpdu_body(hdr)); + reason_code = l_get_le16(mmpdu_body(hdr)); l_info("disconnect event, src="MAC" dest="MAC" bssid="MAC" reason=%u", MAC_STR(hdr->address_2), MAC_STR(hdr->address_1), From patchwork Tue Nov 14 17:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455728 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D45724122F for ; Tue, 14 Nov 2023 17:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zd0EfSQT" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-1dd71c0a41fso3436421fac.2 for ; Tue, 14 Nov 2023 09:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982146; x=1700586946; darn=lists.linux.dev; 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=PwojZLotuMnxVmeffT7lcFhT/Z1mjEG2j1MhEx5cyu8=; b=Zd0EfSQTVpdGCnCHv7VEgrcYkyg57LrAy1YCtH/MtwHwtwyaBrI8stXy4tlilXnm9H FzUxsVBuXuMuWFgBs4ClugNNXHucFaKrPafoC/2R0153p37OfvMBcadEihUXsIY2sb0W nETUcsJIYM9HqL3Xfn87AVZXNAwvNCU6toRH+Q7W4R2nc73kNb25yLY+KaECgy+ac6fl k7fbDh3T5Io7WzPMBerEhELa4Uf44Pa+ra4m5h6cRAiDWdINZeXLAOWOYFBUmlA+S73y 32ljWunROE/0/LdgK6UNbRYt07cgZHNHLK57x7qkM40ROxvaTKGJWLouCKexooMP1pp0 cfhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982146; x=1700586946; 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=PwojZLotuMnxVmeffT7lcFhT/Z1mjEG2j1MhEx5cyu8=; b=SKht0jB4s0SO9CSEqe3Qy7aAa61mbtuwNnwfYx08Kbd0YoJEKy3pgY8aFnSLTLu7n5 /HEfK23ZLZ/OTso/1QYiI//R7v4WF+tK3mmWTWqEwjnWHmI26jOHBas9y4UnJsKtbhu/ w9l+90vMTnk0HSjC6C11SlFED8W/w7zZqZvYkfWMz1crDz/WrgV1fWC3r10hGnKgvPyK M7l5zV7db3tmypSFJGQxKCIlq967Bamm5sFA8hZ8W56w8BGXptf9y+IwpdJ9HbpcbmmQ HJADF15YArs8WY49h9llOOhNRqHV4Ilt9CXyTN8i9Y+5kPnAJf8GOFMJ2r9TzwxUyG4k Wpow== X-Gm-Message-State: AOJu0Ywo2RBq4dPfGo5cFFgW7hoWI7SybIdaaK6zdRX3vH5tvxmwbXqy jupeUM5euDNFuZQ5oz8B3UlyDLvCOTg= X-Google-Smtp-Source: AGHT+IGloXYulKt7TfvdzsYzi314aCg0RKv0o9ysXx3+iHWOHk4wyDggA565z7x2RYYWbhPPKmrcsQ== X-Received: by 2002:a05:6870:160d:b0:1f4:dac9:75a8 with SMTP id b13-20020a056870160d00b001f4dac975a8mr12099727oae.10.1699982146391; Tue, 14 Nov 2023 09:15:46 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:45 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/11] netdev: Use CMD_DISCONNECT if OCI fails Date: Tue, 14 Nov 2023 11:14:26 -0600 Message-ID: <20231114171455.1108856-3-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If netdev_get_oci fails, a goto deauth is invoked in order to terminate the current connection and return an error to the caller. Unfortunately the deauth label builds CMD_DEAUTHENTICATE in order to terminate the connection. This was fine because it used to handle authentication protocols that ran over CMD_AUTHENTICATE and CMD_ASSOCIATE. However, OCI can also be used on FullMAC hardware that does not support them. Use CMD_DISCONNECT instead which works everywhere. Fixes: 06482b811626 ("netdev: Obtain operating channel info") --- src/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netdev.c b/src/netdev.c index 72876f3a39a1..ebb93a74d8aa 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2989,7 +2989,7 @@ error: deauth: netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - msg = netdev_build_cmd_deauthenticate(netdev, + msg = netdev_build_cmd_disconnect(netdev, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, From patchwork Tue Nov 14 17:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455729 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EEF74175D for ; Tue, 14 Nov 2023 17:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gKjmiPHE" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-1ea98ad294cso2856744fac.3 for ; Tue, 14 Nov 2023 09:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982148; x=1700586948; darn=lists.linux.dev; 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=t2BQm43xKw90Q/cNhuMtYsHcu6I5CUoj4vv8xUqZDtQ=; b=gKjmiPHE1cwCiv1UeavYifCZyShIc1E8EAzXcDO2Wz38ToXswizPYctiwS88BjEdE0 gMJmUa5UdzTn7eXvkJY/O1F9YXF4aDBtSu4dGcqTLqvLw4JKAA0iRvarZdaeK6nrXEAd tGjNZhBdyNKZfLvufvdze4jgSwGbTTYpvwPhM0flRAUhNxU/SWCweNFn0Kx7a81FYz2w 7pz80HxiF7Gv5UXUshlOhC/BsDhp6LmdmiOkEYM6NbyGbY7+CNycIDsOndTIyu2QpVX6 tjGy2BDvoYuEuWTMlVKcMH+VJnGm6AWZdzBt/+ABnnk6XRNfKAkXiMzOJR8sYlZH/L/G sjng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982148; x=1700586948; 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=t2BQm43xKw90Q/cNhuMtYsHcu6I5CUoj4vv8xUqZDtQ=; b=n1zkvwBlP4Bw3ylkheTm6PuJXxiMmV8hDqP43tsH91cAGz/Uch7dJs1SXOAEFOeLhG CiN6W4jclnG+xH/h3CAzEmZWvAl3CXnSns316B2ucdevbG2zr3zNA2eYLD8cKKUrdbKg 1t799FsKiNRsbs99PRIz/8YcEcT6DshQAP3E2qAIRLT/QUm+Ih35jTjp1Z6CP4BcdyBB VLFguAuAcLB1ttDbfuKe2rNOKGMIhqhepGNseXVt3CBZ6g4T4/PSMS/cBaQjVdV8f4+7 b2nD1DzC4HcWVpMglwFzWx/YP6MFuXYOlxnwkVpBhqqPNYIIfDQmUgfw4HNQGsoCbYzV FQbQ== X-Gm-Message-State: AOJu0YzfPQSmWL0+53yoRHTuiZFeXCax5b8K6JK5Wl23gwpIKBPxZIdx WA6sxmWyjC5zQBNgexnOH3AKQWtx87Q= X-Google-Smtp-Source: AGHT+IHdxFMvRz0Q6zOrg7c1ZAhn27bd+GWPAMVmPqOqJCTWGv/d70FxFnKOQAbYue1h0etaNGc00A== X-Received: by 2002:a05:6871:4308:b0:1f4:d069:cae9 with SMTP id lu8-20020a056871430800b001f4d069cae9mr10502996oab.32.1699982147455; Tue, 14 Nov 2023 09:15:47 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:47 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/11] netdev: Don't unnecessarily call netdev_connect_failed Date: Tue, 14 Nov 2023 11:14:27 -0600 Message-ID: <20231114171455.1108856-4-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 netdev_begin_connection() already invokes netdev_connect_failed on error. Remove any calls to netdev_connect_failed in callers of netdev_begin_connection(). Fixes: 4165d9414f54 ("netdev: use wiphy radio work queue for connections") --- src/netdev.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index ebb93a74d8aa..6792bb5601e2 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -3605,19 +3605,16 @@ static void netdev_mac_change_failed(struct netdev *netdev, int error) WATCHLIST_NOTIFY(&netdev_watches, netdev_watch_func_t, netdev, NETDEV_WATCH_EVENT_DOWN); - goto failed; - } else { - /* If the interface is up we can still try and connect */ - l_info("Failed to change the MAC, continuing with connection"); - if (netdev_begin_connection(netdev) < 0) - goto failed; - + netdev_connect_failed(netdev, NETDEV_RESULT_ABORTED, + MMPDU_STATUS_CODE_UNSPECIFIED); return; } -failed: - netdev_connect_failed(netdev, NETDEV_RESULT_ABORTED, - MMPDU_STATUS_CODE_UNSPECIFIED); + /* If the interface is up we can still try and connect */ + l_info("Failed to change the MAC, continuing with connection"); + + if (netdev_begin_connection(netdev) < 0) + l_error("netdev_begin_connection() error in mac_change_failed"); } static void netdev_mac_destroy(void *user_data) @@ -3649,14 +3646,9 @@ static void netdev_mac_power_up_cb(int error, uint16_t type, return; } - /* - * Pick up where we left off in netdev_connect_commmon. - */ - if (netdev_begin_connection(netdev) < 0) { - l_error("Failed to connect after changing MAC"); - netdev_connect_failed(netdev, NETDEV_RESULT_ASSOCIATION_FAILED, - MMPDU_STATUS_CODE_UNSPECIFIED); - } + /* Pick up where we left off in netdev_connect_commmon */ + if (netdev_begin_connection(netdev) < 0) + l_error("netdev_begin_connection() error in mac_power_up_cb"); } static void netdev_mac_power_down_cb(int error, uint16_t type, @@ -3870,7 +3862,7 @@ static bool netdev_connection_work_ready(struct wiphy_radio_work_item *item) } if (netdev_begin_connection(netdev) < 0) - goto failed; + return true; return false; From patchwork Tue Nov 14 17:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455730 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E150741744 for ; Tue, 14 Nov 2023 17:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KZYyIl7U" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-1f060e059a3so3705656fac.1 for ; Tue, 14 Nov 2023 09:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982149; x=1700586949; darn=lists.linux.dev; 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=YpZSHOxuc6hY09H9BC1e0xyMpal+TYiPGj637gUyjGo=; b=KZYyIl7UPwUAEi3BlwsqF6lR92olYRhkGB10NzxF2quUNLXE0/wqjLO5PSEVakRmOx ioFDrExq2zEEiO7gDWJxTPQMA103v2pACbN4i/yssQmer4jNb6l+SvxCIFCPXOe5+kGk cfo1nPECUJJ6sWk9ZO+iAdk9RkF0OG/QiW2hyOlocf1/907Az7Xxbk4UYBGkgTJCZ0GN qbvSF1Ih+6QS6ua7p92l9h9z5UbPqCzWtLplBovWs5sb2ouIce1dCBSS82LYo4xd8ksc MJDE0Xgsgdz4Y7ZvvH98Ru1+LV1dF8CiBUYw/srWFltR8FDKhYRTEVn3MSIMNr128TS9 hOew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982149; x=1700586949; 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=YpZSHOxuc6hY09H9BC1e0xyMpal+TYiPGj637gUyjGo=; b=J7XuF6n2qlT7Jj+ef7oHutJ/CACal17AqGWSFQ6ROz3kDqPcToDAAtPmz/rf6Kxmpw WIN/2QxyHGtyher8ouztgm4c/1iAlKK5FGjj3n3Mtp3oXstBqq6eMJ+hBt2gefh+9a3V a8kheYJidFRbVa37NWpHD4eGSN9EGtE0kq7adNcB55kLiavCrNglyemtOvDoy7raT0Cd IYQRZVXkaWDgmCM+dEzREq5hXnbx02fVU1fTY6po8DE0WuuY+ABgC+ualtCqSsDdQCsN KxpQz+NPnqSrGZnKZGiLZoB1qdbs9C5C83F0MqSD3x20VBA2JouzbDR342eELWO/ajY9 WkoA== X-Gm-Message-State: AOJu0Yxd0XzeiG5w77rGh+3xV/aoyqdG/9VXyLmisZD0eLrIFo06V8aV cYpaJx5RcFaXe2H2TyrY0Uk8iwxiujE= X-Google-Smtp-Source: AGHT+IFuJHLGgmiq5iVMCrwBu2INPV/5G9p4pZfeW8/H9H9+2PVx+9fcN7fz+8EhgLMceoZq+2SkbQ== X-Received: by 2002:a05:6871:b1e:b0:1f4:b55c:46b4 with SMTP id fq30-20020a0568710b1e00b001f4b55c46b4mr13421511oab.43.1699982149364; Tue, 14 Nov 2023 09:15:49 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:48 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/11] netdev: Move CMD_DISCONNECT builder to nl80211util Date: Tue, 14 Nov 2023 11:14:28 -0600 Message-ID: <20231114171455.1108856-5-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 22 +++++----------------- src/nl80211util.c | 12 ++++++++++++ src/nl80211util.h | 3 +++ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 6792bb5601e2..1f6920028a03 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1245,18 +1245,6 @@ static void netdev_cmd_disconnect_cb(struct l_genl_msg *msg, void *user_data) disconnect_cb(netdev, r, disconnect_data); } -static struct l_genl_msg *netdev_build_cmd_disconnect(struct netdev *netdev, - uint16_t reason_code) -{ - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_DISCONNECT, 64); - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); - - return msg; -} - static void netdev_deauthenticate_event(struct l_genl_msg *msg, struct netdev *netdev) { @@ -1460,7 +1448,7 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs, return; } - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, @@ -2246,7 +2234,7 @@ void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code) switch (netdev->type) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_P2P_CLIENT: - msg = netdev_build_cmd_disconnect(netdev, reason_code); + msg = nl80211_build_disconnect(netdev->index, reason_code); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, netdev, NULL); @@ -2989,7 +2977,7 @@ error: deauth: netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, @@ -4159,7 +4147,7 @@ int netdev_disconnect(struct netdev *netdev, } if (send_disconnect) { - disconnect = netdev_build_cmd_disconnect(netdev, + disconnect = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_DEAUTH_LEAVING); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, disconnect, netdev_cmd_disconnect_cb, @@ -4695,7 +4683,7 @@ static void netdev_sa_query_timeout(struct l_timeout *timeout, l_timeout_remove(netdev->sa_query_timeout); netdev->sa_query_timeout = NULL; - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, netdev, NULL); diff --git a/src/nl80211util.c b/src/nl80211util.c index 8cc3ea39c4d3..44a8ebe50300 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -284,6 +284,18 @@ done: return ret; } +struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, + uint16_t reason_code) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_DISCONNECT, 64); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); + + return msg; +} + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len, const uint8_t *ctr, diff --git a/src/nl80211util.h b/src/nl80211util.h index d26d286f95a7..9eb8681900b8 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -28,6 +28,9 @@ struct band_freq_attrs; int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...); +struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, + uint16_t reason_code); + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len, From patchwork Tue Nov 14 17:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455731 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D19441754 for ; Tue, 14 Nov 2023 17:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mgefcPiC" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-1f03d9ad89fso3401861fac.1 for ; Tue, 14 Nov 2023 09:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982150; x=1700586950; darn=lists.linux.dev; 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=ql2od1/8gLq3lw/BVJZLx8gEIWwhKh1F4Wk5I9HTr+g=; b=mgefcPiCPlLgSSnTt1rPNNrnO2pmdXsO5ixZ5CddhBHkUw4Gl+kE7lcqbXLCBBKmI3 BVdvCNUHHQHx3S4sRMEgM/ZsgzpYMScrPnpU7JqgJ8ejkI3gVto25bAFwOFArQy55LN7 nUZMav5+g9gVshS48EsTUO4ZlYLQHOo/66nExuI2cHjZqBbwK5gr4XEFwVTtm7rMF1wL aOpyfRaXbVSYHdhigf4NraQjh0aNWJ8djDxb2jDDePHGSBilU+R2GH+Ofw711B+jvCnz kPXU6EMwO8CggYOqPMR11E6cq1GIHWUlOqNfZv8PVRYxWMqAasXDJNAN7WuXrg7Tmz6k dgQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982150; x=1700586950; 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=ql2od1/8gLq3lw/BVJZLx8gEIWwhKh1F4Wk5I9HTr+g=; b=LXqP3Jdvj9Y8ih8TzlHF1xgYhrmzr+wp/LPtJO59ezuy2vwru14QRMZqDdpD7Dl1xz EoewRBuCBUm6Gufy+kUm9AOq17ZHtuw7L/chgPklHLBfeqIHdpMRmarscfRPbekBrv5a th0iR2pQUn1g2MkgA2raVlo7RXlSEw8mbxoi0xwTQ0onc94di9NS4g7cMBZ329U4DGVp R7CqkfK1gfh/1uA07cNXJrSztAQbl7gsT2DtFUYtIomYJ7aYV7h98EjSlbFT9D0WwIkm 32NfRVrzP/bmWjsssoJ9t5mDeYy6J8038Rin+qE9ghCUI3sOWLnj5ogTUgVCg+qagB31 ZhgA== X-Gm-Message-State: AOJu0Yyf9Ncn8RBH8D/GNGI8KTLDqoCjYCP3GgL+lL/ky//mQpm+13UK t63+PlEUkP/5x5OwTlZ6vIqw6M8QOnw= X-Google-Smtp-Source: AGHT+IGpapyR+q03FeeB6wSaKoyvDzdm5KMZkT+LjM2tw6es4KlJezpr5veu1Fl83ZZnwlW2JYVOIg== X-Received: by 2002:a05:6870:ec86:b0:1ea:fd4:58fb with SMTP id eo6-20020a056870ec8600b001ea0fd458fbmr12977623oab.52.1699982150566; Tue, 14 Nov 2023 09:15:50 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:49 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/11] netdev: Move CMD_DEAUTHENTICATE builder to nl80211util Date: Tue, 14 Nov 2023 11:14:29 -0600 Message-ID: <20231114171455.1108856-6-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 20 ++++---------------- src/nl80211util.c | 14 ++++++++++++++ src/nl80211util.h | 3 +++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 1f6920028a03..6c35cd1b75e7 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1298,20 +1298,6 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg, MMPDU_STATUS_CODE_UNSPECIFIED); } -static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev, - uint16_t reason_code) -{ - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_DEAUTHENTICATE, 128); - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); - l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, - netdev->handshake->aa); - - return msg; -} - static struct l_genl_msg *netdev_build_cmd_del_station(struct netdev *netdev, const uint8_t *sta, uint16_t reason_code, @@ -3028,7 +3014,8 @@ static void netdev_cmd_ft_reassociate_cb(struct l_genl_msg *msg, netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - cmd_deauth = netdev_build_cmd_deauthenticate(netdev, + cmd_deauth = nl80211_build_deauthenticate(netdev->index, + netdev->handshake->aa, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, cmd_deauth, @@ -3163,7 +3150,8 @@ static void netdev_authenticate_event(struct l_genl_msg *msg, netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - cmd_deauth = netdev_build_cmd_deauthenticate(netdev, + cmd_deauth = nl80211_build_deauthenticate(netdev->index, + netdev->handshake->aa, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, cmd_deauth, diff --git a/src/nl80211util.c b/src/nl80211util.c index 44a8ebe50300..8ed260ad6f13 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -284,6 +284,20 @@ done: return ret; } +struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex, + const uint8_t addr[static 6], + uint16_t reason_code) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_DEAUTHENTICATE, 128); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); + l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + + return msg; +} + struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, uint16_t reason_code) { diff --git a/src/nl80211util.h b/src/nl80211util.h index 9eb8681900b8..1553047d1b8a 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -28,6 +28,9 @@ struct band_freq_attrs; int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...); +struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex, + const uint8_t addr[static 6], + uint16_t reason_code); struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, uint16_t reason_code); From patchwork Tue Nov 14 17:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455732 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3BA541754 for ; Tue, 14 Nov 2023 17:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VhVurZ4J" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1ef370c2e12so3495592fac.1 for ; Tue, 14 Nov 2023 09:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982154; x=1700586954; darn=lists.linux.dev; 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=pIXEicCogvcXHU6ju71ZFzMYtzrH/C5SFk01ftzMR7M=; b=VhVurZ4J+ki1vAM66s44yG5sHFLtN9HL91b4SYsv7UG3ZJA8M6Lp2rAw6JDZbS+LZU CXKSE3rBdJBwfSPZiDeiVYtB7IxhBljfVh78vEGr4PCaLpsUHH94dYXyNNGf3J1XAOBA 4OBWzgvbADBn6WKnoxKiL2mHrxbwiimCD7XViDJjPttYEsQCUztkIpa5QhVuEt+9eclh 3fMrqrvtzlwo4eBqfWyabuhareZhEQoOcuS3A5mmZ9hwQ5CjAxj9KLCNBMVfUBmYoN1x CQLggTSREIWhubTF+07qcB/0fiBYf4Vxk08zo4hfdCTh8KGObwygdeMlh+qlGFALt2bj 3fWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982154; x=1700586954; 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=pIXEicCogvcXHU6ju71ZFzMYtzrH/C5SFk01ftzMR7M=; b=EIihdoopWekvtNZONbQ+f5K32MVqsQvpHBDD7xN94sYndR6+892pgAbwLMrn/yGTOZ JJ1jNhVRYJ9oUg+9lhKrIzKtlpoFYrAELU7cK0nfHw6gGGY/bURGTIzy1OPfI8mmXfzK KLRZ3x4L1Si9+ZsOU+NiJ2Fbvhq8XaBkjLQubWheE7uwCJT+yvaf8Opffz/LCny0MEVE UOTiWoT8m4nGPgH+DKbcc+co9lDpolyKfjmNq+BI5OeB8gTLeXHEbORI+eoqiPdmQFhV yV9ArLOnn2bkbMsv0RiQSbkeImlj5hqrrDN4EIQNggG9oDQm71r/QtaOHUCDxiZUFgsU GGuw== X-Gm-Message-State: AOJu0YwWKvr2+uSCPajaU4K2HkbjpEMY8iWCKyfDc1q248RtLeJMAHRp BB2HYYL9/Z/Ig2mSAGbiP+LVuYjMP1E= X-Google-Smtp-Source: AGHT+IE2Zidmg0Zwtpjuv+RIn3Kqg01vW9xUR+30z3hGH3Bqnm9OlNJ4UJ3diBa9+uReCxgJnoQEpg== X-Received: by 2002:a05:6870:c90d:b0:1f0:8706:4c4a with SMTP id hj13-20020a056870c90d00b001f087064c4amr13225012oab.29.1699982152073; Tue, 14 Nov 2023 09:15:52 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:51 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/11] netdev: Move CMD_DEL_STATION builder to nl80211util Date: Tue, 14 Nov 2023 11:14:30 -0600 Message-ID: <20231114171455.1108856-7-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While here, also get rid of netdev_del_station. The only user of this function was in ap.c and it could easily be replaced by invoking the new nl80211_build_del_station function. The callback used by netdev_build_del_station only printed an error and didn't do anything useful. Get rid of it for now. --- src/ap.c | 9 +++++++- src/netdev.c | 56 +++++------------------------------------------ src/nl80211util.c | 16 ++++++++++++++ src/nl80211util.h | 5 +++++ 4 files changed, 35 insertions(+), 51 deletions(-) diff --git a/src/ap.c b/src/ap.c index 577f25a71def..bce389d39c9c 100644 --- a/src/ap.c +++ b/src/ap.c @@ -392,10 +392,17 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason, bool disassociate) { struct ap_state *ap = sta->ap; + uint32_t ifindex = netdev_get_ifindex(ap->netdev); struct ap_event_station_removed_data event_data; bool send_event = false; + struct l_genl_msg *msg; + uint8_t subtype = disassociate ? + MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION : + MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION; + + msg = nl80211_build_del_station(ifindex, sta->addr, reason, subtype); + l_genl_family_send(ap->nl80211, msg, NULL, NULL, NULL); - netdev_del_station(ap->netdev, sta->addr, reason, disassociate); sta->associated = false; if (sta->rsna) { diff --git a/src/netdev.c b/src/netdev.c index 6c35cd1b75e7..38fb759058c3 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1298,52 +1298,6 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg, MMPDU_STATUS_CODE_UNSPECIFIED); } -static struct l_genl_msg *netdev_build_cmd_del_station(struct netdev *netdev, - const uint8_t *sta, - uint16_t reason_code, - bool disassociate) -{ - struct l_genl_msg *msg; - uint8_t subtype = disassociate ? - MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION : - MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION; - - msg = l_genl_msg_new_sized(NL80211_CMD_DEL_STATION, 64); - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, 6, sta); - l_genl_msg_append_attr(msg, NL80211_ATTR_MGMT_SUBTYPE, 1, &subtype); - l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); - - return msg; -} - -static void netdev_del_sta_cb(struct l_genl_msg *msg, void *user_data) -{ - int err = l_genl_msg_get_error(msg); - const char *ext_error; - - if (err >= 0) - return; - - ext_error = l_genl_msg_get_extended_error(msg); - l_error("DEL_STATION failed: %s", - ext_error ? ext_error : strerror(-err)); -} - -int netdev_del_station(struct netdev *netdev, const uint8_t *sta, - uint16_t reason_code, bool disassociate) -{ - struct l_genl_msg *msg; - - msg = netdev_build_cmd_del_station(netdev, sta, reason_code, - disassociate); - - if (!l_genl_family_send(nl80211, msg, netdev_del_sta_cb, NULL, NULL)) - return -EIO; - - return 0; -} - static void netdev_operstate_cb(int error, uint16_t type, const void *data, uint32_t len, void *user_data) @@ -1444,8 +1398,9 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs, if (err == -ENETDOWN) return; - msg = netdev_build_cmd_del_station(netdev, nhs->super.spa, - MMPDU_REASON_CODE_UNSPECIFIED, false); + msg = nl80211_build_del_station(netdev->index, + nhs->super.spa, MMPDU_REASON_CODE_UNSPECIFIED, + MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION); if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL)) l_error("error sending DEL_STATION"); @@ -2227,8 +2182,9 @@ void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code) break; case NL80211_IFTYPE_AP: case NL80211_IFTYPE_P2P_GO: - msg = netdev_build_cmd_del_station(netdev, nhs->super.spa, - reason_code, false); + msg = nl80211_build_del_station(netdev->index, nhs->super.spa, + reason_code, + MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION); if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL)) l_error("error sending DEL_STATION"); } diff --git a/src/nl80211util.c b/src/nl80211util.c index 8ed260ad6f13..1d1d7099e575 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -310,6 +310,22 @@ struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, return msg; } +struct l_genl_msg *nl80211_build_del_station(uint32_t ifindex, + const uint8_t addr[static 6], + uint16_t reason_code, + uint8_t subtype) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_DEL_STATION, 64); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, 6, addr); + l_genl_msg_append_attr(msg, NL80211_ATTR_MGMT_SUBTYPE, 1, &subtype); + l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); + + return msg; +} + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len, const uint8_t *ctr, diff --git a/src/nl80211util.h b/src/nl80211util.h index 1553047d1b8a..755133a37bb7 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -34,6 +34,11 @@ struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex, struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, uint16_t reason_code); +struct l_genl_msg *nl80211_build_del_station(uint32_t ifindex, + const uint8_t addr[static 6], + uint16_t reason_code, + uint8_t subtype); + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len, From patchwork Tue Nov 14 17:14:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455733 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE18C41744 for ; Tue, 14 Nov 2023 17:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kOX1Bd97" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-1f4e17c1edfso1949495fac.0 for ; Tue, 14 Nov 2023 09:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982155; x=1700586955; darn=lists.linux.dev; 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=Wc2F2cwzb/8V3d03+M15TY+na+UMBijhWVv0q9U/3+M=; b=kOX1Bd97eikB2OhfeCez9EGiJcMttqVpic7TvWENOfgD6AKyiWCMcwp+78BwAthVSn 52vNj7K16kdHEAPrhZ2kryyW327YMm6pp38Uf5KZz8OmoX6XzpxIAxaAM2KQ+JxrL57T 99512ZromZAxk9st1GiDI5Hl53xf3tluf7nsDOVIi8jju4dCDFD3FGODk8qdWHKQRNzg EZj+7onyHCAqT1r9Ij5nK47dvu3Ho2bcwtaiGHeS9wZB1+OpoykH0rUhixBZLKPqLRQZ erGtB5X8MpRukBpV4BmC6FPCy+6T7ikzPFsvY4HssfvpGs+ph7z4ugSRyVYwI/JQ+12E akuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982155; x=1700586955; 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=Wc2F2cwzb/8V3d03+M15TY+na+UMBijhWVv0q9U/3+M=; b=cS7LuVKvqB1ONXmQjDWIjMgjykhJA2sE/gmN0O9l1rmK930qy33r3/ABWCwFRzEZlA boGSSbrjx6quhgvykvoHl3K+zaAhII4G22H07AoNVlgrPkl/9Jg5fmYk8bZYW2YQBndy IMkT+aDNG4XptEup3SI9GsG8lE6fmDqicR88ULDE9qLr/7YkJqY+lZ5R0b3KlgL/PIPK /jVLwpMXZQ7R+r4rE9VXRqEQATa6d5YgTMIsV2NMLSWsbAJz4dVlmilX0PZrggXnBnLr 6bMluYh+lsyXtDDm9E7GbpSGPekZLEwTaZ7HGdSXgghJIF3mfUPdQaBcFrBrRcAL1T+O rZXA== X-Gm-Message-State: AOJu0Yxaov8faUlBcUI2UrLHmyxM0GwMAf8go57A1//rcwl2cQXHYZ78 7NBT9jt5v47PNrkSmj5jdd9L3m5H+Hk= X-Google-Smtp-Source: AGHT+IHKYwz0w+pID75rhV537lcAM4VvTHGuI4O3zLXbvrs0whkm0m8kSgFDkpWAB7UWUGhpB8Ricw== X-Received: by 2002:a05:6870:c144:b0:1eb:1fa3:7af6 with SMTP id g4-20020a056870c14400b001eb1fa37af6mr13822968oad.18.1699982155451; Tue, 14 Nov 2023 09:15:55 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:54 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/11] netdev: Move pairwise NEW_KEY builder to nl80211util Date: Tue, 14 Nov 2023 11:14:31 -0600 Message-ID: <20231114171455.1108856-8-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 27 +++------------------------ src/nl80211util.c | 20 ++++++++++++++++++++ src/nl80211util.h | 6 ++++++ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 38fb759058c3..64d16d6dc8c6 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1898,27 +1898,6 @@ error: netdev_setting_keys_failed(nhs, err); } -static struct l_genl_msg *netdev_build_cmd_new_key_pairwise( - struct netdev *netdev, - uint32_t cipher, - const uint8_t *aa, - const uint8_t *tk, - size_t tk_len, - uint8_t key_id) -{ - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512); - - l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_DATA, tk_len, tk); - l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_CIPHER, 4, &cipher); - l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, aa); - l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_IDX, 1, &key_id); - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - - return msg; -} - static struct l_genl_msg *netdev_build_cmd_new_rx_key_pairwise( struct netdev *netdev, uint32_t cipher, @@ -2024,9 +2003,9 @@ static void netdev_set_tk(struct handshake_state *hs, uint8_t key_index, if (!netdev_copy_tk(tk_buf, tk, cipher, hs->authenticator)) goto invalid_key; - msg = netdev_build_cmd_new_key_pairwise(netdev, cipher, addr, tk_buf, - crypto_cipher_key_len(cipher), - key_index); + msg = nl80211_build_new_key_pairwise(netdev->index, cipher, addr, + tk_buf, crypto_cipher_key_len(cipher), + key_index); nhs->pairwise_new_key_cmd_id = l_genl_family_send(nl80211, msg, netdev_new_pairwise_key_cb, nhs, NULL); diff --git a/src/nl80211util.c b/src/nl80211util.c index 1d1d7099e575..437a52d55941 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -359,6 +359,26 @@ struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher return msg; } +struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex, + uint32_t cipher, + const uint8_t addr[static 6], + const uint8_t *tk, + size_t tk_len, + uint8_t key_id) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512); + + l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_DATA, tk_len, tk); + l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_CIPHER, 4, &cipher); + l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + l_genl_msg_append_attr(msg, NL80211_ATTR_KEY_IDX, 1, &key_id); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + + return msg; +} + static struct l_genl_msg *nl80211_build_set_station(uint32_t ifindex, const uint8_t *addr, struct nl80211_sta_flag_update *flags) diff --git a/src/nl80211util.h b/src/nl80211util.h index 755133a37bb7..00d1ea852671 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -44,6 +44,12 @@ struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, const uint8_t *key, size_t key_len, const uint8_t *ctr, size_t ctr_len, const uint8_t *addr); +struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex, + uint32_t cipher, + const uint8_t addr[static 6], + const uint8_t *tk, + size_t tk_len, + uint8_t key_id); struct l_genl_msg *nl80211_build_set_station_authorized(uint32_t ifindex, const uint8_t *addr); From patchwork Tue Nov 14 17:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455734 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3574A41754 for ; Tue, 14 Nov 2023 17:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AAq/7Vq3" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6ce2de8da87so3603974a34.1 for ; Tue, 14 Nov 2023 09:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982156; x=1700586956; darn=lists.linux.dev; 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=ABqOeyrR+B6VDoGYx3DuWNHyNf29JEtazO9NhwKGrC8=; b=AAq/7Vq390kQjZ/x1kG5zG180ZhdZNKHqXdQY7Q7YgX9EBt3pgMe2e9DZgU34PIRkN TKBw9k9mvVmoQFCfBsYRdsCRl4PydeOXntBat9bCVvzwebX75Ts7BtqvkEvE4Q0L20Il ztPaayGqCYMnsVe9NC8KVZlu7lflA0TvAyhbCRLy78x5LNqJJDBirg8Ru97QgqZCxS8K 5iCK6/sl5+rkFQ2BjJ+ex+4PigKp9AXpAWt7+/KIBHCCflVStlFctQ6VcCV8OLDDFNq/ RCCjyWC1DenJNLftLLh0vy3G/1egiJP4A2VX5L8KJDcah9bEl6HuH+JW6WVvl3l1d5pl W8RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982156; x=1700586956; 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=ABqOeyrR+B6VDoGYx3DuWNHyNf29JEtazO9NhwKGrC8=; b=WVVh7pCBr0jdsRw1BztMHLAi0kyGRPUDd+4t0n9BMwdOySiQR4PDJLfg9weaLcCJp8 l3T6bNcXbysMJLZIAzrruJyivsxedzrfNONx64vGx45QpRF3vC/tCVAQpyD46yGQw7Rb +WOQDS/ZjhM883ylseUnKoe8Xi7fyt6gV4dUCKsGr95NmrlkeLTsfwh10H3lbDAAdvpN 6MaDcLP8u25YsOrwI7acKO/YyWPKD3J+mVsVFWccUt0Pzyn+pncrN5cLRL+uJv7AqBoJ 9+hwGG2p583szXqtE7OgyETsyGLZ3fZDarKAtSZzocLV7FEKMQdqpsA7Z2Efagpd9B+R 1cPg== X-Gm-Message-State: AOJu0YwDZnV8LO68sxAV5/OYCLxrBDeijffTRYopovEfghmZQ5LIB6wp 4CTKvms2y4X58hky9BoxlLXn5f+Huic= X-Google-Smtp-Source: AGHT+IGxW1MJww5vCiHxwjWMZTzUH81dpZnDMKNWmy/Wec5SXSYNVPng+Pzr4xTl43gECObslDpu3g== X-Received: by 2002:a05:6870:5b8b:b0:1ea:50ec:7087 with SMTP id em11-20020a0568705b8b00b001ea50ec7087mr13275018oab.26.1699982156510; Tue, 14 Nov 2023 09:15:56 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:56 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/11] netdev: Move CMD_NEW_KEY RX-only builder to nl80211util Date: Tue, 14 Nov 2023 11:14:32 -0600 Message-ID: <20231114171455.1108856-9-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 36 +++--------------------------------- src/nl80211util.c | 29 +++++++++++++++++++++++++++++ src/nl80211util.h | 6 ++++++ 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 64d16d6dc8c6..086c3b9d158b 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1898,36 +1898,6 @@ error: netdev_setting_keys_failed(nhs, err); } -static struct l_genl_msg *netdev_build_cmd_new_rx_key_pairwise( - struct netdev *netdev, - uint32_t cipher, - const uint8_t *aa, - const uint8_t *tk, - size_t tk_len, - uint8_t key_id) -{ - uint8_t key_mode = NL80211_KEY_NO_TX; - uint32_t key_type = NL80211_KEYTYPE_PAIRWISE; - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512); - - l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, aa); - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - - l_genl_msg_enter_nested(msg, NL80211_ATTR_KEY); - - l_genl_msg_append_attr(msg, NL80211_KEY_DATA, tk_len, tk); - l_genl_msg_append_attr(msg, NL80211_KEY_CIPHER, 4, &cipher); - l_genl_msg_append_attr(msg, NL80211_KEY_IDX, 1, &key_id); - l_genl_msg_append_attr(msg, NL80211_KEY_MODE, 1, &key_mode); - l_genl_msg_append_attr(msg, NL80211_KEY_TYPE, 4, &key_type); - - l_genl_msg_leave_nested(msg); - - return msg; -} - static void netdev_group_timeout_cb(struct l_timeout *timeout, void *user_data) { struct netdev_handshake_state *nhs = user_data; @@ -2037,9 +2007,9 @@ static void netdev_set_ext_tk(struct handshake_state *hs, uint8_t key_idx, if (!netdev_copy_tk(tk_buf, tk, cipher, hs->authenticator)) goto error; - msg = netdev_build_cmd_new_rx_key_pairwise(netdev, cipher, addr, tk_buf, - crypto_cipher_key_len(cipher), - hs->active_tk_index); + msg = nl80211_build_new_rx_key_pairwise(netdev->index, cipher, addr, + tk_buf, crypto_cipher_key_len(cipher), + hs->active_tk_index); nhs->pairwise_new_key_cmd_id = l_genl_family_send(nl80211, msg, netdev_new_rx_pairwise_key_cb, nhs, NULL); diff --git a/src/nl80211util.c b/src/nl80211util.c index 437a52d55941..87e859c962e6 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -379,6 +379,35 @@ struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex, return msg; } +struct l_genl_msg *nl80211_build_new_rx_key_pairwise(uint32_t ifindex, + uint32_t cipher, + const uint8_t addr[static 6], + const uint8_t *tk, + size_t tk_len, + uint8_t key_id) +{ + uint8_t key_mode = NL80211_KEY_NO_TX; + uint32_t key_type = NL80211_KEYTYPE_PAIRWISE; + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_NEW_KEY, 512); + + l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + + l_genl_msg_enter_nested(msg, NL80211_ATTR_KEY); + + l_genl_msg_append_attr(msg, NL80211_KEY_DATA, tk_len, tk); + l_genl_msg_append_attr(msg, NL80211_KEY_CIPHER, 4, &cipher); + l_genl_msg_append_attr(msg, NL80211_KEY_IDX, 1, &key_id); + l_genl_msg_append_attr(msg, NL80211_KEY_MODE, 1, &key_mode); + l_genl_msg_append_attr(msg, NL80211_KEY_TYPE, 4, &key_type); + + l_genl_msg_leave_nested(msg); + + return msg; +} + static struct l_genl_msg *nl80211_build_set_station(uint32_t ifindex, const uint8_t *addr, struct nl80211_sta_flag_update *flags) diff --git a/src/nl80211util.h b/src/nl80211util.h index 00d1ea852671..d8026a8ebc19 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -50,6 +50,12 @@ struct l_genl_msg *nl80211_build_new_key_pairwise(uint32_t ifindex, const uint8_t *tk, size_t tk_len, uint8_t key_id); +struct l_genl_msg *nl80211_build_new_rx_key_pairwise(uint32_t ifindex, + uint32_t cipher, + const uint8_t addr[static 6], + const uint8_t *tk, + size_t tk_len, + uint8_t key_id); struct l_genl_msg *nl80211_build_set_station_authorized(uint32_t ifindex, const uint8_t *addr); From patchwork Tue Nov 14 17:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455735 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12EBF41773 for ; Tue, 14 Nov 2023 17:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lMR04ijn" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-1ea98ad294cso2856907fac.3 for ; Tue, 14 Nov 2023 09:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982158; x=1700586958; darn=lists.linux.dev; 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=3Fbz7LrAeXCvRPYPPnZxViqhJz/hbgV33uJ0mY7hiPI=; b=lMR04ijnP2OscXrM8YUMr3pG8C5oZnRrGVsJm04jj2GvnWS6DKzVOT80W/RzwHr3W1 2sPeXAmOQHSVdqe3R+uFK0Hu3hFIjYX9W23LSCr+qu1DPIXWFzj4P3caKshg2U3rUojA SVwxfWVZXSfvLx1Bkg3VfGTfgx7h0A7KmdNvXxsOBPSmS5upGIgOp4/bWC9mcnJbl3GZ OlvrwR/wGd5UQKx1eCFDV1PRu/aO3nKdQYYPt8Do/aB4GJtcw1WLAzhETxTvF60TSCjH fn7m0rhO5Mmwd508XWkINNMHZkmhgn2oI5GuK75/K8tmQbTm1r2d1bfc6ULXfrFIN7dG hZEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982158; x=1700586958; 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=3Fbz7LrAeXCvRPYPPnZxViqhJz/hbgV33uJ0mY7hiPI=; b=ZuwhYe0kf70TyNXPFMx2WYrJtE2LG0KTNJbqtrK1/4p2Sf/j7qiLViX/lYVXFA3kN3 uDPYcfKVdtk19i8Q1gfqx5BXRHAJj07fCYFfCAddmaPgSR7zTEahdIJG1rRfgYxhDBNb 0kfaBT+fIZuYnuaP/IwUtYWPOBUy2gcxnvW8POtPF8akU5nlMKJ2HhQED78nupnU+O7M e3/rnORpUxPGxAZheb+11ZRqqYrP9A/lhv8eGSFPy2TDZlU6lBOGZhQFGTHvP4vH2+IJ pdX4Xmp+aZRBsrCI5EvW4MTR3MWV2m5WpL5FR26qrwc5Y8sHt3qBtid7Co+ZxtvugocC 5V8g== X-Gm-Message-State: AOJu0Yyhxa/ExBwvE/tTg8mA8G4su31x4trkdzuhty1R/f407t/NkyVY tTZnq/sILnQLQn1o7ROG4TC0NOtmzbo= X-Google-Smtp-Source: AGHT+IHfEKvG69pwOE9axskxId17IPwLR0nU8WPmvSV+RfjM22aGO8juD1pm1whCThV0yC/fqcHSvw== X-Received: by 2002:a05:6870:a927:b0:1ea:7002:494d with SMTP id eq39-20020a056870a92700b001ea7002494dmr11232310oab.46.1699982157841; Tue, 14 Nov 2023 09:15:57 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:57 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/11] netdev: Move CMD_REKEY_OFFLOAD builder to nl80211util Date: Tue, 14 Nov 2023 11:14:33 -0600 Message-ID: <20231114171455.1108856-10-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 26 +------------------------- src/nl80211util.c | 24 ++++++++++++++++++++++++ src/nl80211util.h | 5 +++++ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 086c3b9d158b..418626d72579 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2163,30 +2163,6 @@ static void hardware_rekey_cb(struct l_genl_msg *msg, void *data) } } -static struct l_genl_msg *netdev_build_cmd_replay_counter(struct netdev *netdev, - const uint8_t *kek, - const uint8_t *kck, - uint64_t replay_ctr) -{ - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_SET_REKEY_OFFLOAD, 512); - - l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - - l_genl_msg_enter_nested(msg, NL80211_ATTR_REKEY_DATA); - l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_KEK, - NL80211_KEK_LEN, kek); - l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_KCK, - NL80211_KCK_LEN, kck); - l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_REPLAY_CTR, - NL80211_REPLAY_CTR_LEN, &replay_ctr); - - l_genl_msg_leave_nested(msg); - - return msg; -} - static void netdev_set_rekey_offload(uint32_t ifindex, const uint8_t *kek, const uint8_t *kck, @@ -2207,7 +2183,7 @@ static void netdev_set_rekey_offload(uint32_t ifindex, return; l_debug("%d", netdev->index); - msg = netdev_build_cmd_replay_counter(netdev, kek, kck, replay_counter); + msg = nl80211_build_rekey_offload(ifindex, kek, kck, replay_counter); netdev->rekey_offload_cmd_id = l_genl_family_send(nl80211, msg, hardware_rekey_cb, netdev, NULL); diff --git a/src/nl80211util.c b/src/nl80211util.c index 87e859c962e6..ef69cc718e04 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -408,6 +408,30 @@ struct l_genl_msg *nl80211_build_new_rx_key_pairwise(uint32_t ifindex, return msg; } +struct l_genl_msg *nl80211_build_rekey_offload(uint32_t ifindex, + const uint8_t *kek, + const uint8_t *kck, + uint64_t replay_ctr) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_SET_REKEY_OFFLOAD, 512); + + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + + l_genl_msg_enter_nested(msg, NL80211_ATTR_REKEY_DATA); + l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_KEK, + NL80211_KEK_LEN, kek); + l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_KCK, + NL80211_KCK_LEN, kck); + l_genl_msg_append_attr(msg, NL80211_REKEY_DATA_REPLAY_CTR, + NL80211_REPLAY_CTR_LEN, &replay_ctr); + + l_genl_msg_leave_nested(msg); + + return msg; +} + static struct l_genl_msg *nl80211_build_set_station(uint32_t ifindex, const uint8_t *addr, struct nl80211_sta_flag_update *flags) diff --git a/src/nl80211util.h b/src/nl80211util.h index d8026a8ebc19..9f8ae17aeaa4 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -57,6 +57,11 @@ struct l_genl_msg *nl80211_build_new_rx_key_pairwise(uint32_t ifindex, size_t tk_len, uint8_t key_id); +struct l_genl_msg *nl80211_build_rekey_offload(uint32_t ifindex, + const uint8_t *kek, + const uint8_t *kck, + uint64_t replay_ctr); + struct l_genl_msg *nl80211_build_set_station_authorized(uint32_t ifindex, const uint8_t *addr); From patchwork Tue Nov 14 17:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13455736 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F30241774 for ; Tue, 14 Nov 2023 17:15:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bZ61WrSD" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-1f0f94943d9so2849559fac.2 for ; Tue, 14 Nov 2023 09:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982159; x=1700586959; darn=lists.linux.dev; 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=2JE9D/wJvfTFJClqf7iFSfHGDUGfkLxXL48h1pslhSE=; b=bZ61WrSD4D6SVDlFG2ZdRjDIEW6vb3XvY/3YMAH5X9nsJDOVCHyYAlk/4CRk+YFs9D 2vqM9FPQSyjSRP3qjbhXQoNzgUe6cSRiMhM/f9QsBBJy6BdhpIPLXaOn5GdLu+Ng0mCj YEW7LKb6Tju4DF2WVegwHNr7eEsNmXatrkqjjA0qplAFBaNytEMCcGAte4Cv/zDu7M86 ITnw83sdx8JHCsHW/7Kvn82IpArJsIx63kC7XOyfwNKXxY36VZtqrpDnwMeDHnrgbqeB HvvZmR1VQ4ARfpJ1G8WM1b9M/qJkJDVpCYZWhr7cQ955arvQYIB63JTm/wGtK9nZygkx U3vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982159; x=1700586959; 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=2JE9D/wJvfTFJClqf7iFSfHGDUGfkLxXL48h1pslhSE=; b=uzZh1pdi6jDLsL746GH9tEhQuKk/48IOa+s+3uBMTeTX+Y8BJnnOPSKeU2L8Ftigq0 FWEFL+fbpx8sMxektiR6UlskPs4ENDPHywLtUTZ9AdnIfHivijyfNeBr4HIpFa9m9BIF fxO/3Pw8SNUoHiNH9OhYZIoFr0ZNzKZ/4xAKiOFGns+MhchlOegIlvARpvMacLkCN8RK n5/aw17TjEJdUNUy42HSppZwdmY4f296DBCmmYgrO6KLfq1tI/d5PttS1rayHZYheRd0 9S20YUQ6L5k0MoDxlozqGIfK8OxElWa7Hf90psbKB6XfpUu4a4uApSkre+ZN2QEtTxoj nRxQ== X-Gm-Message-State: AOJu0YythXsxxA7lRALWw1lqXQiLnctMrFkQK/Zliz3W6BW03/5Kj0BA L9MyEMW1mtEEF5tMTJherB88Dpqb24A= X-Google-Smtp-Source: AGHT+IGA3jfEBI2h2h2wFwKAwSRcNoF1oXlR/n3X/PJIW1TCP6Tj9rvG8YKBS4UPKSRIKOFUC+9quw== X-Received: by 2002:a05:6870:eca1:b0:1e9:bc79:9fa6 with SMTP id eo33-20020a056870eca100b001e9bc799fa6mr10560461oab.50.1699982158761; Tue, 14 Nov 2023 09:15:58 -0800 (PST) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id o4-20020a05687072c400b001e9a253afa3sm1429647oak.49.2023.11.14.09.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:15:58 -0800 (PST) From: Denis Kenzior To: iwd@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 11/11] netdev: disambiguate between disconnection types Date: Tue, 14 Nov 2023 11:14:34 -0600 Message-ID: <20231114171455.1108856-11-denkenz@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com> References: <20231114171455.1108856-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are generally three scenarios where iwd generates a disconnection command to the kernel: 1. Error conditions stemming from a connection related event. For example if SAE/FT/FILS authentication fails during Authenticate or Associate steps and the kernel doesn't disconnect properly. 2. Deauthentication after the connection has been established and not related to a connection attempt in progress. For example, SA Query processing that triggers an disconnect. 3. Disconnects that are triggered due to a handshake failure or if setting keys resulting from the handshake fails. These disconnects can be triggered as a result of a pending connection or when a connection has been established (e.g. due to rekeying). Distinguish between 1 and 2/3 by having the disconnect procedure take different paths. For now there are no functional changes since all paths end up in netdev_connect_failed(), but this will change in the future. --- src/netdev.c | 126 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 50 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 418626d72579..d0ce0aaad5e7 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -858,7 +858,7 @@ static void netdev_connect_failed(struct netdev *netdev, } } -static void netdev_disconnect_cb(struct l_genl_msg *msg, void *user_data) +static void netdev_connect_failed_cb(struct l_genl_msg *msg, void *user_data) { struct netdev *netdev = user_data; @@ -866,6 +866,63 @@ static void netdev_disconnect_cb(struct l_genl_msg *msg, void *user_data) netdev_connect_failed(netdev, netdev->result, netdev->last_code); } +static void netdev_send_and_fail_connection(struct netdev *netdev, + enum netdev_result result, + uint16_t status_code, + struct l_genl_msg *msg) +{ + netdev->result = result; + netdev->last_code = status_code; + + netdev->disconnect_cmd_id = + l_genl_family_send(nl80211, msg, netdev_connect_failed_cb, + netdev, NULL); +} + +static void netdev_disconnect_and_fail_connection(struct netdev *netdev, + enum netdev_result result, + uint16_t status_code) +{ + struct l_genl_msg *msg = nl80211_build_disconnect(netdev->index, + MMPDU_REASON_CODE_UNSPECIFIED); + + netdev_send_and_fail_connection(netdev, result, status_code, msg); +} + +static void netdev_deauth_and_fail_connection(struct netdev *netdev, + enum netdev_result result, + uint16_t status_code) +{ + struct l_genl_msg *msg = nl80211_build_deauthenticate(netdev->index, + netdev->handshake->aa, + MMPDU_REASON_CODE_UNSPECIFIED); + + netdev_send_and_fail_connection(netdev, result, status_code, msg); +} + +static void netdev_disconnect_sme_cb(struct l_genl_msg *msg, void *user_data) +{ + struct netdev *netdev = user_data; + + netdev->disconnect_cmd_id = 0; + netdev_connect_failed(netdev, netdev->result, netdev->last_code); +} + +static void netdev_disconnect_by_sme(struct netdev *netdev, + enum netdev_result result, + uint16_t reason_code) +{ + struct l_genl_msg *msg = nl80211_build_disconnect(netdev->index, + reason_code); + + netdev->result = result; + netdev->last_code = reason_code; + + netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, + netdev_disconnect_sme_cb, + netdev, NULL); +} + static void netdev_free(void *data) { struct netdev *netdev = data; @@ -1388,11 +1445,9 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs, return; } - msg = nl80211_build_disconnect(netdev->index, - MMPDU_REASON_CODE_UNSPECIFIED); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, - netdev_disconnect_cb, - netdev, NULL); + netdev_disconnect_by_sme(netdev, + NETDEV_RESULT_KEY_SETTING_FAILED, + MMPDU_REASON_CODE_UNSPECIFIED); break; case NL80211_IFTYPE_AP: if (err == -ENETDOWN) @@ -1407,7 +1462,6 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs, break; } - netdev->result = NETDEV_RESULT_KEY_SETTING_FAILED; handshake_event(&nhs->super, HANDSHAKE_EVENT_SETTING_KEYS_FAILED, &err); } @@ -2118,16 +2172,11 @@ void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code) netdev->sm = NULL; - netdev->result = NETDEV_RESULT_HANDSHAKE_FAILED; - netdev->last_code = reason_code; - switch (netdev->type) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_P2P_CLIENT: - msg = nl80211_build_disconnect(netdev->index, reason_code); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, - netdev_disconnect_cb, - netdev, NULL); + netdev_disconnect_by_sme(netdev, NETDEV_RESULT_HANDSHAKE_FAILED, + reason_code); break; case NL80211_IFTYPE_AP: case NL80211_IFTYPE_P2P_GO: @@ -2842,14 +2891,9 @@ error: return; deauth: - netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; - netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - msg = nl80211_build_disconnect(netdev->index, - MMPDU_REASON_CODE_UNSPECIFIED); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, - msg, - netdev_disconnect_cb, - netdev, NULL); + netdev_disconnect_and_fail_connection(netdev, + NETDEV_RESULT_ASSOCIATION_FAILED, + MMPDU_STATUS_CODE_UNSPECIFIED); } static struct l_genl_msg *netdev_build_cmd_associate_common( @@ -2890,19 +2934,12 @@ static void netdev_cmd_ft_reassociate_cb(struct l_genl_msg *msg, netdev->connect_cmd_id = 0; - if (l_genl_msg_get_error(msg) < 0) { - struct l_genl_msg *cmd_deauth; + if (l_genl_msg_get_error(msg) >= 0) + return; - netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; - netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - cmd_deauth = nl80211_build_deauthenticate(netdev->index, - netdev->handshake->aa, - MMPDU_REASON_CODE_UNSPECIFIED); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, - cmd_deauth, - netdev_disconnect_cb, - netdev, NULL); - } + netdev_deauth_and_fail_connection(netdev, + NETDEV_RESULT_ASSOCIATION_FAILED, + MMPDU_STATUS_CODE_UNSPECIFIED); } static bool kernel_will_retry_auth(uint16_t status_code, @@ -3027,17 +3064,9 @@ static void netdev_authenticate_event(struct l_genl_msg *msg, * to keep retrying, tell it to stop */ if (retry) { - struct l_genl_msg *cmd_deauth; - - netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; - netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - cmd_deauth = nl80211_build_deauthenticate(netdev->index, - netdev->handshake->aa, - MMPDU_REASON_CODE_UNSPECIFIED); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, - cmd_deauth, - netdev_disconnect_cb, - netdev, NULL); + netdev_deauth_and_fail_connection(netdev, + NETDEV_RESULT_ASSOCIATION_FAILED, + MMPDU_STATUS_CODE_UNSPECIFIED); return; } } @@ -4545,17 +4574,14 @@ static void netdev_sa_query_timeout(struct l_timeout *timeout, void *user_data) { struct netdev *netdev = user_data; - struct l_genl_msg *msg; l_info("SA Query timed out, connection is invalid. Disconnecting..."); l_timeout_remove(netdev->sa_query_timeout); netdev->sa_query_timeout = NULL; - msg = nl80211_build_disconnect(netdev->index, - MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID); - netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, - netdev_disconnect_cb, netdev, NULL); + netdev_disconnect_by_sme(netdev, NETDEV_RESULT_ABORTED, + MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID); } static void netdev_sa_query_req_cb(struct l_genl_msg *msg, void *user_data)