From patchwork Thu Oct 30 08:24:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 404921 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 4CB8D14007F for ; Thu, 30 Oct 2014 19:25:20 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5791017C0CA; Thu, 30 Oct 2014 04:25:17 -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 VBdk+yI8b1Kt; Thu, 30 Oct 2014 04:25:17 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 75B2E17C198; Thu, 30 Oct 2014 04:25:08 -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 163C417C0CA for ; Thu, 30 Oct 2014 04:25:07 -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 9FjSq3yDHLkT for ; Thu, 30 Oct 2014 04:25:00 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx1.redhat.com", Issuer "DigiCert SHA2 Extended Validation Server CA" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 4FBF217C03E for ; Thu, 30 Oct 2014 04:25:00 -0400 (EDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9U8OvGU018315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Oct 2014 04:24:58 -0400 Received: from belphegor.brq.redhat.com. (dhcp-24-102.brq.redhat.com [10.34.24.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9U8OrlU025831 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Thu, 30 Oct 2014 04:24:56 -0400 From: Lubomir Rintel To: hostap@lists.shmoo.com Subject: [PATCH v2] wpa_supplicant: Denitialize the driver if the last user went away Date: Thu, 30 Oct 2014 09:24:50 +0100 Message-Id: <1414657490-22551-1-git-send-email-lkundrak@v3.sk> In-Reply-To: <1414601829-24506-1-git-send-email-lkundrak@v3.sk> References: <1414601829-24506-1-git-send-email-lkundrak@v3.sk> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: Jouni Malinen 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 --- Changes since v1: - wpa_s->global_drv_priv unset moved to correct place wpa_supplicant/wpa_supplicant.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 5a4d8dc..2099ef8 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3925,6 +3925,25 @@ 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) + global->drv_priv[i] = NULL; + + if (wpa_s->driver->global_deinit) + wpa_s->driver->global_deinit (wpa_s->global_drv_priv); + wpa_s->global_drv_priv = NULL; +} static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, int notify, int terminate) @@ -3967,6 +3986,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);