[LEDE-DEV] [PATCH iwinfo] nl80211: Do not block when driver aborts scan
osivertsson at gmail.com
osivertsson at gmail.com
Tue Jan 9 06:16:13 PST 2018
From: Olof Sivertsson <olof.sivertsson at zenterio.com>
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 <olof.sivertsson at zenterio.com>
---
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;
};
--
2.15.1
More information about the Lede-dev
mailing list