From patchwork Wed Jun 17 13:18:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilan Peer X-Patchwork-Id: 485423 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]) by ozlabs.org (Postfix) with ESMTP id 23AF11401F0 for ; Wed, 17 Jun 2015 23:20:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2D46C17C781; Wed, 17 Jun 2015 09:20:33 -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 N+SlQ2SPu7KJ; Wed, 17 Jun 2015 09:20:32 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 63D0F17C935; Wed, 17 Jun 2015 09:19: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 C959B17C934 for ; Wed, 17 Jun 2015 09:19: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 ppe5q54ewjlO for ; Wed, 17 Jun 2015 09:19:26 -0400 (EDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1250717C754 for ; Wed, 17 Jun 2015 09:18:51 -0400 (EDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 17 Jun 2015 06:18:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,632,1427785200"; d="scan'208";a="712618522" Received: from unknown (HELO ipeer-dev-3.jer.intel.com) ([10.12.217.137]) by orsmga001.jf.intel.com with ESMTP; 17 Jun 2015 06:18:50 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH 8/9] P2P: Handle P2P Device dedicated interface parent removal Date: Wed, 17 Jun 2015 16:18:20 +0300 Message-Id: <1434547101-7342-8-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434547101-7342-1-git-send-email-ilan.peer@intel.com> References: <1434547101-7342-1-git-send-email-ilan.peer@intel.com> 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 In case of a network interface removal, check if the interface was also the parent interface of the P2P Device dedicated interface. If this is the case, then stop the P2P Device functionality, and remove the P2P Device dedicated interface. In case that the interface is added again and P2P Device functionality can be enabled again, add a new P2P Device dedicated interface and allow further P2P Device functionality. In case that the P2P Device dedicated interface is re-created, the original P2P Device configuration file is needed, so store it in the global params (instead in the wpa_interface configuration). Signed-off-by: Ilan Peer --- wpa_supplicant/events.c | 29 +++++++++++++++++++++++++++++ wpa_supplicant/main.c | 2 +- wpa_supplicant/p2p_supplicant.c | 1 - wpa_supplicant/wpa_supplicant.c | 3 ++- wpa_supplicant/wpa_supplicant_i.h | 23 ++++++++++++----------- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index b615fbd..f8ab4b8 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2553,6 +2553,21 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the " "driver after interface was added"); } + +#ifdef CONFIG_P2P + if (!wpa_s->global->p2p && + !wpa_s->global->p2p_disabled && + !wpa_s->conf->p2p_disabled && + (wpa_s->drv_flags & + WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) && + wpas_p2p_add_p2pdev_interface(wpa_s, + wpa_s->global->params.conf_p2p_dev) < 0) { + wpa_printf(MSG_INFO, + "P2P: Failed to enable P2P Device interface"); + /* Try to continue without. P2P will be disabled. */ + } +#endif /* CONFIG_P2P */ + break; case EVENT_INTERFACE_REMOVED: wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed"); @@ -2561,6 +2576,20 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED); l2_packet_deinit(wpa_s->l2); wpa_s->l2 = NULL; + +#ifdef CONFIG_P2P + if (wpa_s->global->p2p && + wpa_s->global->p2p_init_wpa_s->parent == wpa_s && + (wpa_s->drv_flags & + WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) { + wpa_dbg(wpa_s, MSG_DEBUG, "Removing P2P Device interface"); + wpa_supplicant_remove_iface(wpa_s->global, + wpa_s->global->p2p_init_wpa_s, + 0); + wpa_s->global->p2p_init_wpa_s = NULL; + } +#endif /* CONFIG_P2P */ + #ifdef CONFIG_TERMINATE_ONLASTIF /* check if last interface */ if (!any_interfaces(wpa_s->global->ifaces)) diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c index 9f5a198..1c93306 100644 --- a/wpa_supplicant/main.c +++ b/wpa_supplicant/main.c @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) goto out; #ifdef CONFIG_P2P case 'm': - iface->conf_p2p_dev = optarg; + params.conf_p2p_dev = optarg; break; #endif /* CONFIG_P2P */ case 'o': diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e309c11..f1de602 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3472,7 +3472,6 @@ int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s, iface.confname = wpa_s->confname; iface.ctrl_interface = wpa_s->conf->ctrl_interface; } - iface.conf_p2p_dev = NULL; p2pdev_wpa_s = wpa_supplicant_add_iface(wpa_s->global, &iface, wpa_s); if (!p2pdev_wpa_s) { diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 97c947c..7fbab2c 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -4451,7 +4451,8 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, if (wpa_s->global->p2p == NULL && !wpa_s->global->p2p_disabled && !wpa_s->conf->p2p_disabled && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) && - wpas_p2p_add_p2pdev_interface(wpa_s, iface->conf_p2p_dev) < 0) { + wpas_p2p_add_p2pdev_interface(wpa_s, + wpa_s->global->params.conf_p2p_dev) < 0) { wpa_printf(MSG_INFO, "P2P: Failed to enable P2P Device interface"); /* Try to continue without. P2P will be disabled. */ diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index f39fe23..73eb920 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -66,17 +66,6 @@ struct wpa_interface { */ const char *confanother; -#ifdef CONFIG_P2P - /** - * conf_p2p_dev - Configuration file used to hold the - * P2P Device configuration parameters. - * - * This can also be %NULL. In such a case, if a P2P Device dedicated - * interfaces is created, the main configuration file will be used. - */ - const char *conf_p2p_dev; -#endif /* CONFIG_P2P */ - /** * ctrl_interface - Control interface parameter * @@ -227,6 +216,18 @@ struct wpa_params { * its internal entropy store over restarts. */ char *entropy_file; + +#ifdef CONFIG_P2P + /** + * conf_p2p_dev - Configuration file used to hold the + * P2P Device configuration parameters. + * + * This can also be %NULL. In such a case, if a P2P Device dedicated + * interfaces is created, the main configuration file will be used. + */ + const char *conf_p2p_dev; +#endif /* CONFIG_P2P */ + }; struct p2p_srv_bonjour {