Don't do broadcast SSID scans, if all configured SSIDs use scan_ssid=1. Improves background scanning in supplicant-managed roaming.

--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -73,6 +73,7 @@ static void wpa_supplicant_scan(void *el
 	struct wpabuf *wps_ie = NULL;
 	const u8 *extra_ie = NULL;
 	size_t extra_ie_len = 0;
+	int scan_ssid_all = 1;
 	int wps = 0;
 #ifdef CONFIG_WPS
 	enum wps_request_type req_type = WPS_REQ_ENROLLEE_INFO;
@@ -82,6 +83,17 @@ static void wpa_supplicant_scan(void *el
 		return;
 
 	enabled = 0;
+
+	/* check if all configured ssids should be scanned directly */
+	ssid = wpa_s->conf->ssid;
+	while (ssid) {
+		if (!ssid->scan_ssid) {
+			scan_ssid_all = 0;
+			break;
+		}
+		ssid = ssid->next;
+	}
+
 	ssid = wpa_s->conf->ssid;
 	while (ssid) {
 		if (!ssid->disabled) {
@@ -154,6 +166,10 @@ static void wpa_supplicant_scan(void *el
 		return;
 	}
 
+	if (scan_ssid_all && !ssid) {
+		ssid = wpa_s->conf->ssid;
+	}
+
 	wpa_printf(MSG_DEBUG, "Starting AP scan (%s SSID)",
 		   ssid ? "specific": "broadcast");
 	if (ssid) {
