From patchwork Tue Feb 4 09:09:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Jance X-Patchwork-Id: 316500 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8C2F12C007C for ; Tue, 4 Feb 2014 20:09:20 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 78DA39D260; Tue, 4 Feb 2014 04:09:16 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YA-4-iXHHvhv; Tue, 4 Feb 2014 04:09:16 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 480CF9D213; Tue, 4 Feb 2014 04:09:11 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B340C9D213 for ; Tue, 4 Feb 2014 04:09:09 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 70272RymWER9 for ; Tue, 4 Feb 2014 04:09:04 -0500 (EST) Received: from mail-gw3-out.broadcom.com (mail-gw3-out.broadcom.com [216.31.210.64]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 57CAC9C1C1 for ; Tue, 4 Feb 2014 04:09:04 -0500 (EST) X-IronPort-AV: E=Sophos;i="4.95,778,1384329600"; d="scan'208";a="12602286" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw3-out.broadcom.com with ESMTP; 04 Feb 2014 01:17:36 -0800 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 4 Feb 2014 01:09:03 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Tue, 4 Feb 2014 01:09:03 -0800 Received: from jithu?broadcom.com (lbblr-jithu01.ban.broadcom.com [10.132.24.37]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 6385D246A6 for ; Tue, 4 Feb 2014 01:09:02 -0800 (PST) Date: Tue, 4 Feb 2014 14:39:00 +0530 From: Jithu Jance To: Subject: [PATCH 1/2] P2P: Addressing few issues seen with Broadcast SD Message-ID: <137202264661b954a4fa6ffea014c5182616aa68.1391502949.git.jithu@broadcom.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 1) Suppose we have multiple peers and we have peers advertising SD capability, but no services registered for adverstising. In this case, even if there are mutliple broadcast queries set, we might end up sending only the lastly added Broadcast to the same device (Since SD_INFO won't get set for the first broadcast) 2) Some times it is seen that before advancing to next device in the list, the scan results come and updates 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-hostap: Jithu Jance --- src/p2p/p2p.c | 19 +++++++++---------- src/p2p/p2p_i.h | 6 ++++++ src/p2p/p2p_sd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 14 deletions(-) -- 1.7.9.5 diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 8aabfc0..9b22e22 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -732,9 +732,6 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, p2p_parse_free(&msg); - if (p2p_pending_sd_req(p2p, dev)) - dev->flags |= P2P_DEV_SD_SCHEDULE; - if (dev->flags & P2P_DEV_REPORTED) return 0; @@ -2384,6 +2381,7 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg) p2p->go_timeout = 100; p2p->client_timeout = 20; + p2p->num_p2p_sd_queries = 0; p2p_dbg(p2p, "initialized"); p2p_channels_dump(p2p, "channels", &p2p->cfg->channels); @@ -2618,13 +2616,18 @@ void p2p_continue_find(struct p2p_data *p2p) struct p2p_device *dev; p2p_set_state(p2p, P2P_SEARCH); 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 BCAST Queries*/ + dev->sd_pending_bcast_queries = p2p->num_p2p_sd_queries; + } + + if (dev->sd_pending_bcast_queries > 0) { if (p2p_start_sd(p2p, dev) == 0) return; else 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 " MACSTR " (config methods 0x%x)", MAC2STR(dev->info.p2p_device_addr), @@ -2646,7 +2649,6 @@ static void p2p_sd_cb(struct p2p_data *p2p, int success) if (!success) { if (p2p->sd_peer) { - p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE; p2p->sd_peer = NULL; } p2p_continue_find(p2p); @@ -3457,7 +3459,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info, "country=%c%c\n" "oper_freq=%d\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" "wait_count=%u\n" "invitation_reqs=%u\n", @@ -3480,9 +3482,6 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info, dev->flags & P2P_DEV_REPORTED ? "[REPORTED]" : "", dev->flags & P2P_DEV_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 ? "[PD_PEER_DISPLAY]" : "", dev->flags & P2P_DEV_PD_PEER_KEYPAD ? diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 3e105eb..926fdd9 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -105,6 +105,7 @@ struct p2p_device { u8 go_timeout; u8 client_timeout; + int sd_pending_bcast_queries; }; struct p2p_sd_query { @@ -250,6 +251,11 @@ struct p2p_data { */ struct p2p_sd_query *sd_query; + /** + * total number of sd broadcast queries present in the list + */ + int num_p2p_sd_queries; + /* GO Negotiation data */ /** diff --git a/src/p2p/p2p_sd.c b/src/p2p/p2p_sd.c index 0e0c7f1..6dd10e8 100644 --- a/src/p2p/p2p_sd.c +++ b/src/p2p/p2p_sd.c @@ -52,6 +52,7 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p, { struct p2p_sd_query *q; int wsd = 0; + int count = 0; if (!(dev->info.dev_capab & P2P_DEV_CAPAB_SERVICE_DISCOVERY)) return NULL; /* peer does not support SD */ @@ -64,8 +65,17 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p, /* Use WSD only if the peer indicates support or it */ if (q->wsd && !wsd) continue; - if (q->for_all_peers && !(dev->flags & P2P_DEV_SD_INFO)) - return q; + /* 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 */ + else if (count == (dev->sd_pending_bcast_queries - 1)) { + return q; + } else + count++; + } if (!q->for_all_peers && os_memcmp(q->peer, dev->info.p2p_device_addr, ETH_ALEN) == 0) @@ -80,10 +90,25 @@ static int p2p_unlink_sd_query(struct p2p_data *p2p, struct p2p_sd_query *query) { struct p2p_sd_query *q, *prev; + struct p2p_device *dev; + int query_number = 0; q = p2p->sd_queries; prev = NULL; while (q) { if (q == query) { + /* if the query is a broadcast query decrease one from all the devices */ + if (query->for_all_peers) { + 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 send to the device and is to be removed. + * So update the pending count. + */ + dev->sd_pending_bcast_queries--; + } + } + } if (prev) prev->next = q->next; else @@ -92,6 +117,8 @@ static int p2p_unlink_sd_query(struct p2p_data *p2p, p2p->sd_query = NULL; return 1; } + if (q->for_all_peers) + query_number++; prev = q; q = q->next; } @@ -262,6 +289,16 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev) ret = -1; } + /* Update the pending Bcast sd query count for this device */ + dev->sd_pending_bcast_queries--; + + /* + * If there are no pending bcast query for this device, + * mark it as done (-1). + */ + if (dev->sd_pending_bcast_queries == 0) + dev->sd_pending_bcast_queries = -1; + wpabuf_free(req); return ret; @@ -841,8 +878,15 @@ void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, if (dst == NULL) { 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 bcast 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;