Patchwork Fail p2p_group_add if freq= param is specified and if we are already running legacy STA on a different freq

login
register
mail settings
Submitter Neeraj Garg
Date Dec. 27, 2011, 5:38 a.m.
Message ID <2C2F1EBA8050E74EA81502D5740B4BD6BBBCDE6801@SJEXCHCCR02.corp.ad.broadcom.com>
Download mbox | patch
Permalink /patch/133296/
State Accepted
Commit b8349523e460493fa0b4de36c689595109e45e91
Headers show

Comments

Neeraj Garg - Dec. 27, 2011, 5:38 a.m.
This patch will ensure that if p2p_group_add freq=xxxx is given, then we need to fail it if STA is already associated on a different frequency. Same code already exists in the path of p2p connection with go negotiation but is missing for autonomous GO. Please check if patch is OK.

Signed-hostap: Neeraj Garg <neerajkg@broadcom.com>
---
 wpa_supplicant/p2p_supplicant.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 wpa_supplicant/p2p_supplicant.c
Jouni Malinen - Dec. 27, 2011, 9:24 p.m.
On Mon, Dec 26, 2011 at 09:38:42PM -0800, Neeraj Kumar Garg wrote:
> This patch will ensure that if p2p_group_add freq=xxxx is given, then we need to fail it if STA is already associated on a different frequency. Same code already exists in the path of p2p connection with go negotiation but is missing for autonomous GO. Please check if patch is OK.

Thanks, applied.

Patch

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
old mode 100644
new mode 100755
index 5ff94ef..ca0cb98
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3005,7 +3005,7 @@  int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s, const char *ifname)
 }
 
 
-static void wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
+static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
 				    struct p2p_go_neg_results *params,
 				    int freq)
 {
@@ -3064,11 +3064,21 @@  static void wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
 	}
 
 	res = wpa_drv_shared_freq(wpa_s);
-	if (res > 0 && !freq) {
-		wpa_printf(MSG_DEBUG, "P2P: Force GO on the channel we are "
-			   "already using on a shared interface");
-		params->freq = res;
+	if (res > 0) {
+		if (!freq) {
+			wpa_printf(MSG_DEBUG, "P2P: Force GO on the channel we are "
+				   "already using on a shared interface");
+			params->freq = res;
+		}
+		else if ((freq != res) && !(wpa_s->drv_flags &
+			WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT)) {
+			wpa_printf(MSG_DEBUG, "P2P: Cannot start P2P group "
+				   "on %u MHz while connected on another "
+				   "channel (%u MHz)", freq, res);
+			return -1;
+		}
 	}
+	return 0;
 }
 
 
@@ -3163,7 +3173,8 @@  int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
 		return -1;
 	}
 
-	wpas_p2p_init_go_params(wpa_s, &params, freq);
+	if (wpas_p2p_init_go_params(wpa_s, &params, freq))
+		return -1;
 	p2p_go_params(wpa_s->global->p2p, &params);
 	params.persistent_group = persistent_group;
 
@@ -3246,7 +3257,8 @@  int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
 	if (ssid->mode != WPAS_MODE_P2P_GO)
 		return -1;
 
-	wpas_p2p_init_go_params(wpa_s, &params, freq);
+	if (wpas_p2p_init_go_params(wpa_s, &params, freq))
+		return -1;
 
 	params.role_go = 1;
 	if (ssid->passphrase == NULL ||