Patchwork [v3] nl80211: Driver capability retrieval only once the interface is UP

login
register
mail settings
Submitter Sreenath
Date Aug. 6, 2013, 6:42 a.m.
Message ID <20130806064258.GA14505@sreenath-Precision-M4700>
Download mbox | patch
Permalink /patch/264880/
State Rejected
Headers show

Comments

Sreenath - Aug. 6, 2013, 6:42 a.m.
The main intention of this patch is to retrieve driver capabilities only
once the interface is UP, similar to the older approach before P2P_DEVICE
integration. This approach will help devices which can retrieve the
capabilities from firmware only once the interface is UP.

v3: Applied v2 changes on top of v1
v2: Fixed hostapd compilation issue

Please discard v2 and v1 patches.

Signed-hostap: Sreenath Sharma <sreenats@broadcom.com>
---
 src/drivers/driver_nl80211.c |   44 +++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 20 deletions(-)
Johannes Berg - Aug. 6, 2013, 6:54 a.m.
On Tue, 2013-08-06 at 12:12 +0530, Sreenath Sharma wrote:
> The main intention of this patch is to retrieve driver capabilities only
> once the interface is UP, similar to the older approach before P2P_DEVICE
> integration. This approach will help devices which can retrieve the
> capabilities from firmware only once the interface is UP.

Which driver has a problem with this? cfg80211/nl80211 is not intended
to be used in a way that defers the capability advertisement after the
interface is UP, the advertised values are expected to be correct before
the interface is up. As such, I don't see how with a properly written
driver this patch can be required.

johannes
Sreenath - Aug. 6, 2013, 7:21 a.m.
Hello Johannes,

What you have told is correct and this is not a mandatory patch. I just felt it is logical to do interface UP before capability retrieval, similar to the older approach before P2P_DEVICE integration.

Regards,
Sreenath
Jouni Malinen - Aug. 7, 2013, 8:13 a.m.
On Tue, Aug 06, 2013 at 07:21:05AM +0000, Sreenath S wrote:
> What you have told is correct and this is not a mandatory patch. I just felt it is logical to do interface UP before capability retrieval, similar to the older approach before P2P_DEVICE integration.

If there is no real need for this, I would rather drop this. It does
not look good to move setting of the interface up to happen before the
nl80211_set_mode operation.

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index e674d9d..06e5b4f 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4011,6 +4011,30 @@  wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 	dynamic_if = dynamic_if || drv->global->if_add_wdevid_set;
 	drv->global->if_add_wdevid_set = 0;
 
+#ifndef HOSTAPD
+	if (dynamic_if)
+		nlmode = nl80211_get_ifmode(bss);
+
+	if (nlmode != NL80211_IFTYPE_P2P_DEVICE) {
+		if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
+			if (rfkill_is_blocked(drv->rfkill)) {
+				wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
+					   "interface '%s' due to rfkill",
+					   bss->ifname);
+				drv->if_disabled = 1;
+				send_rfkill_event = 1;
+			} else {
+				wpa_printf(MSG_ERROR, "nl80211: Could not set "
+					   "interface '%s' UP", bss->ifname);
+				return -1;
+			}
+		}
+
+		netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
+					       1, IF_OPER_DORMANT);
+	}
+#endif /* HOSTAPD */
+
 	if (wpa_driver_nl80211_capa(drv))
 		return -1;
 
@@ -4018,9 +4042,6 @@  wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 		   bss->ifname, drv->phyname);
 
 #ifndef HOSTAPD
-	if (dynamic_if)
-		nlmode = nl80211_get_ifmode(bss);
-
 	/*
 	 * Make sure the interface starts up in station mode unless this is a
 	 * dynamically added interface (e.g., P2P) that was already configured
@@ -4039,23 +4060,6 @@  wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 		nl80211_get_macaddr(bss);
 		return ret;
 	}
-
-	if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
-		if (rfkill_is_blocked(drv->rfkill)) {
-			wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
-				   "interface '%s' due to rfkill",
-				   bss->ifname);
-			drv->if_disabled = 1;
-			send_rfkill_event = 1;
-		} else {
-			wpa_printf(MSG_ERROR, "nl80211: Could not set "
-				   "interface '%s' UP", bss->ifname);
-			return -1;
-		}
-	}
-
-	netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
-			       1, IF_OPER_DORMANT);
 #endif /* HOSTAPD */
 
 	if (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname,