[PATCH v2] nl80211: Do not assume the device is rf-killed before trying to set it up

Tomasz Bursztyka tomasz.bursztyka at linux.intel.com
Mon Apr 28 07:28:58 EDT 2014


This fixes a regression which is assuming that since the general rf-kill
status is on, all devices are rf-killed. This rule is actually not true
since this rf-kill status is not per-device specific and the actual
device might not be rf-killed though users are prevented to use it due
to that logic.

The kernel knows better which device is rf-killed or not, and will check
its status properly when it tries to set it up (or "start" it for P2P).
Thus it's better to rely on the kernel's returned code as it used to be.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka at linux.intel.com>
---
 src/drivers/driver_nl80211.c | 53 ++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1300703..80b2b43 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4673,6 +4673,7 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
 	struct i802_bss *bss = drv->first_bss;
 	int send_rfkill_event = 0;
 	enum nl80211_iftype nlmode;
+	int ret;
 
 	drv->ifindex = if_nametoindex(bss->ifname);
 	bss->ifindex = drv->ifindex;
@@ -4710,41 +4711,41 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
 		return -1;
 	}
 
-	if (nlmode == NL80211_IFTYPE_P2P_DEVICE)
-		nl80211_get_macaddr(bss);
-
-	if (!rfkill_is_blocked(drv->rfkill)) {
-		int ret = i802_set_iface_flags(bss, 1);
-		if (ret) {
-			wpa_printf(MSG_ERROR, "nl80211: Could not set "
-				   "interface '%s' UP", bss->ifname);
-			return ret;
+	ret = i802_set_iface_flags(bss, 1);
+	if (ret < 0) {
+		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 %s "
+				   "interface '%s' UP",
+				   nlmode == NL80211_IFTYPE_P2P_DEVICE ?
+				   "start P2P" : "set", bss->ifname);
+			return -1;
 		}
-		if (nlmode == NL80211_IFTYPE_P2P_DEVICE)
-			return ret;
-	} else {
-		wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
-			   "interface '%s' due to rfkill", bss->ifname);
-		if (nlmode == NL80211_IFTYPE_P2P_DEVICE)
-			return 0;
-		drv->if_disabled = 1;
-		send_rfkill_event = 1;
 	}
 
-	if (!drv->hostapd)
-		netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
-				       1, IF_OPER_DORMANT);
-
-	if (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname,
-			       bss->addr))
-		return -1;
+	if (nlmode != NL80211_IFTYPE_P2P_DEVICE) {
+		if (!drv->hostapd)
+			netlink_send_oper_ifla(drv->global->netlink,
+					       drv->ifindex, 1,
+					       IF_OPER_DORMANT);
+		if (linux_get_ifhwaddr(drv->global->ioctl_sock,
+				       bss->ifname, bss->addr))
+			return -1;
+		ret = 0;
+	} else
+		nl80211_get_macaddr(bss);
 
 	if (send_rfkill_event) {
 		eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
 				       drv, drv->ctx);
 	}
 
-	return 0;
+	return ret;
 }
 
 
-- 
1.8.3.2



More information about the HostAP mailing list