public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 07/11] netdev: Move CMD_DEL_STATION builder to nl80211util
Date: Tue, 14 Nov 2023 11:14:30 -0600	[thread overview]
Message-ID: <20231114171455.1108856-7-denkenz@gmail.com> (raw)
In-Reply-To: <20231114171455.1108856-1-denkenz@gmail.com>

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,
-- 
2.42.0


  parent reply	other threads:[~2023-11-14 17:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 17:14 [PATCH 01/11] netdev: Fix obtaining reason code from deauth frames Denis Kenzior
2023-11-14 17:14 ` [PATCH 02/11] netdev: sa_query: Fix reason code handling Denis Kenzior
2023-11-14 17:14 ` [PATCH 03/11] netdev: Use CMD_DISCONNECT if OCI fails Denis Kenzior
2023-11-14 17:14 ` [PATCH 04/11] netdev: Don't unnecessarily call netdev_connect_failed Denis Kenzior
2023-11-14 17:14 ` [PATCH 05/11] netdev: Move CMD_DISCONNECT builder to nl80211util Denis Kenzior
2023-11-14 17:14 ` [PATCH 06/11] netdev: Move CMD_DEAUTHENTICATE " Denis Kenzior
2023-11-14 17:14 ` Denis Kenzior [this message]
2023-11-14 17:14 ` [PATCH 08/11] netdev: Move pairwise NEW_KEY " Denis Kenzior
2023-11-14 17:14 ` [PATCH 09/11] netdev: Move CMD_NEW_KEY RX-only " Denis Kenzior
2023-11-14 17:14 ` [PATCH 10/11] netdev: Move CMD_REKEY_OFFLOAD " Denis Kenzior
2023-11-14 17:14 ` [PATCH 11/11] netdev: disambiguate between disconnection types Denis Kenzior
2023-11-14 17:39   ` James Prestwood
2023-11-14 20:09     ` Denis Kenzior
2023-11-14 20:11       ` James Prestwood
2023-11-24 12:20   ` Alvin Šipraga
2023-11-24 16:25     ` Denis Kenzior
2023-11-25 20:57       ` Alvin Šipraga
2023-11-14 20:48 ` [PATCH 01/11] netdev: Fix obtaining reason code from deauth frames Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231114171455.1108856-7-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox