P2P: Accept P2P SD response without TX status

If a GAS response is received for a pending SD query, process it even if
the TX status event for the query has not yet been received. It is
possible for the TX status and RX events to be reordered especially when
using UML time-travel, so this is needed to avoid race conditions to
make SD more robust.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2024-01-26 17:12:16 +02:00 committed by Jouni Malinen
parent 16a22ef340
commit 576f462504

View file

@ -489,12 +489,21 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
u16 slen;
u16 update_indic;
if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
if ((p2p->state != P2P_SD_DURING_FIND && p2p->state != P2P_SEARCH) ||
!p2p->sd_peer ||
!ether_addr_equal(sa, p2p->sd_peer->info.p2p_device_addr)) {
p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
MACSTR, MAC2STR(sa));
return;
}
if (p2p->state == P2P_SEARCH) {
/* It is possible for the TX status and RX response events to be
* reordered, so assume the request was ACKed if a response is
* received. */
p2p_dbg(p2p,
"GAS Initial Request had not yet received TX status - process the response anyway");
p2p_set_state(p2p, P2P_SD_DURING_FIND);
}
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
p2p_clear_timeout(p2p);