From d9d5e55c5484b7a206efb7958b5b3ed72ef8a47a Mon Sep 17 00:00:00 2001 From: Michal Kazior Date: Wed, 3 Mar 2021 09:53:33 +0000 Subject: [PATCH] DPP: Respond to GAS on the same channel it was received on When I was testing dpp_auth_init on an AP with Enrollee on a different channel from the AP I was getting failures. This happened on hwsim in UML with time-travel for me. I don't recall seeing this with real devices, presumably because of lax offchan implementation. The DPP authentication would succeed. However the station would then try to get configuration through a GAS request and fail. The AP reported the following logs (grepped): > 1614762426.860212: RX_ACTION category 4 action 10 sa 02:00:00:00:01:00 da 02:00:00:00:00:00 len 227 freq 2412 > 1614762426.860212: wlan0: GAS: GAS Initial Request from 02:00:00:00:01:00 (dialog token 239) > 1614762426.860233: DPP: Wait for Configuration Result > 1614762426.860234: nl80211: Send Action frame (ifindex=5, freq=2462 MHz wait=0 ms no_cck=0 offchanok=0) > 1614762428.861186: DPP: Timeout while waiting for Configuration Result > 1614762428.861186: wlan0: DPP-CONF-FAILED While the STA reported the following logs (grepped): > 1614762426.860193: wlan1: DPP-AUTH-SUCCESS init=0 > 1614762426.860195: DPP: Stop listen on 2412 MHz > 1614762426.860202: wlan1: GAS-QUERY-START addr=02:00:00:00:00:00 dialog_token=239 freq=2412 > 1614762428.861185: GAS: No response received for query to 02:00:00:00:00:00 dialog token 239 > 1614762428.861189: DPP: GAS query did not succeed > 1614762428.861189: wlan1: DPP-CONF-FAILED AP would still receive the GAS request on ch1 but would then try to respond on ch11 while STA was waiting on ch1. Signed-off-by: Michal Kazior --- src/ap/dpp_hostapd.c | 2 +- src/ap/gas_serv.c | 11 ++++++----- src/ap/gas_serv.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index 3c515f268..70dd18e25 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -3376,7 +3376,7 @@ static void hostapd_dpp_relay_gas_resp_tx(void *ctx, const u8 *addr, { struct hostapd_data *hapd = ctx; - gas_serv_req_dpp_processing(hapd, addr, dialog_token, prot, buf); + gas_serv_req_dpp_processing(hapd, addr, dialog_token, prot, buf, 0); } #endif /* CONFIG_DPP2 */ diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c index 90f15778b..4642e4927 100644 --- a/src/ap/gas_serv.c +++ b/src/ap/gas_serv.c @@ -1524,7 +1524,7 @@ static void gas_serv_req_local_processing(struct hostapd_data *hapd, #ifdef CONFIG_DPP void gas_serv_req_dpp_processing(struct hostapd_data *hapd, const u8 *sa, u8 dialog_token, - int prot, struct wpabuf *buf) + int prot, struct wpabuf *buf, int freq) { struct wpabuf *tx_buf; @@ -1582,7 +1582,7 @@ void gas_serv_req_dpp_processing(struct hostapd_data *hapd, return; if (prot) convert_to_protected_dual(tx_buf); - hostapd_drv_send_action(hapd, hapd->iface->freq, 0, sa, + hostapd_drv_send_action(hapd, freq ? freq : hapd->iface->freq, 0, sa, wpabuf_head(tx_buf), wpabuf_len(tx_buf)); wpabuf_free(tx_buf); @@ -1593,7 +1593,7 @@ void gas_serv_req_dpp_processing(struct hostapd_data *hapd, static void gas_serv_rx_gas_initial_req(struct hostapd_data *hapd, const u8 *sa, const u8 *data, size_t len, int prot, - int std_addr3) + int std_addr3, int freq) { const u8 *pos = data; const u8 *end = data + len; @@ -1688,7 +1688,8 @@ static void gas_serv_rx_gas_initial_req(struct hostapd_data *hapd, data, len); if (!msg) return; - gas_serv_req_dpp_processing(hapd, sa, dialog_token, prot, msg); + gas_serv_req_dpp_processing(hapd, sa, dialog_token, prot, msg, + freq); return; } #endif /* CONFIG_DPP */ @@ -1871,7 +1872,7 @@ static void gas_serv_rx_public_action(void *ctx, const u8 *buf, size_t len, switch (data[0]) { case WLAN_PA_GAS_INITIAL_REQ: gas_serv_rx_gas_initial_req(hapd, sa, data + 1, len - 1, prot, - std_addr3); + std_addr3, freq); break; case WLAN_PA_GAS_COMEBACK_REQ: gas_serv_rx_gas_comeback_req(hapd, sa, data + 1, len - 1, prot, diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h index 1528af4af..7646a98a4 100644 --- a/src/ap/gas_serv.h +++ b/src/ap/gas_serv.h @@ -90,6 +90,6 @@ void gas_serv_deinit(struct hostapd_data *hapd); void gas_serv_req_dpp_processing(struct hostapd_data *hapd, const u8 *sa, u8 dialog_token, - int prot, struct wpabuf *buf); + int prot, struct wpabuf *buf, int freq); #endif /* GAS_SERV_H */