diff mbox

[1/3] P2P: Handle rfkill for P2P Device interface

Message ID 1450360452-6116-1-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Peer, Ilan Dec. 17, 2015, 1:54 p.m. UTC
The RFKILL processing in nl80211 driver assumes that the
INTERFACE_ENABLED/DISABLED will be also issued, so does not
do much in the rfkill callbacks. However, as a P2P Device
interface is not associated with a network interface, these
events are not issued for it.

Handle rfkill events for the P2P_DEVICE interface by faking
the INTERFACE_ENABLED/DISABLED.

Signed-off-by: Moshe Benji <Moshe.Benji@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 src/drivers/driver_nl80211.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

Comments

Jouni Malinen Dec. 18, 2015, 8:33 p.m. UTC | #1
Thanks, all three applied. Though, I had to do some changes to the hwsim
test cases to avoid race conditions with trying operations before the
rfkill changes had taken effect. This also converted the fixed one
second sleep to a shorter wait if the interface state changed sooner.
Peer, Ilan Dec. 20, 2015, 8:51 a.m. UTC | #2
> -----Original Message-----
> From: Jouni Malinen [mailto:j@w1.fi]
> Sent: Friday, December 18, 2015 22:33
> To: Peer, Ilan
> Cc: hostap@lists.infradead.org
> Subject: Re: [PATCH 1/3] P2P: Handle rfkill for P2P Device interface
> 
> Thanks, all three applied. Though, I had to do some changes to the hwsim test
> cases to avoid race conditions with trying operations before the rfkill changes
> had taken effect. This also converted the fixed one second sleep to a shorter
> wait if the interface state changed sooner.
> 
> --
> Jouni Malinen                                            PGP id EFC895FA

Great. 10x.

Ilan.
diff mbox

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 0fd836b..a2d1639 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1520,11 +1520,15 @@  static void nl80211_check_global(struct nl80211_global *global)
 
 static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
 {
+	struct wpa_driver_nl80211_data *drv = ctx;
 	wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
+
 	/*
-	 * This may be for any interface; use ifdown event to disable
-	 * interface.
+	 * rtnetlink ifdown handler will report interfaces other than the P2P
+	 * Device interface as disabled.
 	 */
+	if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
+		wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED, NULL);
 }
 
 
@@ -1541,7 +1545,12 @@  static void wpa_driver_nl80211_rfkill_unblocked(void *ctx)
 	if (is_p2p_net_interface(drv->nlmode))
 		nl80211_disable_11b_rates(drv, drv->ifindex, 1);
 
-	/* rtnetlink ifup handler will report interface as enabled */
+	/*
+	 * rtnetlink ifup handler will report interfaces other than the P2P
+	 * Device interface as enabled.
+	 */
+	if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
+		wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED, NULL);
 }
 
 
@@ -2241,19 +2250,21 @@  wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
 	} 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;
+		if (nlmode != NL80211_IFTYPE_P2P_DEVICE)
+			drv->if_disabled = 1;
+
 		send_rfkill_event = 1;
 	}
 
-	if (!drv->hostapd)
+	if (!drv->hostapd && nlmode != NL80211_IFTYPE_P2P_DEVICE)
 		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 (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname,
+				       bss->addr))
+			return -1;
+
 	os_memcpy(drv->perm_addr, bss->addr, ETH_ALEN);
 
 	if (send_rfkill_event) {