[PATCH v3 2/3] GAS: Retry a missed DPP comeback on the same dialog token
Gustavo Bertoli
gubertoli at gmail.com
Sun Nov 15 12:47:28 PST 2026
When a Comeback Request gets no response within 150 ms, gas_query
restarts the query with a new dialog token. For DPP Enterprise
provisioning, the Configurator then sees a second Configuration Request
and the certBag prepared for the first one is lost. Off-channel
responses are often delayed by seconds, so this is common.
For the DPP Configuration Request that carries a CSR, retry on the same
dialog token instead, and only after a 5 s listen without a response,
so that a retry cannot overtake a response still on its way. Every
other retry waits 2.5 s longer, plus up to 0.3 s at random, so that the
retries do not keep hitting the same short gap in the responder's
listen. Give up after 25 s without progress.
Signed-off-by: Gustavo Bertoli <gubertoli at gmail.com>
---
wpa_supplicant/dpp_supplicant.c | 3 ++
wpa_supplicant/gas_query.c | 79 +++++++++++++++++++++++++++++++++
wpa_supplicant/gas_query.h | 2 +
3 files changed, 84 insertions(+)
diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c
index 356dcc8aa..5be11f48b 100644
--- a/wpa_supplicant/dpp_supplicant.c
+++ b/wpa_supplicant/dpp_supplicant.c
@@ -2098,6 +2098,9 @@ static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s)
wpa_printf(MSG_DEBUG,
"DPP: GAS query started with dialog token %u", res);
wpa_s->dpp_gas_dialog_token = res;
+ if (auth->csr)
+ gas_query_set_comeback_recover(
+ wpa_s->gas, auth->peer_mac_addr, res);
}
}
diff --git a/wpa_supplicant/gas_query.c b/wpa_supplicant/gas_query.c
index 73cc34e0a..b6c759a84 100644
--- a/wpa_supplicant/gas_query.c
+++ b/wpa_supplicant/gas_query.c
@@ -32,6 +32,9 @@
#define GAS_QUERY_MAX_COMEBACK_DELAY 60000
+#define GAS_QUERY_WAIT_TIME_RECOVER 5000
+#define GAS_QUERY_RECOVER_TIMEOUT 25
+
/**
* struct gas_query_pending - Pending GAS query
*/
@@ -48,6 +51,9 @@ struct gas_query_pending {
unsigned int wildcard_bssid:1;
unsigned int maintain_addr:1;
unsigned int sent:1;
+ unsigned int comeback_recover:1;
+ unsigned int frag_rx:1;
+ unsigned int reask_late:1;
int freq;
u16 status_code;
struct wpabuf *req;
@@ -267,6 +273,10 @@ static void gas_query_tx_status(struct wpa_supplicant *wpa_s,
}
os_get_reltime(&query->last_oper);
+ /* A missed comeback is retried when the listen time ends */
+ if (query->comeback_recover && query->wait_comeback)
+ return;
+
if (result == OFFCHANNEL_SEND_ACTION_SUCCESS ||
result == OFFCHANNEL_SEND_ACTION_NO_ACK) {
eloop_cancel_timeout(gas_query_timeout, gas, query);
@@ -348,6 +358,35 @@ static void gas_query_tx_comeback_req(struct gas_query *gas,
return;
}
+ if (query->comeback_recover && query->wait_comeback) {
+ /* Ask again only after the listen time. Vary the delay to avoid
+ * staying in step with gaps in the peer's listen. */
+ unsigned int ms = GAS_QUERY_WAIT_TIME_RECOVER + 10;
+
+ if (query->reask_late)
+ ms += 2500;
+ ms += os_random() % 300;
+ query->reask_late = !query->reask_late;
+ eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
+ wait_time = GAS_QUERY_WAIT_TIME_RECOVER;
+ if (query->frag_rx) {
+ wait_time = GAS_QUERY_WAIT_TIME_COMEBACK;
+ } else if (query->offchannel_tx_started) {
+ offchannel_send_action_done(gas->wpa_s);
+ query->offchannel_tx_started = 0;
+ }
+ query->frag_rx = 0;
+ if (gas_query_tx(gas, query, req, wait_time) < 0)
+ wpa_printf(MSG_DEBUG,
+ "GAS: Failed to send Comeback Request to "
+ MACSTR, MAC2STR(query->addr));
+ eloop_register_timeout(ms / 1000, (ms % 1000) * 1000,
+ gas_query_tx_comeback_timeout,
+ gas, query);
+ wpabuf_free(req);
+ return;
+ }
+
wait_time = (query->retry || !query->offchannel_tx_started) ?
GAS_QUERY_WAIT_TIME_INITIAL : GAS_QUERY_WAIT_TIME_COMEBACK;
@@ -401,6 +440,17 @@ static void gas_query_tx_comeback_timeout(void *eloop_data, void *user_ctx)
}
+static void gas_query_recover_watchdog(struct gas_query *gas,
+ struct gas_query_pending *query,
+ unsigned int secs, unsigned int usecs)
+{
+ query->reask_late = 0;
+ eloop_cancel_timeout(gas_query_timeout, gas, query);
+ eloop_register_timeout(secs + GAS_QUERY_RECOVER_TIMEOUT, usecs,
+ gas_query_timeout, gas, query);
+}
+
+
static void gas_query_tx_comeback_req_delay(struct gas_query *gas,
struct gas_query_pending *query,
u16 comeback_delay)
@@ -419,6 +469,8 @@ static void gas_query_tx_comeback_req_delay(struct gas_query *gas,
eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
eloop_register_timeout(secs, usecs, gas_query_tx_comeback_timeout,
gas, query);
+ if (query->comeback_recover)
+ gas_query_recover_watchdog(gas, query, secs, usecs);
}
@@ -501,6 +553,8 @@ static void gas_query_rx_comeback(struct gas_query *gas,
return;
}
query->next_frag_id++;
+ if (query->comeback_recover)
+ gas_query_recover_watchdog(gas, query, 0, 0);
if (gas_query_append(query, resp, len) < 0) {
gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
@@ -508,6 +562,7 @@ static void gas_query_rx_comeback(struct gas_query *gas,
}
if (more_frags) {
+ query->frag_rx = query->comeback_recover;
gas_query_tx_comeback_req(gas, query);
return;
}
@@ -921,6 +976,30 @@ int gas_query_req(struct gas_query *gas, const u8 *dst, int freq,
}
+/**
+ * gas_query_set_comeback_recover - Retry comebacks on the same dialog token
+ * @gas: GAS query data from gas_query_init()
+ * @dst: Destination MAC address of the pending query
+ * @dialog_token: Dialog token returned by gas_query_req()
+ * Returns: 0 on success, -1 if no such query is pending
+ */
+int gas_query_set_comeback_recover(struct gas_query *gas, const u8 *dst,
+ u8 dialog_token)
+{
+ struct gas_query_pending *query;
+
+ dl_list_for_each(query, &gas->pending, struct gas_query_pending, list) {
+ if (query->dialog_token == dialog_token &&
+ ether_addr_equal(query->addr, dst)) {
+ query->comeback_recover = 1;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+
int gas_query_stop(struct gas_query *gas, u8 dialog_token)
{
struct gas_query_pending *query;
diff --git a/wpa_supplicant/gas_query.h b/wpa_supplicant/gas_query.h
index 6ccecd4dd..86fe2031a 100644
--- a/wpa_supplicant/gas_query.h
+++ b/wpa_supplicant/gas_query.h
@@ -41,6 +41,8 @@ int gas_query_req(struct gas_query *gas, const u8 *dst, int freq,
const struct wpabuf *resp, u16 status_code),
void *ctx);
int gas_query_stop(struct gas_query *gas, u8 dialog_token);
+int gas_query_set_comeback_recover(struct gas_query *gas, const u8 *dst,
+ u8 dialog_token);
#else /* CONFIG_GAS */
--
2.43.0
More information about the Hostap
mailing list