Patchwork P2P: Add deinit_p2p_cli op

login
register
mail settings
Submitter Eliad Peller
Date March 5, 2012, 10:39 a.m.
Message ID <1330943984-8572-1-git-send-email-eliad@wizery.com>
Download mbox | patch
Permalink /patch/144648/
State Accepted
Commit 3c29244eb7a2dfd62d80ba4e6176de2889a5dca4
Headers show

Comments

Eliad Peller - March 5, 2012, 10:39 a.m.
On p2p group removal, the GO is deinitialized correctly
(and the vif mode is set back to sta), but the P2P_CLI
isn't deinitialized, and the vif stays in P2P_CLI mode.

Add a new deinit_p2p_cli op (similar to deinit_ap), which
currently only sets the interface back to sta mode.

Signed-hostap: Eliad Peller <eliad@wizery.com>
intended-for: hostap-1
---
 src/drivers/driver.h            |   11 +++++++++++
 src/drivers/driver_nl80211.c    |    9 +++++++++
 wpa_supplicant/driver_i.h       |    7 +++++++
 wpa_supplicant/p2p_supplicant.c |    5 ++++-
 4 files changed, 31 insertions(+), 1 deletions(-)
Vitaly Wool - March 5, 2012, 11:29 a.m.
Hi Eliad,

On Mon, Mar 5, 2012 at 11:39 AM, Eliad Peller <eliad@wizery.com> wrote:

> On p2p group removal, the GO is deinitialized correctly
> (and the vif mode is set back to sta), but the P2P_CLI
> isn't deinitialized, and the vif stays in P2P_CLI mode.
>
> Add a new deinit_p2p_cli op (similar to deinit_ap), which
> currently only sets the interface back to sta mode.
>
> Signed-hostap: Eliad Peller <eliad@wizery.com>
> intended-for: hostap-1
>

why can't we modify wpa_supplicant_ap_deinit() instead?

~Vitaly
Eliad Peller - March 5, 2012, 11:48 a.m.
hi Vitaly,

On Mon, Mar 5, 2012 at 1:29 PM, Vitaly Wool <vitalywool@gmail.com> wrote:
> On Mon, Mar 5, 2012 at 11:39 AM, Eliad Peller <eliad@wizery.com> wrote:
>>
>> On p2p group removal, the GO is deinitialized correctly
>> (and the vif mode is set back to sta), but the P2P_CLI
>> isn't deinitialized, and the vif stays in P2P_CLI mode.
>>
>> Add a new deinit_p2p_cli op (similar to deinit_ap), which
>> currently only sets the interface back to sta mode.
>>
>> Signed-hostap: Eliad Peller <eliad@wizery.com>
>> intended-for: hostap-1
>
>
> why can't we modify wpa_supplicant_ap_deinit() instead?
>
i think wpa_supplicant_ap_deinit is meant for AP/GO interfaces, while
the patch tries to address P2P_CLI interface deinitialization.

Eliad.
Vitaly Wool - March 5, 2012, 11:49 a.m.
On Mon, Mar 5, 2012 at 12:48 PM, Eliad Peller <eliad@wizery.com> wrote:

> >>
> >> Signed-hostap: Eliad Peller <eliad@wizery.com>
> >> intended-for: hostap-1
> >
> >
> > why can't we modify wpa_supplicant_ap_deinit() instead?
> >
> i think wpa_supplicant_ap_deinit is meant for AP/GO interfaces, while
> the patch tries to address P2P_CLI interface deinitialization.
>
>
Why is it now called in the station mode then?

~Vitaly
Eliad Peller - March 5, 2012, 11:56 a.m.
On Mon, Mar 5, 2012 at 1:49 PM, Vitaly Wool <vitalywool@gmail.com> wrote:
> On Mon, Mar 5, 2012 at 12:48 PM, Eliad Peller <eliad@wizery.com> wrote:
>>
>> >>
>> >> Signed-hostap: Eliad Peller <eliad@wizery.com>
>> >> intended-for: hostap-1
>> >
>> >
>> > why can't we modify wpa_supplicant_ap_deinit() instead?
>> >
>> i think wpa_supplicant_ap_deinit is meant for AP/GO interfaces, while
>> the patch tries to address P2P_CLI interface deinitialization.
>>
>
> Why is it now called in the station mode then?
>
it's called when the interface was removed, we are currently in
P2P_CLI mode, and we want to change the interface mode back to STA
mode (as drivers might pose different limitations on STA and P2P_CLI
interface modes)

Eliad.
Jouni Malinen - April 1, 2012, 6:43 p.m.
On Mon, Mar 05, 2012 at 12:39:44PM +0200, Eliad Peller wrote:
> On p2p group removal, the GO is deinitialized correctly
> (and the vif mode is set back to sta), but the P2P_CLI
> isn't deinitialized, and the vif stays in P2P_CLI mode.
> 
> Add a new deinit_p2p_cli op (similar to deinit_ap), which
> currently only sets the interface back to sta mode.

Thanks, applied.

Patch

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 04aedcf..f104cd7 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2003,6 +2003,17 @@  struct wpa_driver_ops {
 	int (*deinit_ap)(void *priv);
 
 	/**
+	 * deinit_ap - Deinitialize P2P_CLI mode
+	 * @priv: Private driver interface data
+	 * Returns: 0 on success, -1 on failure (or if not supported)
+	 *
+	 * This optional function can be used to disable P2P_CLI mode.
+	 * usually, it will most be used to change vif type back to
+	 * station mode.
+	 */
+	int (*deinit_p2p_cli)(void *priv);
+
+	/**
 	 * suspend - Notification on system suspend/hibernate event
 	 * @priv: Private driver interface data
 	 */
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 184b26f..a3c857c 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -8263,6 +8263,14 @@  static int wpa_driver_nl80211_deinit_ap(void *priv)
 	return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION);
 }
 
+static int wpa_driver_nl80211_deinit_p2p_cli(void *priv)
+{
+	struct i802_bss *bss = priv;
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+	if (drv->nlmode != NL80211_IFTYPE_P2P_CLIENT)
+		return -1;
+	return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION);
+}
 
 static void wpa_driver_nl80211_resume(void *priv)
 {
@@ -8989,6 +8997,7 @@  const struct wpa_driver_ops wpa_driver_nl80211_ops = {
 	wpa_driver_nl80211_cancel_remain_on_channel,
 	.probe_req_report = wpa_driver_nl80211_probe_req_report,
 	.deinit_ap = wpa_driver_nl80211_deinit_ap,
+	.deinit_p2p_cli = wpa_driver_nl80211_deinit_p2p_cli,
 	.resume = wpa_driver_nl80211_resume,
 	.send_ft_action = nl80211_send_ft_action,
 	.signal_monitor = nl80211_signal_monitor,
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 5b10540..e1e921d 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -427,6 +427,13 @@  static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
 	return 0;
 }
 
+static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
+{
+	if (wpa_s->driver->deinit_p2p_cli)
+		return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
+	return 0;
+}
+
 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
 {
 	if (wpa_s->driver->suspend)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 486a551..46bb123 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -311,7 +311,10 @@  static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s)
 		wpa_printf(MSG_DEBUG, "P2P: Temporary group network not "
 			   "found");
 	}
-	wpa_supplicant_ap_deinit(wpa_s);
+	if (wpa_s->ap_iface)
+		wpa_supplicant_ap_deinit(wpa_s);
+	else
+		wpa_drv_deinit_p2p_cli(wpa_s);
 }