PERFORCE change 137291 for review

Sam Leffler sam at FreeBSD.org
Mon Mar 10 05:31:06 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137291

Change 137291 by sam at sam_ebb on 2008/03/10 05:30:25

	Optimize re-association to the same ap (e.g. after a deauth due
	to inactivity).  Track the ssid of the last ap we associated to
	and if a scan request is made supply this ssid and request the
	scan cache be checked before kicking off a full scan.  If the
	cache valid setting is raised to keep the contents valid from
	background scans then we'll hit in the cache and immediately
	reassociate w/o a scan.  Clear the ssid on deauth/disasoc and
	after we use this trick so we don't get into a loop.

Affected files ...

.. //depot/projects/vap/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c#6 edit

Differences ...

==== //depot/projects/vap/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c#6 (text+ko) ====

@@ -43,6 +43,8 @@
 	int	prev_roaming;		/* roaming state to restore on deinit */
 	int	prev_privacy;		/* privacy state to restore on deinit */
 	int	prev_wpa;		/* wpa state to restore on deinit */
+	uint8_t	lastssid[IEEE80211_NWID_LEN];
+	int	lastssid_len;
 };
 
 static int
@@ -360,6 +362,8 @@
 	struct wpa_driver_bsd_data *drv = priv;
 	struct ieee80211req_mlme mlme;
 
+	drv->lastssid_len = 0;
+
 	wpa_printf(MSG_DEBUG, "%s", __func__);
 	memset(&mlme, 0, sizeof(mlme));
 	mlme.im_op = IEEE80211_MLME_DEAUTH;
@@ -374,6 +378,8 @@
 	struct wpa_driver_bsd_data *drv = priv;
 	struct ieee80211req_mlme mlme;
 
+	drv->lastssid_len = 0;
+
 	wpa_printf(MSG_DEBUG, "%s", __func__);
 	memset(&mlme, 0, sizeof(mlme));
 	mlme.im_op = IEEE80211_MLME_DISASSOC;
@@ -426,6 +432,8 @@
 		memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN);
 	if (set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme)) < 0)
 		return -1;
+	memcpy(drv->lastssid, params->ssid, params->ssid_len);
+	drv->lastssid_len = params->ssid_len;
 	return 0;
 }
 
@@ -471,18 +479,35 @@
 	memset(&sr, 0, sizeof(sr));
 	sr.sr_flags = IEEE80211_IOC_SCAN_ACTIVE
 		    | IEEE80211_IOC_SCAN_ONCE
-		    | IEEE80211_IOC_SCAN_NOPICK
-		    /*
-		     * NB: caller specifies bcast ssid, so suppress
-		     *     net80211's normal handling
-		     */
-		    | IEEE80211_IOC_SCAN_NOBCAST
 		    ;
 	sr.sr_duration = IEEE80211_IOC_SCAN_FOREVER;
-	sr.sr_nssid = 1;
-	/* XXX ssid_len must be <= IEEE80211_NWID_LEN */
-	memcpy(sr.sr_ssid[0].ssid, ssid, ssid_len);
-	sr.sr_ssid[0].len = ssid_len;
+	if (ssid_len != 0) {
+		/* XXX ssid_len must be <= IEEE80211_NWID_LEN */
+		memcpy(sr.sr_ssid[sr.sr_nssid].ssid, ssid, ssid_len);
+		sr.sr_ssid[sr.sr_nssid].len = ssid_len;
+		sr.sr_nssid++;
+	}
+	if (drv->lastssid_len != 0 &&
+	    (drv->lastssid_len != ssid_len ||
+	     memcmp(drv->lastssid, ssid, ssid_len) != 0)) {
+		/*
+		 * If we are scanning because we received a deauth
+		 * and the scan cache is warm then we'll find the
+		 * ap there and short circuit a full-blown scan.
+		 */
+		memcpy(sr.sr_ssid[sr.sr_nssid].ssid, drv->lastssid,
+		    drv->lastssid_len);
+		sr.sr_ssid[sr.sr_nssid].len = drv->lastssid_len;
+		sr.sr_nssid++;
+		/* NB: clear so we don't retry w/o associating first */
+		drv->lastssid_len = 0;
+	}
+	if (sr.sr_nssid != 0) {		/* NB: check scan cache first */
+		sr.sr_flags |= IEEE80211_IOC_SCAN_CHECK
+			    |  IEEE80211_IOC_SCAN_NOJOIN
+			    ;
+	} else
+		sr.sr_flags |= IEEE80211_IOC_SCAN_NOPICK;
 
 	/* NB: net80211 delivers a scan complete event so no need to poll */
 	return set80211var(drv, IEEE80211_IOC_SCAN_REQ, &sr, sizeof(sr));


More information about the p4-projects mailing list