Patchwork STA: Fix AP connection drop issue when starting P2P scanning

login
register
mail settings
Submitter 赵兵
Date Aug. 13, 2013, 12:56 p.m.
Message ID <B493880046B15940B55B6737AA477C7D3F294BE0@EX-MBOX1.xiaomi.net>
Download mbox | patch
Permalink /patch/266791/
State Rejected
Headers show

Comments

赵兵 - Aug. 13, 2013, 12:56 p.m.
On Android, there is an issue of STA dropping from AP when P2P scanning.
Following is the reproduce steps:
1. Close WiFi
2. Open WiFi and wait for connecting to a saved AP
3. When AP connected, go into WiFi direct screen immediately
4. Wait for P2P scan for a while, the connection with AP will drop

The reproduce rate is almost 100%. The root cause is wpas_p2p_scan()
possibly triggers an AP scan if sta_scan_pending is set. At this time,
scan_req is 0 and ap_scan is 2. So wpa_supplicant_assoc_try() will be
invoked from wpa_supplicant_scan(). It disassoc current AP.

Signed-off-by: zhaobing <zhaobing@xiaomi.com>

---
wpa_supplicant/scan.c |    3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

-- 
1.7.9.5


Best regards,

Zhao Bing (赵兵)
861060606666-5023
13693622077
MiTalk: 39682852
北京市海淀区清河中街68号 华润五彩城
The Rainbow City of China Resources ,NO.68,Qinghe Middle Street,Haidian District,Beijing,China
Dmitry Shmidt - Aug. 19, 2013, 10:54 p.m.
On Tue, Aug 13, 2013 at 5:56 AM, 赵兵 <zhaobing@xiaomi.com> wrote:
> On Android, there is an issue of STA dropping from AP when P2P scanning.
> Following is the reproduce steps:
> 1. Close WiFi
> 2. Open WiFi and wait for connecting to a saved AP
> 3. When AP connected, go into WiFi direct screen immediately
> 4. Wait for P2P scan for a while, the connection with AP will drop
>
> The reproduce rate is almost 100%. The root cause is wpas_p2p_scan()
> possibly triggers an AP scan if sta_scan_pending is set. At this time,
> scan_req is 0 and ap_scan is 2. So wpa_supplicant_assoc_try() will be
> invoked from wpa_supplicant_scan(). It disassoc current AP.

Despite it can be correct statement, I feel like the problem is that
ap_scan == 2.
We changed this functionality on Android long time ago introducing
SCAN TYPE=ONLY
command. So Wifi manager is not setting ap_scan to 2 anymore.

>
> Signed-off-by: zhaobing <zhaobing@xiaomi.com>
> ---
> wpa_supplicant/scan.c |    3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
> index e662713..eb8e7d7 100644
> --- a/wpa_supplicant/scan.c
> +++ b/wpa_supplicant/scan.c
> @@ -668,7 +668,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
>                 }
>        }
>
> -        if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2) {
> +       if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2 &&
> +          wpa_s->current_ssid == NULL) {
>                 wpa_s->connect_without_scan = NULL;
>                 wpa_s->prev_scan_wildcard = 0;
>                 wpa_supplicant_assoc_try(wpa_s, ssid);
> --
> 1.7.9.5
>
>
> Best regards,
>
> Zhao Bing (赵兵)
> 861060606666-5023
> 13693622077
> MiTalk: 39682852
> 北京市海淀区清河中街68号 华润五彩城
> The Rainbow City of China Resources ,NO.68,Qinghe Middle Street,Haidian District,Beijing,China
>
赵兵 - Aug. 22, 2013, 1:57 a.m.
Hi Dmitry Shmidt,

Thanks for your reply. I got all patches from Android 4.3 which you mentioned. Is there any potential risk of merging them back to Android 4.2?

Best regards,

Zhao Bing (赵兵)
861060606666-5023
13693622077
MiTalk: 39682852
北京市海淀区清河中街68号 华润五彩城
The Rainbow City of China Resources ,NO.68,Qinghe Middle Street,Haidian District,Beijing,China

-----邮件原件-----
发件人: Dmitry Shmidt [mailto:dimitrysh@google.com] 
发送时间: 2013年8月20日 6:54
收件人: 赵兵
抄送: j@w1.fi; hostap@lists.shmoo.com
主题: Re: [PATCH] STA: Fix AP connection drop issue when starting P2P scanning

On Tue, Aug 13, 2013 at 5:56 AM, 赵兵 <zhaobing@xiaomi.com> wrote:
> On Android, there is an issue of STA dropping from AP when P2P scanning.

> Following is the reproduce steps:

> 1. Close WiFi

> 2. Open WiFi and wait for connecting to a saved AP 3. When AP 

> connected, go into WiFi direct screen immediately 4. Wait for P2P scan 

> for a while, the connection with AP will drop

>

> The reproduce rate is almost 100%. The root cause is wpas_p2p_scan() 

> possibly triggers an AP scan if sta_scan_pending is set. At this time, 

> scan_req is 0 and ap_scan is 2. So wpa_supplicant_assoc_try() will be 

> invoked from wpa_supplicant_scan(). It disassoc current AP.


Despite it can be correct statement, I feel like the problem is that ap_scan == 2.
We changed this functionality on Android long time ago introducing SCAN TYPE=ONLY command. So Wifi manager is not setting ap_scan to 2 anymore.

>

> Signed-off-by: zhaobing <zhaobing@xiaomi.com>

> ---

> wpa_supplicant/scan.c |    3 ++-

> 1 file changed, 2 insertions(+), 1 deletion(-)

>

> diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 

> e662713..eb8e7d7 100644

> --- a/wpa_supplicant/scan.c

> +++ b/wpa_supplicant/scan.c

> @@ -668,7 +668,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)

>                 }

>        }

>

> -        if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2) {

> +       if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2 &&

> +          wpa_s->current_ssid == NULL) {

>                 wpa_s->connect_without_scan = NULL;

>                 wpa_s->prev_scan_wildcard = 0;

>                 wpa_supplicant_assoc_try(wpa_s, ssid);

> --

> 1.7.9.5

>

>

> Best regards,

>

> Zhao Bing (赵兵)

> 861060606666-5023

> 13693622077

> MiTalk: 39682852

> 北京市海淀区清河中街68号 华润五彩城

> The Rainbow City of China Resources ,NO.68,Qinghe Middle 

> Street,Haidian District,Beijing,China

>
Dmitry Shmidt - Aug. 22, 2013, 3 a.m.
On Wed, Aug 21, 2013 at 6:57 PM, 赵兵 <zhaobing@xiaomi.com> wrote:
> Hi Dmitry Shmidt,
>
> Thanks for your reply. I got all patches from Android 4.3 which you mentioned. Is there any potential risk of merging them back to Android 4.2?

You need to be specific about what patches are you talking about.
Usually it is always potential risk of cherry-picking patches from
newer version to old one.

>
> Best regards,
>
> Zhao Bing (赵兵)
> 861060606666-5023
> 13693622077
> MiTalk: 39682852
> 北京市海淀区清河中街68号 华润五彩城
> The Rainbow City of China Resources ,NO.68,Qinghe Middle Street,Haidian District,Beijing,China
>
> -----邮件原件-----
> 发件人: Dmitry Shmidt [mailto:dimitrysh@google.com]
> 发送时间: 2013年8月20日 6:54
> 收件人: 赵兵
> 抄送: j@w1.fi; hostap@lists.shmoo.com
> 主题: Re: [PATCH] STA: Fix AP connection drop issue when starting P2P scanning
>
> On Tue, Aug 13, 2013 at 5:56 AM, 赵兵 <zhaobing@xiaomi.com> wrote:
>> On Android, there is an issue of STA dropping from AP when P2P scanning.
>> Following is the reproduce steps:
>> 1. Close WiFi
>> 2. Open WiFi and wait for connecting to a saved AP 3. When AP
>> connected, go into WiFi direct screen immediately 4. Wait for P2P scan
>> for a while, the connection with AP will drop
>>
>> The reproduce rate is almost 100%. The root cause is wpas_p2p_scan()
>> possibly triggers an AP scan if sta_scan_pending is set. At this time,
>> scan_req is 0 and ap_scan is 2. So wpa_supplicant_assoc_try() will be
>> invoked from wpa_supplicant_scan(). It disassoc current AP.
>
> Despite it can be correct statement, I feel like the problem is that ap_scan == 2.
> We changed this functionality on Android long time ago introducing SCAN TYPE=ONLY command. So Wifi manager is not setting ap_scan to 2 anymore.
>
>>
>> Signed-off-by: zhaobing <zhaobing@xiaomi.com>
>> ---
>> wpa_supplicant/scan.c |    3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index
>> e662713..eb8e7d7 100644
>> --- a/wpa_supplicant/scan.c
>> +++ b/wpa_supplicant/scan.c
>> @@ -668,7 +668,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
>>                 }
>>        }
>>
>> -        if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2) {
>> +       if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2 &&
>> +          wpa_s->current_ssid == NULL) {
>>                 wpa_s->connect_without_scan = NULL;
>>                 wpa_s->prev_scan_wildcard = 0;
>>                 wpa_supplicant_assoc_try(wpa_s, ssid);
>> --
>> 1.7.9.5
>>
>>
>> Best regards,
>>
>> Zhao Bing (赵兵)
>> 861060606666-5023
>> 13693622077
>> MiTalk: 39682852
>> 北京市海淀区清河中街68号 华润五彩城
>> The Rainbow City of China Resources ,NO.68,Qinghe Middle
>> Street,Haidian District,Beijing,China
>>
Jouni Malinen - Aug. 25, 2013, 6:44 a.m.
On Tue, Aug 13, 2013 at 12:56:14PM +0000, 赵兵 wrote:
> On Android, there is an issue of STA dropping from AP when P2P scanning.
> Following is the reproduce steps:
> 1. Close WiFi
> 2. Open WiFi and wait for connecting to a saved AP
> 3. When AP connected, go into WiFi direct screen immediately
> 4. Wait for P2P scan for a while, the connection with AP will drop
> 
> The reproduce rate is almost 100%. The root cause is wpas_p2p_scan()
> possibly triggers an AP scan if sta_scan_pending is set. At this time,
> scan_req is 0 and ap_scan is 2. So wpa_supplicant_assoc_try() will be
> invoked from wpa_supplicant_scan(). It disassoc current AP.

I think the root cause would actually be in using ap_scan=2 for
something that it was not meant for. The proper fix is to stop doing
that (which has now happened). As such, I'm not planning on applying
this into wpa_supplicant.

Patch

diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c

index e662713..eb8e7d7 100644

--- a/wpa_supplicant/scan.c

+++ b/wpa_supplicant/scan.c

@@ -668,7 +668,8 @@  static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)

                }
       }

-        if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2) {

+       if (scan_req != MANUAL_SCAN_REQ && wpa_s->conf->ap_scan == 2 &&

+          wpa_s->current_ssid == NULL) {

                wpa_s->connect_without_scan = NULL;
                wpa_s->prev_scan_wildcard = 0;
                wpa_supplicant_assoc_try(wpa_s, ssid);