From 63a965c313a0e263ae8a4ef360c960de5ad60a91 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 23 Apr 2013 21:12:04 +0300 Subject: [PATCH] P2P: Fix after_scan_tx processing during ongoing operations When Action frame TX is postponed until a pending p2p_scan completes, there may be additional operations that need to be continued after the postponed Action frame TX operation completes. Fix this by starting pending operation (if any) from TX status event for after_scan_tx frames. This fixes common errors seen with the test_discovery hwsim test case. Signed-hostap: Jouni Malinen --- src/p2p/p2p.c | 17 +++++++++++++++-- src/p2p/p2p_i.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 4418bb32b..65f34120f 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -941,8 +941,7 @@ static int p2p_run_after_scan(struct p2p_data *p2p) enum p2p_after_scan op; if (p2p->after_scan_tx) { - /* TODO: schedule p2p_run_after_scan to be called from TX - * status callback(?) */ + p2p->after_scan_tx_in_progress = 1; wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send pending " "Action frame at p2p_scan completion"); p2p->cfg->send_action(p2p->cfg->cb_ctx, @@ -3050,6 +3049,18 @@ void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, p2p->pending_action_state = P2P_NO_PENDING_ACTION; switch (state) { case P2P_NO_PENDING_ACTION: + if (p2p->after_scan_tx_in_progress) { + p2p->after_scan_tx_in_progress = 0; + if (p2p->start_after_scan != P2P_AFTER_SCAN_NOTHING && + p2p_run_after_scan(p2p)) + break; + if (p2p->state == P2P_SEARCH) { + wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, + "P2P: Continue find after " + "after_scan_tx completion"); + p2p_continue_find(p2p); + } + } break; case P2P_PENDING_GO_NEG_REQUEST: p2p_go_neg_req_cb(p2p, success); @@ -3085,6 +3096,8 @@ void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, p2p_go_disc_req_cb(p2p, success); break; } + + p2p->after_scan_tx_in_progress = 0; } diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index dff226ada..c428c2027 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -385,6 +385,7 @@ struct p2p_data { } start_after_scan; u8 after_scan_peer[ETH_ALEN]; struct p2p_pending_action_tx *after_scan_tx; + unsigned int after_scan_tx_in_progress:1; /* Requested device types for find/search */ unsigned int num_req_dev_types;