[PATCH 1/3] wpa_supplicant: abort scan after removing all networks

Eyal Shapira eyal
Tue Oct 30 00:21:48 PDT 2012


On 29 October 2012 11:13,  <david.spinadel at intel.com> wrote:
> From: David Spinadel <david.spinadel at intel.com>
>
> Change-Id: I737848dabed49d961985845f2e86f717c2926f0c
> Reviewed-on: http://git-mwg.jer.intel.com/gerrit/3585
> Reviewed-by: Jenkins
> Tested-by: Jenkins
> Reviewed-by: Max Stepanov <Max.Stepanov at intel.com>
> Tested-by: Max Stepanov <Max.Stepanov at intel.com>
> Signed-off-by: David Spinadel <david.spinadel at intel.com>
> ---
>  wpa_supplicant/ctrl_iface.c             |    7 +++++++
>  wpa_supplicant/dbus/dbus_new_handlers.c |    8 ++++++++
>  wpa_supplicant/dbus/dbus_old_handlers.c |    5 +++++
>  wpa_supplicant/wps_supplicant.c         |    5 +++++
>  4 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> index 0351241..d1a5cf6 100644
> --- a/wpa_supplicant/ctrl_iface.c
> +++ b/wpa_supplicant/ctrl_iface.c
> @@ -2224,6 +2224,8 @@ static int wpa_supplicant_ctrl_iface_remove_network(
>         /* cmd: "<network id>" or "all" */
>         if (os_strcmp(cmd, "all") == 0) {
>                 wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_NETWORK all");
> +               wpa_supplicant_cancel_sched_scan(wpa_s);
> +               wpa_supplicant_cancel_scan(wpa_s);
>                 ssid = wpa_s->conf->ssid;
>                 while (ssid) {
>                         struct wpa_ssid *remove_ssid = ssid;
> @@ -2281,6 +2283,11 @@ static int wpa_supplicant_ctrl_iface_remove_network(
>                 return -1;
>         }
>
> +       if (!wpa_s->conf->ssid) {
> +               wpa_supplicant_cancel_sched_scan(wpa_s);
> +               wpa_supplicant_cancel_scan(wpa_s);
> +       }
> +
>         return 0;
>  }
>
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
> index 00378be..b0f0d0e 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers.c
> +++ b/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -1525,6 +1525,11 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
>                 wpa_supplicant_deauthenticate(wpa_s,
>                                               WLAN_REASON_DEAUTH_LEAVING);
>
> +       if (!wpa_s->conf->ssid) {
> +               wpa_supplicant_cancel_sched_scan(wpa_s);
> +               wpa_supplicant_cancel_scan(wpa_s);
> +       }
> +
>  out:
>         os_free(iface);
>         os_free(net_id);
> @@ -1562,6 +1567,9 @@ static void remove_network(void *arg, struct wpa_ssid *ssid)
>  DBusMessage * wpas_dbus_handler_remove_all_networks(
>         DBusMessage *message, struct wpa_supplicant *wpa_s)
>  {
> +       wpa_supplicant_cancel_sched_scan(wpa_s);
> +       wpa_supplicant_cancel_scan(wpa_s);
> +
>         /* NB: could check for failure and return an error */
>         wpa_config_foreach_network(wpa_s->conf, remove_network, wpa_s);
>         return NULL;
> diff --git a/wpa_supplicant/dbus/dbus_old_handlers.c b/wpa_supplicant/dbus/dbus_old_handlers.c
> index e217a72..ff60f6e 100644
> --- a/wpa_supplicant/dbus/dbus_old_handlers.c
> +++ b/wpa_supplicant/dbus/dbus_old_handlers.c
> @@ -870,6 +870,11 @@ DBusMessage * wpas_dbus_iface_remove_network(DBusMessage *message,
>                                               WLAN_REASON_DEAUTH_LEAVING);
>         reply = wpas_dbus_new_success_reply(message);
>
> +       if (!wpa_s->conf->ssid) {
> +               wpa_supplicant_cancel_sched_scan(wpa_s);
> +               wpa_supplicant_cancel_scan(wpa_s);
> +       }
> +
>  out:
>         os_free(iface);
>         os_free(net_id);
> diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
> index 41aa5db..87ea320 100644
> --- a/wpa_supplicant/wps_supplicant.c
> +++ b/wpa_supplicant/wps_supplicant.c
> @@ -759,6 +759,11 @@ static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
>         }
>
>         wpas_wps_clear_ap_info(wpa_s);
> +
> +       if (!wpa_s->conf->ssid) {
> +               wpa_supplicant_cancel_sched_scan(wpa_s);
> +               wpa_supplicant_cancel_scan(wpa_s);
> +       }
>  }

wpa_supplicant_scan wouldn't do anything if you haven't got any
enabled networks so the cancel_scan() is a bit moot. no ?

Regarding sched scan, I think the more correct behavior is to restart
sched scan whenever the enabled networks list change (e.g.
enable/disable/remove)
as otherwise we'd continue to sched scan a non relevant list of SSIDs.
This would also take care of removing all networks given
that we bail out in wpa_supplicant_req_sched_scan if there aren't any
enabled networks.
I have some internal patches on our tree doing something like this but
they need some work to be rebased on the latetest master.
If we agree that's a better approach I can rebase them and submit.



More information about the Hostap mailing list