@@ -3883,7 +3883,7 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global,
wpa_s = wpa_supplicant_get_iface(global, cmd);
if (wpa_s == NULL)
return -1;
- return wpa_supplicant_remove_iface(global, wpa_s);
+ return wpa_supplicant_remove_iface(global, wpa_s, 0);
}
@@ -576,7 +576,7 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message,
wpa_s = get_iface_by_dbus_path(global, path);
if (wpa_s == NULL)
reply = wpas_dbus_error_iface_unknown(message);
- else if (wpa_supplicant_remove_iface(global, wpa_s)) {
+ else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) {
reply = wpas_dbus_error_unknown_error(
message, "wpa_supplicant couldn't remove this "
"interface.");
@@ -229,7 +229,7 @@ DBusMessage * wpas_dbus_global_remove_interface(DBusMessage *message,
goto out;
}
- if (!wpa_supplicant_remove_iface(global, wpa_s)) {
+ if (!wpa_supplicant_remove_iface(global, wpa_s, 0)) {
reply = wpas_dbus_new_success_reply(message);
} else {
reply = dbus_message_new_error(message,
@@ -280,7 +280,7 @@ static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s)
global = wpa_s->global;
ifname = os_strdup(wpa_s->ifname);
type = wpas_p2p_if_type(wpa_s->p2p_group_interface);
- wpa_supplicant_remove_iface(wpa_s->global, wpa_s);
+ wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0);
wpa_s = global->ifaces;
if (wpa_s && ifname)
wpa_drv_if_remove(wpa_s, type, ifname);
@@ -2427,7 +2427,7 @@ void wpas_p2p_deinit_global(struct wpa_global *global)
break;
ifname = os_strdup(tmp->ifname);
type = wpas_p2p_if_type(tmp->p2p_group_interface);
- wpa_supplicant_remove_iface(global, tmp);
+ wpa_supplicant_remove_iface(global, tmp, 0);
if (ifname)
wpa_drv_if_remove(wpa_s, type, ifname);
os_free(ifname);
@@ -400,16 +400,10 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
wpa_s->l2_br = NULL;
}
- if (wpa_s->ctrl_iface) {
- wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
- wpa_s->ctrl_iface = NULL;
- }
if (wpa_s->conf != NULL) {
struct wpa_ssid *ssid;
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
wpas_notify_network_removed(wpa_s, ssid);
- wpa_config_free(wpa_s->conf);
- wpa_s->conf = NULL;
}
os_free(wpa_s->confname);
@@ -2393,7 +2387,7 @@ next_driver:
static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
- int notify)
+ int notify, int terminate)
{
if (wpa_s->drv_priv) {
wpa_supplicant_deauthenticate(wpa_s,
@@ -2405,11 +2399,24 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
wpa_supplicant_cleanup(wpa_s);
+ if (wpa_s->drv_priv)
+ wpa_drv_deinit(wpa_s);
+
if (notify)
wpas_notify_iface_removed(wpa_s);
- if (wpa_s->drv_priv)
- wpa_drv_deinit(wpa_s);
+ if (terminate)
+ wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
+
+ if (wpa_s->ctrl_iface) {
+ wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
+ wpa_s->ctrl_iface = NULL;
+ }
+
+ if (wpa_s->conf != NULL) {
+ wpa_config_free(wpa_s->conf);
+ wpa_s->conf = NULL;
+ }
}
@@ -2459,14 +2466,14 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
if (wpa_supplicant_init_iface(wpa_s, &t_iface)) {
wpa_printf(MSG_DEBUG, "Failed to add interface %s",
iface->ifname);
- wpa_supplicant_deinit_iface(wpa_s, 0);
+ wpa_supplicant_deinit_iface(wpa_s, 0, 0);
os_free(wpa_s);
return NULL;
}
/* Notify the control interfaces about new iface */
if (wpas_notify_iface_added(wpa_s)) {
- wpa_supplicant_deinit_iface(wpa_s, 1);
+ wpa_supplicant_deinit_iface(wpa_s, 1, 0);
os_free(wpa_s);
return NULL;
}
@@ -2495,7 +2502,8 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
* %wpa_supplicant is terminated.
*/
int wpa_supplicant_remove_iface(struct wpa_global *global,
- struct wpa_supplicant *wpa_s)
+ struct wpa_supplicant *wpa_s,
+ int terminate)
{
struct wpa_supplicant *prev;
@@ -2515,7 +2523,7 @@ int wpa_supplicant_remove_iface(struct wpa_global *global,
if (global->p2p_group_formation == wpa_s)
global->p2p_group_formation = NULL;
- wpa_supplicant_deinit_iface(wpa_s, 1);
+ wpa_supplicant_deinit_iface(wpa_s, 1, terminate);
os_free(wpa_s);
return 0;
@@ -2731,7 +2739,7 @@ void wpa_supplicant_deinit(struct wpa_global *global)
#endif /* CONFIG_P2P */
while (global->ifaces)
- wpa_supplicant_remove_iface(global, global->ifaces);
+ wpa_supplicant_remove_iface(global, global->ifaces, 1);
if (global->ctrl_iface)
wpa_supplicant_global_ctrl_iface_deinit(global->ctrl_iface);
@@ -575,7 +575,8 @@ void wpa_show_license(void);
struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
struct wpa_interface *iface);
int wpa_supplicant_remove_iface(struct wpa_global *global,
- struct wpa_supplicant *wpa_s);
+ struct wpa_supplicant *wpa_s,
+ int terminate);
struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
const char *ifname);
struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com> --- wpa_supplicant/ctrl_iface.c | 2 +- wpa_supplicant/dbus/dbus_new_handlers.c | 2 +- wpa_supplicant/dbus/dbus_old_handlers.c | 2 +- wpa_supplicant/p2p_supplicant.c | 4 +- wpa_supplicant/wpa_supplicant.c | 36 +++++++++++++++++++------------ wpa_supplicant/wpa_supplicant_i.h | 3 +- 6 files changed, 29 insertions(+), 20 deletions(-)