From patchwork Mon May 19 12:34:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Jance X-Patchwork-Id: 350233 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 9968D14008A for ; Mon, 19 May 2014 22:34:54 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D6EF99D281; Mon, 19 May 2014 08:34:50 -0400 (EDT) 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 aUJxWbh5ne5Q; Mon, 19 May 2014 08:34:50 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C31E59D270; Mon, 19 May 2014 08:34:44 -0400 (EDT) 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 86DD39D270 for ; Mon, 19 May 2014 08:34:43 -0400 (EDT) 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 4WfiArdygEW7 for ; Mon, 19 May 2014 08:34:38 -0400 (EDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 5D7EF9CEB9 for ; Mon, 19 May 2014 08:34:37 -0400 (EDT) Received: by mail-la0-f50.google.com with SMTP id b8so4045636lan.9 for ; Mon, 19 May 2014 05:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=SA0BDFvCH5Aa3iXvVNmsvvucqYcXzTzbaNjTuKs1zaw=; b=gN3f+GIPd41C3WuTOb0uQs+nhiuyxujev0lVnFVIVTqYWyUb56u9/R3NbSbvVZ0fpo 2dDa0TkVdVfAlpdY9N++aehkH4945nlq1HXb18KmhgYMlvevr1znE16VQBqUADXSnFEU 9EYS4eGkzCSgHrVhaq/KklbgRribm3N1xOntYbWdYYDyE9VbkD4u/g7CJLQ3axFS7+EV +03xETA1lO1qcT5AFxaeuTnpsDRTz7mcr+TFIcCG9I1OX4QY2KX4b5o99DVuW9vM9iPx lpjfYnHL2/UXfENzZDPsZzOA+DKX3RQakA52WAwUVruZ49j66JA1sM4intJZ7rdWjQgG kmGQ== X-Received: by 10.152.4.39 with SMTP id h7mr26646026lah.12.1400502875561; Mon, 19 May 2014 05:34:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.96.195 with HTTP; Mon, 19 May 2014 05:34:15 -0700 (PDT) In-Reply-To: <20140511194928.GA6487@w1.fi> References: <20140511194928.GA6487@w1.fi> From: Jithu Jance Date: Mon, 19 May 2014 18:04:15 +0530 Message-ID: Subject: Re: [PATCH 1/1] P2P: Avoid resetting pending_listen_freq, if p2p_listen is pending To: "hostap@lists.shmoo.com" 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 Hi Jouni, >This seems to be causing failures in hwsim test cases. I'm not >completely sure why, but the logs seems to imply that this case is hit >and the P2P state machine is then stuck in waiting for something that >never happens. It looks like this can happen at least when P2P_LISTEN is >issued while a p2p_scan from a previously started P2P_FIND is in >progress. I ran hwsim and fixed a case where the listen was getting stuck (the p2p_find case that you mentioned). Please find the revised patch below. But when I run the hwsim there were other failures which seems to occur with or without this patch. I couldn't figure out the cause of the failure as the group formation seems to succeed, but the result shows as failed. :( Signed-off-by: Jithu Jance --- src/p2p/p2p.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) p2p_dbg(p2p, "Unknown regulatory class/channel"); @@ -260,14 +266,14 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc) return; } - p2p->pending_listen_freq = freq; - p2p->pending_listen_sec = 0; - p2p->pending_listen_usec = 1024 * tu; - ies = p2p_build_probe_resp_ies(p2p); if (ies == NULL) return; + p2p->pending_listen_freq = freq; + p2p->pending_listen_sec = 0; + p2p->pending_listen_usec = 1024 * tu; + if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000, ies) < 0) { p2p_dbg(p2p, "Failed to start listen mode"); @@ -284,16 +290,18 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout) p2p_dbg(p2p, "Going to listen(only) state"); + if (p2p->pending_listen_freq) { + /* We have a pending p2p_listen request */ + p2p_dbg(p2p, "p2p_listen command pending already"); + return -1; + } + freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); if (freq < 0) { p2p_dbg(p2p, "Unknown regulatory class/channel"); return -1; } - p2p->pending_listen_freq = freq; - p2p->pending_listen_sec = timeout / 1000; - p2p->pending_listen_usec = (timeout % 1000) * 1000; - if (p2p->p2p_scan_running) { if (p2p->start_after_scan == P2P_AFTER_SCAN_CONNECT) { p2p_dbg(p2p, "p2p_scan running - connect is already pending - skip listen"); @@ -308,6 +316,10 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout) if (ies == NULL) return -1; + p2p->pending_listen_freq = freq; + p2p->pending_listen_sec = timeout / 1000; + p2p->pending_listen_usec = (timeout % 1000) * 1000; + if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) { p2p_dbg(p2p, "Failed to start listen mode"); p2p->pending_listen_freq = 0; -- 1.7.9.5 *> Jithu Jance* On Mon, May 12, 2014 at 1:19 AM, Jouni Malinen wrote: > On Wed, May 07, 2014 at 02:02:06PM +0530, Jithu Jance wrote: > > If p2p_listen is called while previous listen command's > > remain_on_channel event is pending, the p2p_listen would fail > > and it used to clear pending_listen_freq. Now when the remain- > > on-channel event comes from the driver, the pending_listen_freq > > doesn't match and gets ignored. This was leading to a case > > where listen state was getting stuck (in case of WAIT_PEER_CONNECT > > state). > > > diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c > > @@ -284,6 +284,12 @@ int p2p_listen(struct p2p_data *p2p, unsigned int > timeout) > > p2p_dbg(p2p, "Going to listen(only) state"); > > > > + if (p2p->pending_listen_freq) { > > + /* We have a pending p2p_listen request */ > > + p2p_dbg(p2p, "p2p_listen command pending already"); > > + return -1; > > + } > > This seems to be causing failures in hwsim test cases. I'm not > completely sure why, but the logs seems to imply that this case is hit > and the P2P state machine is then stuck in waiting for something that > never happens. It looks like this can happen at least when P2P_LISTEN is > issued while a p2p_scan from a previously started P2P_FIND is in > progress. > > -- > Jouni Malinen PGP id EFC895FA > _______________________________________________ > HostAP mailing list > HostAP@lists.shmoo.com > http://lists.shmoo.com/mailman/listinfo/hostap > diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index c2f8d9b..7b2d43b 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -238,6 +238,12 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc) p2p_dbg(p2p, "Starting short listen state (state=%s)", p2p_state_txt(p2p->state)); + if (p2p->pending_listen_freq) { + /* We have a pending p2p_listen request */ + p2p_dbg(p2p, "p2p_listen command pending already"); + return; + } + freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); if (freq < 0) {