From patchwork Tue Jan 9 14:16:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Sivertsson X-Patchwork-Id: 857540 X-Patchwork-Delegate: jow@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p+3Qx2Ps"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CTNV6Lry"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zGDkg5pTxz9s75 for ; Wed, 10 Jan 2018 01:18:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P5CNPA7SR/GP9lW2STxlDA8ug7JnCxCETtfu4lf7V5c=; b=p+3Qx2PsZ6eIp3 kZmnExSGOb2W4iijEcjWu0q13jyb7zyhgKYHjJFvj4bZkG75Xh5Ec9oBI8fbRNAwRyxIgCipvWxRk jS9XQeVbiAHRdgj+MwfaxDCioLR1ihtul+7k3UlGPOAAjSbq7CKG8nnnrGhp5RnmOehoMDNTv0X+1 mgwUDyg1+pRexPgr8s6EpMFbpr+gZ5ub9ymYH+razOFPPGzAHev4T2LvAux0uLE2WeeQyCeP6UFO3 R02lmG8yDDJK5uHiCo1aS7kpx+Z/W77ZJdI9DAoF12w6Dg5e+PRua0b9DE6UxCsKtayqL8xVE7kYZ cG3OSpy4GyHLpGS31o7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYuj2-0002KD-17; Tue, 09 Jan 2018 14:18:00 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYuiy-0002Ir-LQ for lede-dev@lists.infradead.org; Tue, 09 Jan 2018 14:17:58 +0000 Received: by mail-lf0-x241.google.com with SMTP id f3so16116196lfe.4 for ; Tue, 09 Jan 2018 06:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aRMyftJ0XM+xd8lyhkdTwsVMGajD6E5wzd9ozBH90+0=; b=CTNV6LrykRbE6MiN5+i8vDoSyHBdp62P7WD17/AExlghry1pTMhCnE0P/9p475/BNc +JRJSk8Z/L5bVxN7tw7rbUjGd46itq9ZnHqTWazQHcA5B/IxWRw8JYk2jgCxBCYd8Hv2 xQXyo5XNexFpZXm+g8K367rckqsMUPmy/J+liTtEKw/TSTxxQZI0VtY4U3T/xUhN8HFS PdRacDXQkhIUNdava9s8c+ICBZo5xT/B3eb86TlrQbWvapiw0WTiQ3dmLdoN3DvibNj1 OKg6jiLWtFFJ0gC6nuYqDb2DhFqDa4ugxC3YKLovm6ApgPfBhZiE2e4goQOeICVunCQF jPvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aRMyftJ0XM+xd8lyhkdTwsVMGajD6E5wzd9ozBH90+0=; b=AO6X+1DsEOwf/uFcCrQKkdFZudiecJlG175fUDDs2MnC+/Kw2loPLbsTkKDfVxdwvn Bje3Zk5Tgf5/V7HAP24Uv8slaca1Vcg1T2HEMMzSJt5Kynp3SJccoLF9AJoC4ErCRQxE GRXKckZcSiLbUF9I+iBR83KRysEJN1xNXSgjD0zNfEpG8COR/4B0dDZ8U3PKygwh/DVW nCFwH7NWcmf77sqRu+++P+xuO0g5pmsp19PRaWFjtwmDDsr1UEtWh7fUreV9NOpGdDIk 6ZnXkrp9psifLnUpnea5GtgvqFdFJ3h8S/bu8CVVGqXZawpWWwj2t+L4rU/zzkdZws3I lpkQ== X-Gm-Message-State: AKwxytdUiDIJxbEK80r6dUW1Q9DvG72gzzFhf2gbBDIQXzYBqmnUtqs8 7ueigtPyX3Nb7ZyvNNEAxV/RWM/f X-Google-Smtp-Source: ACJfBoshLbUcAIefENsqGfU//W9kCxOi8dckKmgD8roDvdw6ycckGQ3hI5d/vsC9j8mUxXa4Yn9vOQ== X-Received: by 10.25.150.207 with SMTP id y198mr8165518lfd.33.1515507462862; Tue, 09 Jan 2018 06:17:42 -0800 (PST) Received: from linw2017.zenterio.lan (vpn2.zenterio.com. [85.112.166.143]) by smtp.gmail.com with ESMTPSA id q72sm658916lfi.36.2018.01.09.06.17.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 06:17:41 -0800 (PST) From: osivertsson@gmail.com X-Google-Original-From: olof.sivertsson@zenterio.com To: lede-dev@lists.infradead.org Date: Tue, 9 Jan 2018 15:16:13 +0100 Message-Id: <20180109141613.7198-1-olof.sivertsson@zenterio.com> X-Mailer: git-send-email 2.15.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_061756_729091_75CB8168 X-CRM114-Status: GOOD ( 11.59 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4010:c07:0:0:0:241 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (osivertsson[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [PATCH iwinfo] nl80211: Do not block when driver aborts scan X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Olof Sivertsson MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Olof Sivertsson Drivers may abort a scan by calling cfg80211_scan_done() with a struct cfg80211_scan_info that sets aborted to true. To avoid blocking forever consider both NL80211_CMD_NEW_SCAN_RESULTS and NL80211_CMD_SCAN_ABORTED when waiting for scan results. Tested with Broadcom's bcmdhd driver. Signed-off-by: Olof Sivertsson --- iwinfo_nl80211.c | 12 ++++++++---- iwinfo_nl80211.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2776531..d84da24 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -510,7 +510,7 @@ static int nl80211_wait_cb(struct nl_msg *msg, void *arg) struct nl80211_event_conveyor *cv = arg; struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); - if (gnlh->cmd == cv->wait) + if (gnlh->cmd == cv->wait || gnlh->cmd == cv->cancel) cv->recv = gnlh->cmd; return NL_SKIP; @@ -521,9 +521,9 @@ static int nl80211_wait_seq_check(struct nl_msg *msg, void *arg) return NL_OK; } -static int nl80211_wait(const char *family, const char *group, int cmd) +static int nl80211_wait(const char *family, const char *group, int wait, int cancel) { - struct nl80211_event_conveyor cv = { .wait = cmd }; + struct nl80211_event_conveyor cv = { .wait = wait, .cancel = cancel }; struct nl_cb *cb; int err = 0; @@ -544,6 +544,9 @@ static int nl80211_wait(const char *family, const char *group, int cmd) nl_cb_put(cb); + if (cv.recv == cancel) + return -ECANCELED; + return err; } @@ -2091,7 +2094,8 @@ static int nl80211_get_scanlist_nl(const char *ifname, char *buf, int *len) if (nl80211_request(ifname, NL80211_CMD_TRIGGER_SCAN, 0, NULL, NULL)) goto out; - if (nl80211_wait("nl80211", "scan", NL80211_CMD_NEW_SCAN_RESULTS)) + if (nl80211_wait("nl80211", "scan", + NL80211_CMD_NEW_SCAN_RESULTS, NL80211_CMD_SCAN_ABORTED)) goto out; if (nl80211_request(ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP, diff --git a/iwinfo_nl80211.h b/iwinfo_nl80211.h index bb5117e..38089d2 100644 --- a/iwinfo_nl80211.h +++ b/iwinfo_nl80211.h @@ -49,6 +49,7 @@ struct nl80211_msg_conveyor { struct nl80211_event_conveyor { int wait; + int cancel; int recv; };