[PATCH 3/3] P2P: p2p connect request return fail for single p2p-interface if already connected

Jouni Malinen j
Wed Aug 5 03:00:06 PDT 2015

On Wed, Aug 05, 2015 at 08:36:24AM +0000, Avichal Agarwal wrote:
> This patch works only for single  p2p interface (which act as GC and GO) whose state is already completed

The concept of rejecting some P2P_CONNECT commands in this type of state
sound fine, but this patch would require work to be acceptable way of
doing that.

> diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
> @@ -4986,6 +4986,12 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
>  	if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
>  		return -1;

Just like the previous patches, this should not depend on build time
define. In other words, wpa_supplicant already knows whether the driver
is capable of starting a concurrent group.

> +	if(wpa_s->wpa_state == WPA_COMPLETED) {
> +		wpa_printf(MSG_INFO, "P2P: Already connected \n");
> +		return -1;
> +	}

I don't think wpa_state == WPA_COMPLETED is ideal way of doing this.
The interface may be running a P2P group and be in other states while
this new command is issued. Something like "if
(!wpas_p2p_create_iface(wpa_s!) && wpa_s->current_ssid &&
wpa_s->current_ssid->p2p_group)" might work for this need.

Please also note that some wpas_p2p_connect() operations should still be
allowed even if there is a group (e.g., "P2P_CONNECT <addr> ... auth"
which is just marking a peer authorized to start group formation
without actually starting any new group at the point this command is

Jouni Malinen                                            PGP id EFC895FA

More information about the Hostap mailing list