diff mbox

[v3,03/15] driver_nl80211: move AP SME setup to mode change

Message ID 20111119123950.257383639@sipsolutions.net
State Accepted
Commit 3fd1cefb812762ebb796d3b1eb05f5748a0c9045
Headers show

Commit Message

Johannes Berg Nov. 19, 2011, 12:39 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
---
 src/drivers/driver_nl80211.c |   84 ++++++++++++++++++++++++++---------------
 1 files changed, 53 insertions(+), 31 deletions(-)

Comments

Jouni Malinen Dec. 3, 2011, 5:50 p.m. UTC | #1
On Sat, Nov 19, 2011 at 01:39:13PM +0100, Johannes Berg wrote:
> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c

> @@ -5964,33 +5997,22 @@ static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
> -	if (!ret && is_p2p_interface(drv->nlmode)) {
> -		nl80211_disable_11b_rates(drv, drv->ifindex, 1);
> -		drv->disabled_11b_rates = 1;
> -	} else if (!ret && drv->disabled_11b_rates) {
> -		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
> -		drv->disabled_11b_rates = 0;
> +		nl80211_teardown_ap(bss);
>  	}

Hmm.. That removal of disable_11b_rates() does not look correct. Was
this some kind of merge/rebasing issue? I dropped the part that removed
11b rate handling here. Please verify that the changes are correct.
Johannes Berg Dec. 4, 2011, 9:29 a.m. UTC | #2
On Sat, 2011-12-03 at 19:50 +0200, Jouni Malinen wrote:
> On Sat, Nov 19, 2011 at 01:39:13PM +0100, Johannes Berg wrote:
> > diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> 
> > @@ -5964,33 +5997,22 @@ static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
> > -	if (!ret && is_p2p_interface(drv->nlmode)) {
> > -		nl80211_disable_11b_rates(drv, drv->ifindex, 1);
> > -		drv->disabled_11b_rates = 1;
> > -	} else if (!ret && drv->disabled_11b_rates) {
> > -		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
> > -		drv->disabled_11b_rates = 0;
> > +		nl80211_teardown_ap(bss);
> >  	}
> 
> Hmm.. That removal of disable_11b_rates() does not look correct. Was
> this some kind of merge/rebasing issue? I dropped the part that removed
> 11b rate handling here. Please verify that the changes are correct.

Yeah, that looks fishy, thanks for catching it.

I notice you changed the 11b-disable behaviour completely afterwards, it
looks OK to me except it seems to now be missing when the driver doesn't
advertise WPA_DRIVER_FLAGS_P2P_CONCURRENT?

johannes
diff mbox

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index a1a379e..ccb4329 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -223,6 +223,7 @@  struct wpa_driver_nl80211_data {
 
 	int monitor_sock;
 	int monitor_ifidx;
+	int monitor_refcount;
 
 	unsigned int disabled_11b_rates:1;
 	unsigned int pending_remain_on_chan:1;
@@ -5133,6 +5134,10 @@  static int add_monitor_filter(int s)
 static void nl80211_remove_monitor_interface(
 	struct wpa_driver_nl80211_data *drv)
 {
+	drv->monitor_refcount--;
+	if (drv->monitor_refcount > 0)
+		return;
+
 	if (drv->monitor_ifidx >= 0) {
 		nl80211_remove_iface(drv, drv->monitor_ifidx);
 		drv->monitor_ifidx = -1;
@@ -5153,6 +5158,11 @@  nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv)
 	int optval;
 	socklen_t optlen;
 
+	if (drv->monitor_ifidx > 0) {
+		drv->monitor_refcount++;
+		return 0;
+	}
+
 	if (os_strncmp(drv->first_bss.ifname, "p2p-", 4) == 0) {
 		/*
 		 * P2P interface name is of the format p2p-%s-%d. For monitor
@@ -5231,6 +5241,38 @@  nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv)
 }
 
 
+static int nl80211_setup_ap(struct i802_bss *bss)
+{
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+
+	if (!drv->device_ap_sme &&
+	    nl80211_create_monitor_interface(drv) &&
+	    !drv->device_ap_sme)
+		return -1;
+
+	if (drv->device_ap_sme &&
+	    wpa_driver_nl80211_probe_req_report(bss, 1) < 0) {
+		wpa_printf(MSG_DEBUG, "nl80211: Failed to enable "
+			   "Probe Request frame reporting in AP mode");
+		/* Try to survive without this */
+	}
+
+	return 0;
+}
+
+
+static void nl80211_teardown_ap(struct i802_bss *bss)
+{
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+
+	if (drv->device_ap_sme)
+		wpa_driver_nl80211_probe_req_report(bss, 0);
+	else
+		nl80211_remove_monitor_interface(drv);
+	bss->beacon_set = 0;
+}
+
+
 static int nl80211_send_eapol_data(struct i802_bss *bss,
 				   const u8 *addr, const u8 *data,
 				   size_t data_len)
@@ -5404,15 +5446,6 @@  static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv,
 		return -1;
 	}
 
-	if (drv->device_ap_sme) {
-		if (wpa_driver_nl80211_probe_req_report(&drv->first_bss, 1) < 0)
-		{
-			wpa_printf(MSG_DEBUG, "nl80211: Failed to enable "
-				   "Probe Request frame reporting in AP mode");
-			/* Try to survive without this */
-		}
-	}
-
 	drv->ap_oper_freq = params->freq;
 
 	return 0;
@@ -5964,33 +5997,22 @@  static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 	}
 
 done:
-	if (!ret && is_ap_interface(nlmode)) {
+	if (ret) {
+		wpa_printf(MSG_DEBUG, "nl80211: Interface mode change to %d "
+			   "from %d failed", nlmode, drv->nlmode);
+		return ret;
+	}
+
+	if (is_ap_interface(nlmode)) {
 		/* Setup additional AP mode functionality if needed */
-		if (!drv->device_ap_sme && drv->monitor_ifidx < 0 &&
-		    nl80211_create_monitor_interface(drv) &&
-		    !drv->device_ap_sme)
+		if (nl80211_setup_ap(bss))
 			return -1;
-	} else if (!ret && !is_ap_interface(nlmode)) {
+	} else if (was_ap) {
 		/* Remove additional AP mode functionality */
-		if (was_ap && drv->device_ap_sme)
-			wpa_driver_nl80211_probe_req_report(bss, 0);
-		nl80211_remove_monitor_interface(drv);
-		bss->beacon_set = 0;
-	}
-
-	if (!ret && is_p2p_interface(drv->nlmode)) {
-		nl80211_disable_11b_rates(drv, drv->ifindex, 1);
-		drv->disabled_11b_rates = 1;
-	} else if (!ret && drv->disabled_11b_rates) {
-		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
-		drv->disabled_11b_rates = 0;
+		nl80211_teardown_ap(bss);
 	}
 
-	if (ret)
-		wpa_printf(MSG_DEBUG, "nl80211: Interface mode change to %d "
-			   "from %d failed", nlmode, drv->nlmode);
-
-	return ret;
+	return 0;
 }