Patchwork [v2] P2P: Handle INTERFACE_DISABLED event on a P2P GO interface

login
register
mail settings
Submitter Ilan Peer
Date Sept. 2, 2013, 12:40 p.m.
Message ID <1378125660-16627-1-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/271940/
State Accepted
Headers show

Comments

Ilan Peer - Sept. 2, 2013, 12:40 p.m.
An INTERFACE_DISABLED event received on an interface that is
currently operating a P2P_GO means that the group session ended.
In such a case, if the interface was dynamically added remove it, and
if not, remove all the network blocks that are temporary, assuming
that if needed a new session will be started by an external entity.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>
---
 wpa_supplicant/events.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
Jouni Malinen - Nov. 24, 2013, 11:28 a.m.
On Mon, Sep 02, 2013 at 03:40:59PM +0300, Ilan Peer wrote:
> An INTERFACE_DISABLED event received on an interface that is
> currently operating a P2P_GO means that the group session ended.
> In such a case, if the interface was dynamically added remove it, and
> if not, remove all the network blocks that are temporary, assuming
> that if needed a new session will be started by an external entity.

Thanks, applied with the no-separate-group-iface case modified to use
the same wpas_p2p_disconnect() call.

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 69e4030..7bf3d7b 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2580,6 +2580,7 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			  union wpa_event_data *data)
 {
 	struct wpa_supplicant *wpa_s = ctx;
+	struct wpa_ssid *ssid;
 
 	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
 	    event != EVENT_INTERFACE_ENABLED &&
@@ -3045,7 +3046,35 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 		break;
 	case EVENT_INTERFACE_DISABLED:
 		wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
+#ifdef CONFIG_P2P
+		if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO) {
+			/*
+			 * The interface was externally disabled. Remove
+			 * it assuming an external entity will start a
+			 * new session if needed.
+			 */
+			wpas_p2p_disconnect(wpa_s);
+			break;
+		}
+#endif /* CONFIG_P2P */
+
 		wpa_supplicant_mark_disassoc(wpa_s);
+
+#ifdef CONFIG_P2P
+		/*
+		 * Since the interface was externally disabled, remove any
+		 * temporary network blocks
+		 */
+		ssid = wpa_s->conf->ssid;
+		while (ssid) {
+			int id = ssid->id;
+			ssid = ssid->next;
+			if (ssid->p2p_group && ssid->temporary &&
+			    ssid->mode == WPAS_MODE_P2P_GO)
+				wpa_config_remove_network(wpa_s->conf, id);
+		}
+#endif /* CONFIG_P2P */
+
 		wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
 		break;
 	case EVENT_CHANNEL_LIST_CHANGED: