From patchwork Wed Oct 29 16:57:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 404720 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BA1C214008E for ; Thu, 30 Oct 2014 03:57:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 818949D663; Wed, 29 Oct 2014 12:57:39 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XocdvbXz0mRq; Wed, 29 Oct 2014 12:57:39 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4724C9D65E; Wed, 29 Oct 2014 12:57:33 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id ED8189D65E for ; Wed, 29 Oct 2014 12:57:31 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xCfrBAwVjBDc for ; Wed, 29 Oct 2014 12:57:25 -0400 (EDT) Received: from shell.v3.sk (shell.v3.sk [195.168.3.45]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CC9B59D65D for ; Wed, 29 Oct 2014 12:57:24 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id ACE17832EA for ; Wed, 29 Oct 2014 17:57:23 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id W1QaNbUv_V6h; Wed, 29 Oct 2014 17:57:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 1392A832EB; Wed, 29 Oct 2014 17:57:21 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FHlW3NOXD_SB; Wed, 29 Oct 2014 17:57:20 +0100 (CET) Received: from goatlord.localdomain.localdomain (ip-37-188-137-11.eurotel.cz [37.188.137.11]) by zimbra.v3.sk (Postfix) with ESMTPSA id 5F688832EA; Wed, 29 Oct 2014 17:57:19 +0100 (CET) From: Lubomir Rintel To: hostap@lists.shmoo.com Subject: [PATCH] wpa_supplicant: Denitialize the driver if the last user went away Date: Wed, 29 Oct 2014 17:57:09 +0100 Message-Id: <1414601829-24506-1-git-send-email-lkundrak@v3.sk> X-Mailer: git-send-email 2.1.0 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com It might be that the underlying infrastrucutre went away and the state is no longer valid. We ought to reinitialize it once a device appears again. This is the case when the nl80211 devices disappear and cfg8011 is remoed afterwards. The netlink handle is no longer valid (returns ENOENT) and a new one needs to be open if it's loaded back. Signed-off-by: Lubomir Rintel --- wpa_supplicant/wpa_supplicant.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 5a4d8dc..072dce5 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3925,6 +3925,24 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, return 0; } +/* Deinitialize the driver if we're the last user. */ +static void wpa_drv_cleanup(struct wpa_supplicant *wpa_s) +{ + struct wpa_global *global = wpa_s->global; + struct wpa_supplicant *iface; + int i; + + for (iface = global->ifaces; iface; iface = iface->next) + if (iface != wpa_s && iface->driver == wpa_s->driver) + return; + + for (i = 0; wpa_drivers[i]; i++) + if (global->drv_priv[i] == wpa_s->global_drv_priv) + wpa_s->global_drv_priv = global->drv_priv[i] = NULL; + + if (wpa_s->driver->global_deinit) + wpa_s->driver->global_deinit (wpa_s->global_drv_priv); +} static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, int notify, int terminate) @@ -3967,6 +3985,8 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, if (wpa_s->drv_priv) wpa_drv_deinit(wpa_s); + wpa_drv_cleanup(wpa_s); + if (notify) wpas_notify_iface_removed(wpa_s);