]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Accept P2P SD response without TX status
authorJouni Malinen <quic_jouni@quicinc.com>
Fri, 26 Jan 2024 15:12:16 +0000 (17:12 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 26 Jan 2024 15:12:16 +0000 (17:12 +0200)
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>
src/p2p/p2p_sd.c

index 050b6fd88fd7584aca2633920d2419ab3d73e813..d6882e4a324101d7d53cfbbac92a142d607966f6 100644 (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);