P2P: optimize join scan freq
If the auto GO has been discovered on another interface, optimize scan
frequency by performing a single channel scan first.
Bug: 233925359
Test: Configured auto GO using the WifiP2pTest app, used wifi picker to
discover the GO on client device, enabled client on WifiP2PTest app and
looked at logs to confirm that only operating freq was scanned
Change-Id: Iff9b67093647b829cc00a4afbb1f016a3a6de37b
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index a3da86c..dcc28be 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -240,7 +240,7 @@
/**
* wpa_bss_get - Fetch a BSS table entry based on BSSID and SSID
* @wpa_s: Pointer to wpa_supplicant data
- * @bssid: BSSID
+ * @bssid: BSSID, or %NULL to match any BSSID
* @ssid: SSID
* @ssid_len: Length of @ssid
* Returns: Pointer to the BSS entry or %NULL if not found
@@ -252,7 +252,8 @@
if (!wpa_supplicant_filter_bssid_match(wpa_s, bssid))
return NULL;
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
- if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
+ if ((!bssid ||
+ os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0) &&
bss->ssid_len == ssid_len &&
os_memcmp(bss->ssid, ssid, ssid_len) == 0)
return bss;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 0d59b79..00493d0 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -7014,6 +7014,11 @@
if (params->passphrase)
ssid->passphrase = os_strdup(params->passphrase);
+ if (params->bssid_set) {
+ ssid->bssid_set = 1;
+ os_memcpy(ssid->bssid, params->bssid, ETH_ALEN);
+ }
+
wpa_s->show_group_started = 1;
wpa_s->p2p_in_invitation = 1;
wpa_s->p2p_retry_limit = retry_limit;
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 57f5747..bfcb62b 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -444,10 +444,35 @@
if (params->freqs == NULL && wpa_s->p2p_in_invitation) {
/*
+ * Perform a single-channel scan if the GO has already been
+ * discovered on another non-P2P interface. Note that a scan
+ * initiated by a P2P interface (e.g. the device interface)
+ * should already have sufficient IEs and scan results will be
+ * fetched on interface creation in that case.
+ */
+ if (wpa_s->p2p_in_invitation == 1 && wpa_s->current_ssid) {
+ struct wpa_supplicant *ifs;
+ struct wpa_bss *bss = NULL;
+ struct wpa_ssid *ssid = wpa_s->current_ssid;
+ u8 *bssid = ssid->bssid_set ? ssid->bssid : NULL;
+ dl_list_for_each(ifs, &wpa_s->radio->ifaces,
+ struct wpa_supplicant, radio_list) {
+ bss = wpa_bss_get(ifs, bssid, ssid->ssid,
+ ssid->ssid_len);
+ if (bss)
+ break;
+ }
+ if (bss && !disabled_freq(wpa_s, bss->freq)) {
+ params->freqs = os_calloc(2, sizeof(int));
+ if (params->freqs)
+ params->freqs[0] = bss->freq;
+ }
+ }
+ /*
* Optimize scan based on GO information during persistent
* group reinvocation
*/
- if (wpa_s->p2p_in_invitation < 5 &&
+ if (params->freqs == NULL && wpa_s->p2p_in_invitation < 5 &&
wpa_s->p2p_invite_go_freq > 0) {
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO preferred frequency %d MHz during invitation",
wpa_s->p2p_invite_go_freq);