]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Handle P2P Device dedicated interface parent removal
authorIlan Peer <ilan.peer@intel.com>
Wed, 17 Jun 2015 13:18:20 +0000 (16:18 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 19 Jun 2015 13:22:26 +0000 (16:22 +0300)
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 <ilan.peer@intel.com>
wpa_supplicant/events.c
wpa_supplicant/main.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index b615fbd42febd377428c2b73a007865e41c632f0..f15a6a43c1e0cdeeed04a6a84b2caa97d2101396 100644 (file)
@@ -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,21 @@ 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))
index 9f5a198e0aaab07380f176e834b2884f4a7b649e..1c9330693721079903d197dbad9e1391b6baa3ca 100644 (file)
@@ -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':
index ac4ad5a5d025600872c01b7876c6cae6ae779e3c..b9ebd380f2d32430a544ca91ffcbafbf651fd9f8 100644 (file)
@@ -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) {
index 97c947c7db0426de98fce74b10e61d6033b95825..8fba9382a90b193edbe4782494e97e50dc38a6f5 100644 (file)
@@ -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. */
index 8ace44f520adc0e3dc1f88a9aaf442df7494b76c..dd5b245c8ed7673992a88d395f20829a2f00f08e 100644 (file)
@@ -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 {