tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wpa_supplicant / hostap changes



Hi List

wpa_supplicant and hostap love to take an interface down, make changes and then bring it up when ready to go.

Now, the Linux nl80211 stack doesn't seem to need this and from what I can tell, neither does ours. Certainly from the wpa_supplicant side.

Sadly, all 3 of my NetBSD supported wifi devices don't do HostAP mode, so I can't test that part of it. I have tested urtwm, iwi and iwn. Does anyhave have any others, preferably hostap capable and test this patch please?

It's important for up-coming dhcpcd support for anonymous profiles.

Thanks

Roy
Index: src/drivers/driver_bsd.c
===================================================================
RCS file: /cvsroot/src/external/bsd/wpa/dist/src/drivers/driver_bsd.c,v
retrieving revision 1.30
diff -u -p -r1.30 driver_bsd.c
--- src/drivers/driver_bsd.c	10 Apr 2019 17:48:07 -0000	1.30
+++ src/drivers/driver_bsd.c	25 Jan 2020 19:35:53 -0000
@@ -340,7 +340,7 @@ bsd_send_mlme_param(void *priv, const u8
 }
 
 static int
-bsd_ctrl_iface(void *priv, int enable)
+bsd_get_iface_flags(void *priv)
 {
 	struct bsd_driver_data *drv = priv;
 	struct ifreq ifr;
@@ -354,24 +354,6 @@ bsd_ctrl_iface(void *priv, int enable)
 		return -1;
 	}
 	drv->flags = ifr.ifr_flags;
-
-	if (enable) {
-		if (ifr.ifr_flags & IFF_UP)
-			return 0;
-		ifr.ifr_flags |= IFF_UP;
-	} else {
-		if (!(ifr.ifr_flags & IFF_UP))
-			return 0;
-		ifr.ifr_flags &= ~IFF_UP;
-	}
-
-	if (ioctl(drv->global->sock, SIOCSIFFLAGS, &ifr) < 0) {
-		wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
-			   strerror(errno));
-		return -1;
-	}
-
-	drv->flags = ifr.ifr_flags;
 	return 0;
 }
 
@@ -585,7 +567,7 @@ bsd_set_ieee8021x(void *priv, struct wpa
 			   __func__);
 		return -1;
 	}
-	return bsd_ctrl_iface(priv, 1);
+	return 0;
 }
 
 static void
@@ -908,8 +890,7 @@ bsd_init(struct hostapd_data *hapd, stru
 	if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
 		goto bad;
 
-	/* mark down during setup */
-	if (bsd_ctrl_iface(drv, 0) < 0)
+	if (bsd_get_iface_flags(drv) < 0)
 		goto bad;
 
 	if (bsd_set_mediaopt(drv, IFM_OMASK, IFM_IEEE80211_HOSTAP) < 0) {
@@ -934,8 +915,6 @@ bsd_deinit(void *priv)
 {
 	struct bsd_driver_data *drv = priv;
 
-	if (drv->ifindex != 0)
-		bsd_ctrl_iface(drv, 0);
 	if (drv->sock_xmit != NULL)
 		l2_packet_deinit(drv->sock_xmit);
 	os_free(drv);
@@ -943,13 +922,6 @@ bsd_deinit(void *priv)
 
 
 static int
-bsd_commit(void *priv)
-{
-	return bsd_ctrl_iface(priv, 1);
-}
-
-
-static int
 bsd_set_sta_authorized(void *priv, const u8 *addr,
 		       unsigned int total_flags, unsigned int flags_or,
 		       unsigned int flags_and)
@@ -1201,9 +1173,13 @@ wpa_driver_bsd_scan(void *priv, struct w
 		return -1;
 	}
 
-	/* NB: interface must be marked UP to do a scan */
-	if (bsd_ctrl_iface(drv, 1) < 0)
+	/* NB: interface must be marked UP to do a scan
+	 * BUT it's not our job to bring the interface up */
+	if (!(drv->flags & IFF_UP)) {
+		wpa_printf(MSG_DEBUG, "%s: interface is not up, aborting scan",
+			   __func__);
 		return -1;
+	}
 
 #ifdef IEEE80211_IOC_SCAN_MAX_SSID
 	os_memset(&sr, 0, sizeof(sr));
@@ -1643,8 +1619,7 @@ wpa_driver_bsd_init(void *ctx, const cha
 	if (wpa_driver_bsd_capa(drv))
 		goto fail;
 
-	/* Down interface during setup. */
-	if (bsd_ctrl_iface(drv, 0) < 0)
+	if (bsd_get_iface_flags(drv) < 0)
 		goto fail;
 
 	drv->opmode = get80211opmode(drv);
@@ -1665,11 +1640,11 @@ wpa_driver_bsd_deinit(void *priv)
 	if (drv->ifindex != 0 && !drv->if_removed) {
 		wpa_driver_bsd_set_wpa(drv, 0);
 
-		/* NB: mark interface down */
-		bsd_ctrl_iface(drv, 0);
-
-		wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
-						drv->prev_privacy);
+		if (wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
+						    drv->prev_privacy) < 0)
+			wpa_printf(MSG_DEBUG,
+				   "%s: failed to restore privacy state",
+				   __func__);
 
 		if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)
 		    < 0)
@@ -1781,7 +1756,6 @@ const struct wpa_driver_ops wpa_driver_b
 	.sta_disassoc		= bsd_sta_disassoc,
 	.sta_deauth		= bsd_sta_deauth,
 	.sta_set_flags		= bsd_set_sta_authorized,
-	.commit			= bsd_commit,
 #else /* HOSTAPD */
 	.init2			= wpa_driver_bsd_init,
 	.deinit			= wpa_driver_bsd_deinit,


Home | Main Index | Thread Index | Old Index