[PATCH] p2p: discount current op freq

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

 



When scanning for a new connection, we currently optimize by scanning
all frequencies only when our MCC capabilities will allow an additional
operating frequency, and scan only the existing operating frequencies
otherwise. This is problematic when there the current operating
frequency singularly accounts for one of the shared radio frequencies
because we should be able to switch operating frequencies without adding
to the channel count. Fix this.

Signed-off-by: Matthew Wang <matthewmwang@xxxxxxxxxxxx>
---
 wpa_supplicant/p2p_supplicant.c   | 10 +++++-----
 wpa_supplicant/scan.c             | 11 +++++++++--
 wpa_supplicant/sme.c              |  2 +-
 wpa_supplicant/wpa_supplicant.c   | 12 +++++++++---
 wpa_supplicant/wpa_supplicant_i.h |  5 ++++-
 5 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index f6252b1aa..f9d93439d 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -188,7 +188,7 @@ static int wpas_p2p_num_unused_channels(struct wpa_supplicant *wpa_s)
 	if (!freqs)
 		return -1;
 
-	num = get_shared_radio_freqs(wpa_s, freqs,
+	num = get_shared_radio_freqs(wpa_s, freqs, 0,
 				     wpa_s->num_multichan_concurrent);
 	os_free(freqs);
 
@@ -215,7 +215,7 @@ wpas_p2p_valid_oper_freqs(struct wpa_supplicant *wpa_s,
 	if (!freqs)
 		return 0;
 
-	num = get_shared_radio_freqs_data(wpa_s, freqs,
+	num = get_shared_radio_freqs_data(wpa_s, freqs, 0,
 					  wpa_s->num_multichan_concurrent);
 
 	os_memset(p2p_freqs, 0, sizeof(struct wpa_used_freq_data) * len);
@@ -6442,7 +6442,7 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
 	if (!freqs)
 		return -1;
 
-	num = get_shared_radio_freqs_data(wpa_s, freqs,
+	num = get_shared_radio_freqs_data(wpa_s, freqs, 0,
 					  wpa_s->num_multichan_concurrent);
 
 	if (wpa_s->current_ssid &&
@@ -8292,7 +8292,7 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
 	if (!freqs)
 		return;
 
-	num = get_shared_radio_freqs_data(wpa_s, freqs, num);
+	num = get_shared_radio_freqs_data(wpa_s, freqs, 0, num);
 
 	os_memset(&chan, 0, sizeof(chan));
 	os_memset(&cli_chan, 0, sizeof(cli_chan));
@@ -9838,7 +9838,7 @@ static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx)
 	if (!freqs)
 		return;
 
-	num = get_shared_radio_freqs_data(wpa_s, freqs, num);
+	num = get_shared_radio_freqs_data(wpa_s, freqs, 0, num);
 
 	/* Previous attempt to move a GO was not possible -- try again. */
 	wpas_p2p_consider_moving_gos(wpa_s, freqs, num,
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 05913a181..ea701bbac 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -1267,7 +1267,8 @@ ssid_list_set:
 
 		params.freqs = os_calloc(num + 1, sizeof(int));
 		if (params.freqs) {
-			num = get_shared_radio_freqs(wpa_s, params.freqs, num);
+			num = get_shared_radio_freqs(wpa_s, params.freqs, 0,
+						     num);
 			if (num > 0) {
 				wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the "
 					"current operating channels since "
@@ -1357,7 +1358,13 @@ scan:
 
 		params.freqs = os_calloc(num + 1, sizeof(int));
 		if (params.freqs) {
-			num = get_shared_radio_freqs(wpa_s, params.freqs, num);
+			/*
+			 * Exclude the operating frequency of the current
+			 * interface since we're looking to transition off of
+			 * it.
+			 */
+			num = get_shared_radio_freqs(wpa_s, params.freqs,
+						     1, num);
 			if (num > 0 && num == wpa_s->num_multichan_concurrent) {
 				wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current operating channels since all channels are already used");
 			} else {
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 41b67f8eb..cfac4986a 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -895,7 +895,7 @@ no_fils:
 	 */
 	if (wpa_s->num_multichan_concurrent < 2) {
 		int freq, num;
-		num = get_shared_radio_freqs(wpa_s, &freq, 1);
+		num = get_shared_radio_freqs(wpa_s, &freq, 0, 1);
 		if (num > 0 && freq > 0 && freq != params.freq) {
 			wpa_printf(MSG_DEBUG,
 				   "Conflicting frequency found (%d != %d)",
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 761017248..12e436b01 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4128,7 +4128,7 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
 	 */
 	if (wpa_s->num_multichan_concurrent < 2) {
 		int freq, num;
-		num = get_shared_radio_freqs(wpa_s, &freq, 1);
+		num = get_shared_radio_freqs(wpa_s, &freq, 0, 1);
 		if (num > 0 && freq > 0 && freq != params.freq.freq) {
 			wpa_printf(MSG_DEBUG,
 				   "Assoc conflicting freq found (%d != %d)",
@@ -8404,6 +8404,7 @@ void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
  */
 int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
 				struct wpa_used_freq_data *freqs_data,
+				unsigned int exclude_current,
 				unsigned int len)
 {
 	struct wpa_supplicant *ifs;
@@ -8420,6 +8421,9 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
 		if (idx == len)
 			break;
 
+		if (exclude_current && ifs == wpa_s)
+			continue;
+
 		if (ifs->current_ssid == NULL || ifs->assoc_freq == 0)
 			continue;
 
@@ -8457,7 +8461,8 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
  * are using the same radio as the current interface.
  */
 int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
-			   int *freq_array, unsigned int len)
+			   int *freq_array, unsigned int exclude_current,
+			   unsigned int len)
 {
 	struct wpa_used_freq_data *freqs_data;
 	int num, i;
@@ -8468,7 +8473,8 @@ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
 	if (!freqs_data)
 		return -1;
 
-	num = get_shared_radio_freqs_data(wpa_s, freqs_data, len);
+	num = get_shared_radio_freqs_data(wpa_s, freqs_data, exclude_current,
+					  len);
 	for (i = 0; i < num; i++)
 		freq_array[i] = freqs_data[i].freq;
 
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 813e5ac1b..c3d74e81c 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1850,11 +1850,14 @@ void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
 		    struct wpa_used_freq_data *freqs_data,
 		    unsigned int len);
 
+int get_op_freq(struct wpa_supplicant *wpa_s);
 int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
 				struct wpa_used_freq_data *freqs_data,
+				unsigned int exclude_current,
 				unsigned int len);
 int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
-			   int *freq_array, unsigned int len);
+			   int *freq_array, unsigned int exclude_current,
+			   unsigned int len);
 
 void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx);
 
-- 
2.38.1.431.g37b22c650d-goog


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux