Patchwork wpa_supplicant: abort scan after removing all networks

login
register
mail settings
Submitter Spinadel, David
Date Oct. 26, 2012, 3:15 a.m.
Message ID <F781B6216F70FE49AB7B89F25E2F80C0BB552E@HASMSX105.ger.corp.intel.com>
Download mbox | patch
Permalink /patch/194603/
State Superseded
Headers show

Comments

Spinadel, David - Oct. 26, 2012, 3:15 a.m.
From 8f3b462083bdca2a94d6af32547b7965fdffa9d6 Mon Sep 17 00:00:00 2001
From: David Spinadel <david.spinadel@intel.com>
Date: Wed, 10 Oct 2012 15:37:36 +0200
Subject: [PATCH] wpa_supplicant: abort scan after removing all networks

Change-Id: I737848dabed49d961985845f2e86f717c2926f0c
Signed-off-by: David Spinadel <david.spinadel@intel.com>
Reviewed-on: http://git-mwg.jer.intel.com/gerrit/3585
Reviewed-by: Jenkins
Tested-by: Jenkins
Reviewed-by: Max Stepanov <Max.Stepanov@intel.com>
Tested-by: Max Stepanov <Max.Stepanov@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(-)

--
1.7.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Jouni Malinen - Oct. 28, 2012, 6:58 p.m.
On Fri, Oct 26, 2012 at 03:15:37AM +0000, Spinadel, David wrote:
> Subject: [PATCH] wpa_supplicant: abort scan after removing all networks

This one is also whitespace damaged.. Could you please explain why this
change is needed? wpa_supplicant stops scanning if there are no enabled
networks.

> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -1538,6 +1543,9 @@ static void remove_network(void *arg, struct wpa_ssid *ssid)
> 
>         wpas_notify_network_removed(wpa_s, ssid);
> 
> +       wpa_supplicant_cancel_sched_scan(wpa_s);
> +       wpa_supplicant_cancel_scan(wpa_s);
> +
>         if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {

Is this correct? This is removing just one network and there could be
other enabled networks that are being scanned.
Spinadel, David - Oct. 29, 2012, 8:02 a.m.
> This one is also whitespace damaged..
Sorry for that, It's a side effect from my Windows machine that I'm using for Emails. I'll fix it.
> Could you please explain why this change is needed? wpa_supplicant stops scanning if there are no enabled
> networks.
It's especially needed for scheduled scan, but we can stop the regular scans as well.

> >         if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
> 
> Is this correct? This is removing just one network and there could be other
> enabled networks that are being scanned.

My mistake, will fix it.

David 
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index d8e4864..0eeb9ec 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2085,6 +2085,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;
@@ -2142,6 +2144,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..9422b24 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);
@@ -1538,6 +1543,9 @@  static void remove_network(void *arg, struct wpa_ssid *ssid)

        wpas_notify_network_removed(wpa_s, ssid);

+       wpa_supplicant_cancel_sched_scan(wpa_s);
+       wpa_supplicant_cancel_scan(wpa_s);
+
        if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
                wpa_printf(MSG_ERROR,
                           "wpas_dbus_handler_remove_all_networks[dbus]: "
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 dd48ab7..d8603fd 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -756,6 +756,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);
+       }
 }