P2P: Address few issues seen with P2P SD
Suppose we have multiple peers and we have peers advertising SD capability, but no services registered for advertising. In this case, even if there are multiple broadcast queries set, we might end up sending only the lastly added broadcast query to the same device (since SD_INFO won't get set for the first broadcast query). Add support for multiple wildcard queries to be tracked to enable this type of use case. Some times it is seen that before advancing to next device in the list, the scan results come and update SD_SCHEDULE flag. This will result in sending the already sent query to the same device without giving chance to other devices. This issue again is seen with peer devices advertising SD capability without any services registered. Signed-off-by: Jithu Jance <jithu@broadcom.com>
This commit is contained in:
parent
e9a6f18385
commit
f667e031c9
4 changed files with 82 additions and 32 deletions
|
@ -733,9 +733,6 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
|
||||||
|
|
||||||
p2p_parse_free(&msg);
|
p2p_parse_free(&msg);
|
||||||
|
|
||||||
if (p2p_pending_sd_req(p2p, dev))
|
|
||||||
dev->flags |= P2P_DEV_SD_SCHEDULE;
|
|
||||||
|
|
||||||
if (dev->flags & P2P_DEV_REPORTED)
|
if (dev->flags & P2P_DEV_REPORTED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2406,6 +2403,7 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg)
|
||||||
|
|
||||||
p2p->go_timeout = 100;
|
p2p->go_timeout = 100;
|
||||||
p2p->client_timeout = 20;
|
p2p->client_timeout = 20;
|
||||||
|
p2p->num_p2p_sd_queries = 0;
|
||||||
|
|
||||||
p2p_dbg(p2p, "initialized");
|
p2p_dbg(p2p, "initialized");
|
||||||
p2p_channels_dump(p2p, "channels", &p2p->cfg->channels);
|
p2p_channels_dump(p2p, "channels", &p2p->cfg->channels);
|
||||||
|
@ -2641,12 +2639,15 @@ void p2p_continue_find(struct p2p_data *p2p)
|
||||||
struct p2p_device *dev;
|
struct p2p_device *dev;
|
||||||
p2p_set_state(p2p, P2P_SEARCH);
|
p2p_set_state(p2p, P2P_SEARCH);
|
||||||
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
||||||
if (dev->flags & P2P_DEV_SD_SCHEDULE) {
|
if (dev->sd_pending_bcast_queries == 0) {
|
||||||
|
/* Initialize with total number of registered broadcast
|
||||||
|
* SD queries. */
|
||||||
|
dev->sd_pending_bcast_queries = p2p->num_p2p_sd_queries;
|
||||||
|
}
|
||||||
|
|
||||||
if (p2p_start_sd(p2p, dev) == 0)
|
if (p2p_start_sd(p2p, dev) == 0)
|
||||||
return;
|
return;
|
||||||
else
|
if (dev->req_config_methods &&
|
||||||
break;
|
|
||||||
} else if (dev->req_config_methods &&
|
|
||||||
!(dev->flags & P2P_DEV_PD_FOR_JOIN)) {
|
!(dev->flags & P2P_DEV_PD_FOR_JOIN)) {
|
||||||
p2p_dbg(p2p, "Send pending Provision Discovery Request to "
|
p2p_dbg(p2p, "Send pending Provision Discovery Request to "
|
||||||
MACSTR " (config methods 0x%x)",
|
MACSTR " (config methods 0x%x)",
|
||||||
|
@ -2668,10 +2669,7 @@ static void p2p_sd_cb(struct p2p_data *p2p, int success)
|
||||||
p2p->pending_action_state = P2P_NO_PENDING_ACTION;
|
p2p->pending_action_state = P2P_NO_PENDING_ACTION;
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (p2p->sd_peer) {
|
|
||||||
p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
|
|
||||||
p2p->sd_peer = NULL;
|
p2p->sd_peer = NULL;
|
||||||
}
|
|
||||||
p2p_continue_find(p2p);
|
p2p_continue_find(p2p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3216,7 +3214,6 @@ static void p2p_timeout_sd_during_find(struct p2p_data *p2p)
|
||||||
p2p_dbg(p2p, "Service Discovery Query timeout");
|
p2p_dbg(p2p, "Service Discovery Query timeout");
|
||||||
if (p2p->sd_peer) {
|
if (p2p->sd_peer) {
|
||||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||||
p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
|
|
||||||
p2p->sd_peer = NULL;
|
p2p->sd_peer = NULL;
|
||||||
}
|
}
|
||||||
p2p_continue_find(p2p);
|
p2p_continue_find(p2p);
|
||||||
|
@ -3487,7 +3484,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
||||||
"country=%c%c\n"
|
"country=%c%c\n"
|
||||||
"oper_freq=%d\n"
|
"oper_freq=%d\n"
|
||||||
"req_config_methods=0x%x\n"
|
"req_config_methods=0x%x\n"
|
||||||
"flags=%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
|
"flags=%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
|
||||||
"status=%d\n"
|
"status=%d\n"
|
||||||
"wait_count=%u\n"
|
"wait_count=%u\n"
|
||||||
"invitation_reqs=%u\n",
|
"invitation_reqs=%u\n",
|
||||||
|
@ -3510,9 +3507,6 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
||||||
dev->flags & P2P_DEV_REPORTED ? "[REPORTED]" : "",
|
dev->flags & P2P_DEV_REPORTED ? "[REPORTED]" : "",
|
||||||
dev->flags & P2P_DEV_NOT_YET_READY ?
|
dev->flags & P2P_DEV_NOT_YET_READY ?
|
||||||
"[NOT_YET_READY]" : "",
|
"[NOT_YET_READY]" : "",
|
||||||
dev->flags & P2P_DEV_SD_INFO ? "[SD_INFO]" : "",
|
|
||||||
dev->flags & P2P_DEV_SD_SCHEDULE ? "[SD_SCHEDULE]" :
|
|
||||||
"",
|
|
||||||
dev->flags & P2P_DEV_PD_PEER_DISPLAY ?
|
dev->flags & P2P_DEV_PD_PEER_DISPLAY ?
|
||||||
"[PD_PEER_DISPLAY]" : "",
|
"[PD_PEER_DISPLAY]" : "",
|
||||||
dev->flags & P2P_DEV_PD_PEER_KEYPAD ?
|
dev->flags & P2P_DEV_PD_PEER_KEYPAD ?
|
||||||
|
|
|
@ -81,8 +81,6 @@ struct p2p_device {
|
||||||
#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
|
#define P2P_DEV_PROBE_REQ_ONLY BIT(0)
|
||||||
#define P2P_DEV_REPORTED BIT(1)
|
#define P2P_DEV_REPORTED BIT(1)
|
||||||
#define P2P_DEV_NOT_YET_READY BIT(2)
|
#define P2P_DEV_NOT_YET_READY BIT(2)
|
||||||
#define P2P_DEV_SD_INFO BIT(3)
|
|
||||||
#define P2P_DEV_SD_SCHEDULE BIT(4)
|
|
||||||
#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
|
#define P2P_DEV_PD_PEER_DISPLAY BIT(5)
|
||||||
#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
|
#define P2P_DEV_PD_PEER_KEYPAD BIT(6)
|
||||||
#define P2P_DEV_USER_REJECTED BIT(7)
|
#define P2P_DEV_USER_REJECTED BIT(7)
|
||||||
|
@ -110,6 +108,7 @@ struct p2p_device {
|
||||||
|
|
||||||
u8 go_timeout;
|
u8 go_timeout;
|
||||||
u8 client_timeout;
|
u8 client_timeout;
|
||||||
|
int sd_pending_bcast_queries;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct p2p_sd_query {
|
struct p2p_sd_query {
|
||||||
|
@ -256,6 +255,12 @@ struct p2p_data {
|
||||||
*/
|
*/
|
||||||
struct p2p_sd_query *sd_query;
|
struct p2p_sd_query *sd_query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* num_p2p_sd_queries - Total number of broadcast SD queries present in
|
||||||
|
* the list
|
||||||
|
*/
|
||||||
|
int num_p2p_sd_queries;
|
||||||
|
|
||||||
/* GO Negotiation data */
|
/* GO Negotiation data */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
|
||||||
{
|
{
|
||||||
struct p2p_sd_query *q;
|
struct p2p_sd_query *q;
|
||||||
int wsd = 0;
|
int wsd = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
if (!(dev->info.dev_capab & P2P_DEV_CAPAB_SERVICE_DISCOVERY))
|
if (!(dev->info.dev_capab & P2P_DEV_CAPAB_SERVICE_DISCOVERY))
|
||||||
return NULL; /* peer does not support SD */
|
return NULL; /* peer does not support SD */
|
||||||
|
@ -64,8 +65,19 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
|
||||||
/* Use WSD only if the peer indicates support or it */
|
/* Use WSD only if the peer indicates support or it */
|
||||||
if (q->wsd && !wsd)
|
if (q->wsd && !wsd)
|
||||||
continue;
|
continue;
|
||||||
if (q->for_all_peers && !(dev->flags & P2P_DEV_SD_INFO))
|
/* if the query is a broadcast query */
|
||||||
|
if (q->for_all_peers) {
|
||||||
|
/*
|
||||||
|
* check if there are any broadcast queries pending for
|
||||||
|
* this device
|
||||||
|
*/
|
||||||
|
if (dev->sd_pending_bcast_queries <= 0)
|
||||||
|
return NULL;
|
||||||
|
/* query number that needs to be send to the device */
|
||||||
|
if (count == dev->sd_pending_bcast_queries - 1)
|
||||||
return q;
|
return q;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
if (!q->for_all_peers &&
|
if (!q->for_all_peers &&
|
||||||
os_memcmp(q->peer, dev->info.p2p_device_addr, ETH_ALEN) ==
|
os_memcmp(q->peer, dev->info.p2p_device_addr, ETH_ALEN) ==
|
||||||
0)
|
0)
|
||||||
|
@ -76,14 +88,37 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void p2p_decrease_sd_bc_queries(struct p2p_data *p2p, int query_number)
|
||||||
|
{
|
||||||
|
struct p2p_device *dev;
|
||||||
|
|
||||||
|
p2p->num_p2p_sd_queries--;
|
||||||
|
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
||||||
|
if (query_number <= dev->sd_pending_bcast_queries - 1) {
|
||||||
|
/*
|
||||||
|
* Query not yet sent to the device and it is to be
|
||||||
|
* removed, so update the pending count.
|
||||||
|
*/
|
||||||
|
dev->sd_pending_bcast_queries--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int p2p_unlink_sd_query(struct p2p_data *p2p,
|
static int p2p_unlink_sd_query(struct p2p_data *p2p,
|
||||||
struct p2p_sd_query *query)
|
struct p2p_sd_query *query)
|
||||||
{
|
{
|
||||||
struct p2p_sd_query *q, *prev;
|
struct p2p_sd_query *q, *prev;
|
||||||
|
int query_number = 0;
|
||||||
|
|
||||||
q = p2p->sd_queries;
|
q = p2p->sd_queries;
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
while (q) {
|
while (q) {
|
||||||
if (q == query) {
|
if (q == query) {
|
||||||
|
/* If the query is a broadcast query, decrease one from
|
||||||
|
* all the devices */
|
||||||
|
if (query->for_all_peers)
|
||||||
|
p2p_decrease_sd_bc_queries(p2p, query_number);
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = q->next;
|
prev->next = q->next;
|
||||||
else
|
else
|
||||||
|
@ -92,6 +127,8 @@ static int p2p_unlink_sd_query(struct p2p_data *p2p,
|
||||||
p2p->sd_query = NULL;
|
p2p->sd_query = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (q->for_all_peers)
|
||||||
|
query_number++;
|
||||||
prev = q;
|
prev = q;
|
||||||
q = q->next;
|
q = q->next;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +155,7 @@ void p2p_free_sd_queries(struct p2p_data *p2p)
|
||||||
q = q->next;
|
q = q->next;
|
||||||
p2p_free_sd_query(prev);
|
p2p_free_sd_query(prev);
|
||||||
}
|
}
|
||||||
|
p2p->num_p2p_sd_queries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,6 +300,16 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the pending broadcast SD query count for this device */
|
||||||
|
dev->sd_pending_bcast_queries--;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are no pending broadcast queries for this device, mark it as
|
||||||
|
* done (-1).
|
||||||
|
*/
|
||||||
|
if (dev->sd_pending_bcast_queries == 0)
|
||||||
|
dev->sd_pending_bcast_queries = -1;
|
||||||
|
|
||||||
wpabuf_free(req);
|
wpabuf_free(req);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -541,8 +589,6 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
|
||||||
p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
|
p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
|
|
||||||
p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
|
|
||||||
p2p->sd_peer = NULL;
|
p2p->sd_peer = NULL;
|
||||||
|
|
||||||
if (p2p->sd_query) {
|
if (p2p->sd_query) {
|
||||||
|
@ -787,8 +833,6 @@ skip_nqp_header:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
|
|
||||||
p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
|
|
||||||
p2p->sd_peer = NULL;
|
p2p->sd_peer = NULL;
|
||||||
|
|
||||||
if (p2p->sd_query) {
|
if (p2p->sd_query) {
|
||||||
|
@ -841,8 +885,16 @@ void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
|
||||||
|
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
struct p2p_device *dev;
|
struct p2p_device *dev;
|
||||||
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list)
|
|
||||||
dev->flags &= ~P2P_DEV_SD_INFO;
|
p2p->num_p2p_sd_queries++;
|
||||||
|
|
||||||
|
/* Update all the devices for the newly added broadcast query */
|
||||||
|
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
||||||
|
if (dev->sd_pending_bcast_queries <= 0)
|
||||||
|
dev->sd_pending_bcast_queries = 1;
|
||||||
|
else
|
||||||
|
dev->sd_pending_bcast_queries++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return q;
|
return q;
|
||||||
|
|
|
@ -230,9 +230,8 @@ discovery protocols and requests this to be sent to all discovered
|
||||||
peers (note: this can result in long response frames). The pending
|
peers (note: this can result in long response frames). The pending
|
||||||
requests are sent during device discovery (see p2p_find).
|
requests are sent during device discovery (see p2p_find).
|
||||||
|
|
||||||
Only a single pending wildcard query is supported, but there can be
|
There can be multiple pending peer device specific queries (each will be
|
||||||
multiple pending peer device specific queries (each will be sent in
|
sent in sequence whenever the peer is found).
|
||||||
sequence whenever the peer is found).
|
|
||||||
|
|
||||||
This command returns an identifier for the pending query (e.g.,
|
This command returns an identifier for the pending query (e.g.,
|
||||||
"1f77628") that can be used to cancel the request. Directed requests
|
"1f77628") that can be used to cancel the request. Directed requests
|
||||||
|
|
Loading…
Reference in a new issue