<div dir="ltr"><div>I have a similar (if not the same) issue where the AP list is not sorted. Additionally, the value for the current AP (when using hidden SSIDs) is never updated on subsequent scans.<br><br></div>Kurt<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 16, 2013 at 11:03 AM, Dan Williams <span dir="ltr">&lt;<a href="mailto:dcbw@redhat.com" target="_blank">dcbw@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sun, 2013-12-15 at 21:53 +1100, <a href="mailto:a.brooks2@marathon-targets.com">a.brooks2@marathon-targets.com</a> wrote:<br>

&gt; Hi,<br>
&gt;<br>
&gt; I&#39;ve been trying to track down why a client seems to connect to the<br>
&gt; (significantly) weaker of two access-points with identical SSIDs, and<br>
&gt; refuses to roam to the stronger one subsequently.<br>
&gt;<br>
&gt; I think there might be an error in wpa_supplicant_select_bss:<br>
<br>
</div>Scan results are sorted when they arrive from the driver in<br>
wpa_supplicant_get_scan_results() using the wpa_scan_result_compar()<br>
function, a huge component of which is signal strength.  Thus, when<br>
wpa_supplicant_select_bss() returns the first matching AP, it should<br>
already be the best AP because the AP list has been sorted.<br>
<br>
So I would concentrate your debugging on that function, and find out why<br>
it decides your &quot;better&quot; AP is less usable than your &quot;worse&quot; AP.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
&gt; static struct wpa_bss *<br>
&gt; wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,<br>
&gt;                struct wpa_ssid *group,<br>
&gt;                struct wpa_ssid **selected_ssid)<br>
&gt; {<br>
&gt;      unsigned int i;<br>
&gt;<br>
&gt;      wpa_dbg(wpa_s, MSG_DEBUG, &quot;Selecting BSS from priority group %d&quot;,<br>
&gt;          group-&gt;priority);<br>
&gt;<br>
&gt;      for (i = 0; i &lt; wpa_s-&gt;last_scan_res_used; i++) {<br>
&gt;          struct wpa_bss *bss = wpa_s-&gt;last_scan_res[i];<br>
&gt;          *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group);<br>
&gt;          if (!*selected_ssid)<br>
&gt;              continue;<br>
&gt;          wpa_dbg(wpa_s, MSG_DEBUG, &quot;   selected BSS &quot; MACSTR<br>
&gt;              &quot; ssid=&#39;%s&#39;&quot;,<br>
&gt;              MAC2STR(bss-&gt;bssid),<br>
&gt;              wpa_ssid_txt(bss-&gt;ssid, bss-&gt;ssid_len));<br>
&gt;          return bss;<br>
&gt;      }<br>
&gt;<br>
&gt;      return NULL;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; The loop returns on the first BSS it finds with the appropriate ssid.<br>
&gt; So the results depend on the order of the scan results.<br>
&gt; In my case I have a client which happens to list the weaker BSS first,<br>
&gt; so it does the wrong thing.<br>
&gt;<br>
&gt; I think this loop should find the best BSS instead.  I made this change<br>
&gt; and now my client happily connects to the correct BSS, and roams<br>
&gt; appropriately.<br>
&gt;<br>
&gt; I can submit a patch but thought I&#39;d ask the question first (this code<br>
&gt; seems to have been around for a while so I&#39;m surprised no-one has found<br>
&gt; it if it is in fact a bug), let me know.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; Alex<br>
&gt; _______________________________________________<br>
&gt; HostAP mailing list<br>
&gt; <a href="mailto:HostAP@lists.shmoo.com">HostAP@lists.shmoo.com</a><br>
&gt; <a href="http://lists.shmoo.com/mailman/listinfo/hostap" target="_blank">http://lists.shmoo.com/mailman/listinfo/hostap</a><br>
<br>
<br>
_______________________________________________<br>
HostAP mailing list<br>
<a href="mailto:HostAP@lists.shmoo.com">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>