Message ID | 20180109141613.7198-1-olof.sivertsson@zenterio.com |
---|---|
State | Superseded |
Delegated to: | Jo-Philipp Wich |
Headers | show |
Series | [LEDE-DEV,iwinfo] nl80211: Do not block when driver aborts scan | expand |
On 09/01/18 15:16, osivertsson@gmail.com wrote: > From: Olof Sivertsson <olof.sivertsson@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@zenterio.com> Hi Olof, Jow prepare an alternate solution ot the problem https://git.openwrt.org/?p=project/iwinfo.git;a=commitdiff;h=75c572074f272f0b983d888f7dd23ee59719c6b0 https://git.openwrt.org/?p=project/iwinfo.git;a=commitdiff;h=fb749bf51a7855ee955fc221acdc51b94231db2b John > --- > 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; > }; >
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; };