<div>Hi Jouni,</div><div><br></div><div>&gt; This should probably not be run with WPA_DRIVER_FLAGS_SME..</div><div><br></div><div>&gt; wpa_supplicant_deauthenticate() would sound more appropriate in this<br>&gt; case since association was rejected.</div>

<div>
<br></div><div>Thanks for pointing these out. </div><div><br></div><div>&gt; This could use wpas_connection_failed() to remain consistent with other<br>&gt; similar connection failure cases..</div><div><br></div><div>I found this while testing P2P connection scenario and I didn&#39;t want to backlist the ssid which would</div>


<div>further delay the connection process. Is it fine to same approach for P2P and STA in this case? or should we</div><div>use  wpas_connection_failed() for STA alone? I also added code to disable the network and remove the p2p_group, </div>


<div>if the retries reached the threshold. This code so far is working for me. But not sure whether I have</div><div>covered all the cases properly. Request your opinion. </div><div><br></div><div>I shall generate a patch, If you feel this is okay. Please find the updated code below.</div>

<div><br></div><div><div>void wpa_supplicant_event(void *ctx, enum wpa_event_type event,</div><div><span style="white-space:pre-wrap">                        </span>  union wpa_event_data *data)</div>
</div><div><br></div><div>            ...</div><div>            ...</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span>case EVENT_ASSOC_REJECT:</div><div><span style="white-space:pre-wrap">                </span>if (data-&gt;assoc_reject.bssid)</div>


<div><span style="white-space:pre-wrap">                        </span>wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT</div><div><span style="white-space:pre-wrap">                                </span>&quot;bssid=&quot; MACSTR<span style="white-space:pre-wrap">        </span>&quot; status_code=%u&quot;,</div>


<div><span style="white-space:pre-wrap">                                </span>MAC2STR(data-&gt;assoc_reject.bssid),</div><div><span style="white-space:pre-wrap">                                </span>data-&gt;assoc_reject.status_code);</div>
<div><span style="white-space:pre-wrap">                </span>else</div><div><span style="white-space:pre-wrap">                        </span>wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT</div><div><span style="white-space:pre-wrap">                                </span>&quot;status_code=%u&quot;,</div>


<div><span style="white-space:pre-wrap">                                </span>data-&gt;assoc_reject.status_code);</div><div><span style="white-space:pre-wrap">                </span>if (wpa_s-&gt;drv_flags &amp; WPA_DRIVER_FLAGS_SME)</div>
<div><span style="white-space:pre-wrap">                        </span>sme_event_assoc_reject(wpa_s, data);</div><div><span style="white-space:pre-wrap">                </span>else {</div><div><br></div><div><span style="white-space:pre-wrap">                        </span>if(!wpa_s-&gt;current_ssid) {</div>


<div><span style="white-space:pre-wrap">                                </span>wpa_printf(MSG_ERROR, &quot;current_ssid == NULL&quot;);</div><div><span style="white-space:pre-wrap">                                </span>break;</div><div><span style="white-space:pre-wrap">                        </span>}</div>


<div><span style="white-space:pre-wrap">                        </span>/* If assoc reject is reported by the driver, then avoid</div><div><span style="white-space:pre-wrap">                        </span> * waiting for  the authentication timeout. Cancel the</div>


<div><span style="white-space:pre-wrap">                        </span> * authentication timeout and retry the assoc.</div><div><span style="white-space:pre-wrap">                        </span> */</div><div><span style="white-space:pre-wrap">                        </span>if(wpa_s-&gt;current_ssid-&gt;assoc_retry++ &lt; 5) {</div>


<div><span style="white-space:pre-wrap">                                </span>wpa_printf(MSG_ERROR, &quot;Retrying assoc: %d &quot;,</div><div><span style="white-space:pre-wrap">                                                                </span>wpa_s-&gt;current_ssid-&gt;assoc_retry);</div>
<div><br></div><div><span style="white-space:pre-wrap">                                </span>wpa_supplicant_cancel_auth_timeout(wpa_s);</div><div><br></div><div><span style="white-space:pre-wrap">                                </span>/* Clear the states */</div>
<div><span style="white-space:pre-wrap">                                </span>wpa_sm_notify_disassoc(wpa_s-&gt;wpa);</div><div><span style="white-space:pre-wrap">                                </span>wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);</div>
<div><br></div><div><span style="white-space:pre-wrap">                                </span>wpa_s-&gt;reassociate = 1;</div><div><span style="white-space:pre-wrap">                                </span>wpa_supplicant_req_scan(wpa_s, 1, 0);</div>
<div><span style="white-space:pre-wrap">                        </span>} else {</div><div><span style="white-space:pre-wrap">                                </span>/* If we ASSOC_REJECT&#39;s hits threshold, disable the </div><div><span style="white-space:pre-wrap">                        </span> <span style="white-space:pre-wrap">        </span>* network</div>


<div><span style="white-space:pre-wrap">                        </span> <span style="white-space:pre-wrap">        </span>*/</div><div><span style="white-space:pre-wrap">                                </span>wpa_printf(MSG_ERROR, &quot;Assoc retry threshold reached. &quot;</div>


<div><span style="white-space:pre-wrap">                                </span>&quot;Disabling the network&quot;);</div><div><span style="white-space:pre-wrap">                                </span>wpa_supplicant_disable_network(wpa_s, wpa_s-&gt;current_ssid);</div>
<div>#ifdef CONFIG_P2P</div><div><span style="white-space:pre-wrap">                                </span>if(wpa_s-&gt;p2p_group_interface != NOT_P2P_GROUP_INTERFACE)</div><div><span style="white-space:pre-wrap">                                        </span>wpas_p2p_group_remove(wpa_s, wpa_s-&gt;ifname);</div>


<div>#endif</div><div><span style="white-space:pre-wrap">                        </span>}</div><div><span style="white-space:pre-wrap">                </span>}</div><div><span style="white-space:pre-wrap">                </span>break;</div>
<br clear="all"><div><font color="#666666"><b>   ...</b></font></div><div><font color="#666666"><b>   ...</b></font></div><div><font color="#666666"><b>}</b></font></div><div><font color="#666666"><b><br></b></font></div>

<div><font color="#666666"><b><br></b></font></div><div><font color="#666666" face="&#39;courier new&#39;, monospace"><b>- Jithu Jance</b></font></div><br>
<br><br><div class="gmail_quote">On Sat, Jun 9, 2012 at 5:17 PM, Jouni Malinen <span dir="ltr">&lt;<a href="mailto:j@w1.fi" target="_blank">j@w1.fi</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On Mon, May 21, 2012 at 06:24:31AM +0000, Jithu Jance wrote:<br>
&gt; In current implementation, authentication timer continues to run even after the<br>
&gt; driver has reported ASSOC_REJECT. Then the association is retried on authentication<br>
&gt; timeout which is 10secs.<br>
<br>
</div>This is actually not the case for SME-in-wpa_supplicant, i.e., this<br>
patch did not change anything for my mac80211_hwsim test.. As such, this<br>
change should probably be conditional on WPA_DRIVER_FLAGS_SME not being<br>
set..<br>
<div><br>
&gt; The below patch cancels the authentication timeout on ASSOC_REJECT and initiates an<br>
&gt; scan for association. Kindly see whether the patch is fine.<br>
<br>
</div>The patch was whitespace damaged (tabs converted to spaces).<br>
<br>
&gt; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c<br>
<div>&gt; @@ -2238,6 +2238,25 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,<br>
</div><div>&gt;                 if (wpa_s-&gt;drv_flags &amp; WPA_DRIVER_FLAGS_SME)<br>
&gt;                         sme_event_assoc_reject(wpa_s, data);<br>
&gt; +<br>
&gt; +               /* If assoc reject is reported by the driver, then avoid<br>
<br>
</div>sme_event_assoc_reject() handles this with similar mechanism to initiate<br>
new attempt immediately.<br>
<div><br>
&gt; +                * waiting for  the authentication timeout. Cancel the<br>
&gt; +                * authentication timeout and retry the assoc.<br>
&gt; +                */<br>
&gt; +               if(wpa_s-&gt;assoc_retries++ &lt; 3) {<br>
<br>
</div>This should probably not be run with WPA_DRIVER_FLAGS_SME..<br>
<div><br>
&gt; +                       wpa_printf(MSG_ERROR, &quot;Retrying assoc &quot;<br>
&gt; +                       &quot;Iteration:%d&quot;, wpa_s-&gt;assoc_retries);<br>
&gt; +                       wpa_supplicant_cancel_auth_timeout(wpa_s);<br>
&gt; +<br>
&gt; +                       /* Clear the states */<br>
&gt; +                       wpa_sm_notify_disassoc(wpa_s-&gt;wpa);<br>
&gt; +                       wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);<br>
<br>
</div>wpa_supplicant_deauthenticate() would sound more appropriate in this<br>
case since association was rejected.<br>
<div><br>
&gt; +                       wpa_s-&gt;reassociate = 1;<br>
&gt; +                       wpa_supplicant_req_scan(wpa_s, 1, 0);<br>
<br>
</div>This could use wpas_connection_failed() to remain consistent with other<br>
similar connection failure cases..<br>
<br>
<br>
I have not tested this, but something like this could handle this a bit<br>
more cleanly. Could you please check whether this works in the case you<br>
are seeing?<br>
<br>
<br>
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c<br>
index d09be6c..0b4feb8 100644<br>
--- a/wpa_supplicant/events.c<br>
+++ b/wpa_supplicant/events.c<br>
@@ -2320,6 +2320,27 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,<br>
<div>                                data-&gt;assoc_reject.status_code);<br>
                if (wpa_s-&gt;drv_flags &amp; WPA_DRIVER_FLAGS_SME)<br>
                        sme_event_assoc_reject(wpa_s, data);<br>
</div>+               else if (wpa_s-&gt;assoc_retries++ &lt; 3) {<br>
+                       /*<br>
+                        * If association reject is reported by the driver,<br>
+                        * avoid waiting for the authentication timeout. Cancel<br>
+                        * the authentication timeout and retry the<br>
+                        * association.<br>
+                        */<br>
+                       wpa_printf(MSG_DEBUG, &quot;Retrying association &quot;<br>
+                                  &quot;(iteration %d)&quot;, wpa_s-&gt;assoc_retries);<br>
+<br>
+                       /* Clear the state */<br>
+                       wpa_sm_notify_disassoc(wpa_s-&gt;wpa);<br>
+                       wpa_supplicant_deauthenticate(<br>
+                               wpa_s, WLAN_REASON_DEAUTH_LEAVING);<br>
<div>+<br>
+                       wpa_s-&gt;reassociate = 1;<br>
</div>+                       wpas_connection_failed(wpa_s,<br>
+                                              data-&gt;assoc_reject.bssid);<br>
<div>+               } else {<br>
+                       wpa_s-&gt;assoc_retries = 0;<br>
+               }<br>
                break;<br>
        case EVENT_AUTH_TIMED_OUT:<br>
                if (wpa_s-&gt;drv_flags &amp; WPA_DRIVER_FLAGS_SME)<br>
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c<br>
</div>index 3cb954d..fdfcc5d 100644<br>
--- a/wpa_supplicant/wpa_supplicant.c<br>
+++ b/wpa_supplicant/wpa_supplicant.c<br>
@@ -587,6 +587,9 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,<br>
                wpa_supplicant_state_txt(wpa_s-&gt;wpa_state),<br>
                wpa_supplicant_state_txt(state));<br>
<br>
+       if (state == WPA_ASSOCIATED || state &lt;= WPA_INACTIVE)<br>
<div>+               wpa_s-&gt;assoc_retries = 0;<br>
+<br>
        if (state != WPA_SCANNING)<br>
                wpa_supplicant_notify_scanning(wpa_s, 0);<br>
<br>
</div>@@ -3199,8 +3202,11 @@ void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid)<br>
         * either not available or has already been tried, so that we can start<br>
         * increasing the delay here to avoid constant scanning.<br>
         */<br>
-       count = wpa_blacklist_add(wpa_s, bssid);<br>
-       if (count == 1 &amp;&amp; wpa_s-&gt;current_bss) {<br>
+       if (bssid)<br>
+               count = wpa_blacklist_add(wpa_s, bssid);<br>
+       else<br>
+               count = 3;<br>
+       if (count == 1 &amp;&amp; wpa_s-&gt;current_bss &amp;&amp; bssid) {<br>
                /*<br>
                 * This BSS was not in the blacklist before. If there is<br>
                 * another BSS available for the same ESS, we should try that<br>
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h<br>
index 84e8fa4..50eef00 100644<br>
<div>--- a/wpa_supplicant/wpa_supplicant_i.h<br>
+++ b/wpa_supplicant/wpa_supplicant_i.h<br>
@@ -286,6 +286,7 @@ struct wpa_supplicant {<br>
        struct wpa_bss *current_bss;<br>
        int ap_ies_from_associnfo;<br>
        unsigned int assoc_freq;<br>
+       unsigned int assoc_retries;<br>
<br>
        /* Selected configuration (based on Beacon/ProbeResp WPA IE) */<br>
        int pairwise_cipher;<br>
<br>
--<br>
</div>Jouni Malinen                                            PGP id EFC895FA<br>
<div><div>_______________________________________________<br>
HostAP mailing list<br>
<a href="mailto:HostAP@lists.shmoo.com" target="_blank">HostAP@lists.shmoo.com</a><br>
<a href="http://lists.shmoo.com/mailman/listinfo/hostap" target="_blank">http://lists.shmoo.com/mailman/listinfo/hostap</a><br>
</div></div></blockquote></div><br></div>