Skip to contentSkip to conversation

wiphy: add wiphy_supports_probe_resp_offload

PATCH In review James Prestwood 2 participants 3 messages Sep 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wiphy: add wiphy_supports_probe_resp_offload

Parse the AP probe response offload attribute during the dump. If set this indicates the driver expects the probe response attribute to be included with START_AP.

---
 src/wiphy.c | 9 +++++++++
 src/wiphy.h | 1 +
 2 files changed, 10 insertions(+)
src/wiphy.c +9 -0
index 28d4b66e..6fdd3df5 100644
@@ -138,6 +138,7 @@ struct wiphy {
 	bool blacklisted : 1;
 	bool registered : 1;
 	bool self_managed : 1;
+	bool ap_probe_resp_offload : 1;
 };
 
 static struct l_queue *wiphy_list = NULL;
@@ -473,6 +474,11 @@ const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy)
 	return wiphy->disabled_freqs;
 }
 
+bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy)
+{
+	return wiphy->ap_probe_resp_offload;
+}
+
 bool wiphy_can_transition_disable(struct wiphy *wiphy)
 {
 	/*
@@ -1644,6 +1650,9 @@ static void wiphy_parse_attributes(struct wiphy *wiphy,
 		case NL80211_ATTR_WIPHY_SELF_MANAGED_REG:
 			wiphy->self_managed = true;
 			break;
+		case NL80211_ATTR_PROBE_RESP_OFFLOAD:
+			wiphy->ap_probe_resp_offload = true;
+			break;
 		}
 	}
 }
src/wiphy.h +1 -0
index 9cd18451..2c6bf86b 100644
@@ -97,6 +97,7 @@ uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy);
+bool wiphy_supports_probe_resp_offload(struct wiphy *wiphy);
 bool wiphy_can_transition_disable(struct wiphy *wiphy);
 bool wiphy_can_offload(struct wiphy *wiphy);
 bool wiphy_supports_cmds_auth_assoc(struct wiphy *wiphy);
Signature · 1 line
2.34.3
#1 lore raw

PATCH 2/2 ap: include PROBE_RESP attribute if required by driver

Certain drivers support/require probe response offloading which IWD did not check for or properly handle. If probe response offloading is required the probe response frame watch will not be added and instead the ATTR_PROBE_RESP will be included with START_AP.

The head/tail builders were reused but slightly modified to check if the probe request frame is NULL, since it will be for use with START_AP.

---
 src/ap.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
src/ap.c +22 -3
index 8681189b..7140e823 100644
@@ -699,7 +699,7 @@ static size_t ap_write_wsc_ie(struct ap_state *ap,
 	size_t len = 0;
 
 	/* WSC IE */
-	if (type == MPDU_MANAGEMENT_SUBTYPE_PROBE_RESPONSE) {
+	if (type == MPDU_MANAGEMENT_SUBTYPE_PROBE_RESPONSE && client_frame) {
 		const uint8_t *from = client_frame->address_2;
 		struct wsc_probe_response wsc_pr = {};
 		const struct mmpdu_probe_request *req =
@@ -2416,6 +2416,8 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap)
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 	};
 
+	static const uint8_t zero_addr[6] = { 0 };
+
 	for (i = 0, nl_ciphers_cnt = 0; i < 8; i++)
 		if (ap->ciphers & (1 << i))
 			nl_ciphers[nl_ciphers_cnt++] =
@@ -2458,6 +2460,21 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap)
 	l_genl_msg_append_attr(cmd, NL80211_ATTR_WIPHY_FREQ, 4, &ch_freq);
 	l_genl_msg_append_attr(cmd, NL80211_ATTR_CHANNEL_WIDTH, 4, &ch_width);
 
+	if (wiphy_supports_probe_resp_offload(wiphy)) {
+		uint8_t probe_resp[head_len + tail_len];
+		uint8_t *ptr = probe_resp;
+
+		ptr += ap_build_beacon_pr_head(ap,
+					MPDU_MANAGEMENT_SUBTYPE_PROBE_RESPONSE,
+					zero_addr, ptr, sizeof(probe_resp));
+		ptr += ap_build_beacon_pr_tail(ap,
+					MPDU_MANAGEMENT_SUBTYPE_PROBE_RESPONSE,
+					NULL, 0, ptr);
+
+		l_genl_msg_append_attr(cmd, NL80211_ATTR_PROBE_RESP,
+					ptr - probe_resp, probe_resp);
+	}
+
 	if (wiphy_has_ext_feature(wiphy,
 			NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211)) {
 		l_genl_msg_append_attr(cmd, NL80211_ATTR_SOCKET_OWNER, 0, NULL);
@@ -3321,10 +3338,12 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
 			NULL, 0, ap_reassoc_req_cb, ap, NULL))
 		goto error;
 
-	if (!frame_watch_add(wdev_id, 0, 0x0000 |
+	if (!wiphy_supports_probe_resp_offload(wiphy)) {
+		if (!frame_watch_add(wdev_id, 0, 0x0000 |
 				(MPDU_MANAGEMENT_SUBTYPE_PROBE_REQUEST << 4),
 				NULL, 0, ap_probe_req_cb, ap, NULL))
-		goto error;
+			goto error;
+	}
 
 	if (!frame_watch_add(wdev_id, 0, 0x0000 |
 				(MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION << 4),
Signature · 1 line
2.34.3
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 8 lines · James Prestwood

Parse the AP probe response offload attribute during the dump. If set this indicates the driver expects the probe response attribute to be included with START_AP.

---
  src/wiphy.c | 9 +++++++++
  src/wiphy.h | 1 +
  2 files changed, 10 insertions(+)

Both applied, thanks.

Regards,
-Denis