public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support
@ 2024-10-11 14:55 James Prestwood
  2024-10-11 14:55 ` [PATCH 2/2] station: check if authentication is supported via CMD_FRAME James Prestwood
  2024-10-21 17:55 ` [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood
  0 siblings, 2 replies; 3+ messages in thread
From: James Prestwood @ 2024-10-11 14:55 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Drivers have been identified that do not support authentication via
CMD_FRAME. This prevents FT from succeeding but since there is no
way to check this in IWD station cannot handle it gracefully.

Now IWD can parse the TX/RX frame types and check if authentication
is supported and plan the type of roam according to what protocol
will work correctly.
---
 src/wiphy.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/wiphy.h |  1 +
 2 files changed, 55 insertions(+)

diff --git a/src/wiphy.c b/src/wiphy.c
index 06f72ef2..cc0e6dd7 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -150,6 +150,8 @@ struct wiphy {
 	bool ap_probe_resp_offload : 1;
 	bool supports_uapsd : 1;
 	bool supports_cmd_offchannel : 1;
+	/* Bit 0 for TX, Bit 1 for RX */
+	uint8_t supports_auth_frame : 2;
 };
 
 static struct l_queue *wiphy_list = NULL;
@@ -938,6 +940,11 @@ bool wiphy_supports_cmd_offchannel(const struct wiphy *wiphy)
 	return wiphy->supports_cmd_offchannel;
 }
 
+bool wiphy_supports_auth_frame(const struct wiphy *wiphy)
+{
+	return wiphy->supports_auth_frame == 0x03;
+}
+
 const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy,
 						enum band_freq band,
 						size_t *size)
@@ -1816,6 +1823,45 @@ static void parse_iftype_extended_capabilities(struct wiphy *wiphy,
 	}
 }
 
+static void wiphy_parse_frame_types(struct wiphy *wiphy,
+					struct l_genl_attr *attr, bool tx)
+{
+	uint16_t type, len;
+	const void *data;
+
+	while (l_genl_attr_next(attr, NULL, NULL, NULL)) {
+		struct l_genl_attr types;
+
+		if (!l_genl_attr_recurse(attr, &types))
+			continue;
+
+		while (l_genl_attr_next(&types, &type, &len, &data)) {
+			uint16_t frame_type;
+
+			if (L_WARN_ON(type != NL80211_ATTR_FRAME_TYPE))
+				continue;
+
+			if (L_WARN_ON(len != 2))
+				continue;
+
+			frame_type = l_get_le16(data);
+
+			switch (frame_type) {
+			/* Authentication */
+			case 0x00b0:
+				if (tx)
+					wiphy->supports_auth_frame |= 0x01;
+				else
+					wiphy->supports_auth_frame |= 0x02;
+				break;
+			default:
+				break;
+			}
+
+		}
+	}
+}
+
 static void wiphy_parse_attributes(struct wiphy *wiphy,
 					struct l_genl_msg *msg)
 {
@@ -1903,6 +1949,14 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
 		case NL80211_ATTR_SUPPORT_AP_UAPSD:
 			wiphy->supports_uapsd = true;
 			break;
+		case NL80211_ATTR_TX_FRAME_TYPES:
+			if (l_genl_attr_recurse(&attr, &nested))
+				wiphy_parse_frame_types(wiphy, &nested, true);
+			break;
+		case NL80211_ATTR_RX_FRAME_TYPES:
+			if (l_genl_attr_recurse(&attr, &nested))
+				wiphy_parse_frame_types(wiphy, &nested, false);
+			break;
 		}
 	}
 }
diff --git a/src/wiphy.h b/src/wiphy.h
index 17e53075..fe7e9e49 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -142,6 +142,7 @@ void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out);
 bool wiphy_country_is_unknown(struct wiphy *wiphy);
 bool wiphy_supports_uapsd(const struct wiphy *wiphy);
 bool wiphy_supports_cmd_offchannel(const struct wiphy *wiphy);
+bool wiphy_supports_auth_frame(const struct wiphy *wiphy);
 
 const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy,
 						enum band_freq band,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] station: check if authentication is supported via CMD_FRAME
  2024-10-11 14:55 [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood
@ 2024-10-11 14:55 ` James Prestwood
  2024-10-21 17:55 ` [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood
  1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2024-10-11 14:55 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

If the driver does not support this don't allow FT-over-Air as
CMD_FRAME will fail. This will downgrade the roam to reassociation.
In the future IWD could instead use CMD_AUTHENTICATE, but thats a
larger change. This will at least get these drivers functioning
better.
---
 src/station.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/station.c b/src/station.c
index 9ebed8e2..b7905c4f 100644
--- a/src/station.c
+++ b/src/station.c
@@ -2162,14 +2162,29 @@ static bool station_can_fast_transition(struct station *station,
 			return false;
 	}
 
-	/*
-	 * FT-over-Air in its current form relies on CMD_REMAIN_ON_CHANNEL. Some
-	 * drivers do not support this so only allow over-DS if this is the case
-	 */
-	if (!(hs->mde[4] & 1) &&
-			!wiphy_supports_cmd_offchannel(station->wiphy)) {
-		l_debug("FT-over-Air needs offchannel, using reassociation");
-		return false;
+	if (!(hs->mde[4] & 1)) {
+		/*
+		 * FT-over-Air in its current form relies on
+		 * CMD_REMAIN_ON_CHANNEL. Some drivers do not support this so
+		 * only allow over-DS if this is the case
+		 */
+		if (!wiphy_supports_cmd_offchannel(station->wiphy)) {
+			l_debug("FT-over-Air needs offchannel, using "
+				"reassociation");
+			return false;
+		}
+
+		/*
+		 * TODO: if drivers don't support TX/RX of auth frames via
+		 *       CMD_FRAME IWD could choose to use CMD_AUTHENTICATE
+		 *       instead. For now just avoid FT roaming and let these
+		 *       drivers roam via reassociation.
+		 */
+		if (!wiphy_supports_auth_frame(station->wiphy)) {
+			l_debug("FT-over-Air needs CMD_FRAME auth, using "
+				"reassociation");
+			return false;
+		}
 	}
 
 	return true;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support
  2024-10-11 14:55 [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood
  2024-10-11 14:55 ` [PATCH 2/2] station: check if authentication is supported via CMD_FRAME James Prestwood
@ 2024-10-21 17:55 ` James Prestwood
  1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2024-10-21 17:55 UTC (permalink / raw)
  To: iwd; +Cc: Dierk.Modrow

Hi Dierk,

On 10/11/24 7:55 AM, James Prestwood wrote:
> Drivers have been identified that do not support authentication via
> CMD_FRAME. This prevents FT from succeeding but since there is no
> way to check this in IWD station cannot handle it gracefully.
>
> Now IWD can parse the TX/RX frame types and check if authentication
> is supported and plan the type of roam according to what protocol
> will work correctly.
> ---
>   src/wiphy.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   src/wiphy.h |  1 +
>   2 files changed, 55 insertions(+)

Were you able to try these patches yet? I can't test them on the 
hardware you are using, so if possible we'd like a confirmation the fix 
worked as expected before they are merged upstream.

Thanks,

James


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-21 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 14:55 [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood
2024-10-11 14:55 ` [PATCH 2/2] station: check if authentication is supported via CMD_FRAME James Prestwood
2024-10-21 17:55 ` [PATCH 1/2] wiphy: parse TX/RX frame types, and API to check auth frame support James Prestwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox