wpa_supplicant_select_bss error?

a.brooks2 at marathon-targets.com a.brooks2
Mon Dec 16 18:24:21 PST 2013


Hi Kurt,

Here's the patch I have:

===============================================
--- wpa_supplicant-2.0/wpa_supplicant/events.c	2013-01-13 
02:42:53.000000000 +1100
+++ wpa_supplicant-2.0.alexb/wpa_supplicant/events.c	2013-12-17 
12:45:51.190573010 +1100
@@ -806,21 +806,32 @@ wpa_supplicant_select_bss(struct wpa_sup
  			  struct wpa_ssid **selected_ssid)
  {
  	unsigned int i;
+    int best_bss_i = -1;
+    int best_bss_level = -99999;

  	wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
  		group->priority);

  	for (i = 0; i < wpa_s->last_scan_res_used; i++) {
  		struct wpa_bss *bss = wpa_s->last_scan_res[i];
-		*selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group);
-		if (!*selected_ssid)
-			continue;
+        struct wpa_ssid *ssid = wpa_scan_res_match(wpa_s, i, bss, 
group);
+        if ( !ssid )
+            continue;
+        if ( bss->level > best_bss_level ) {
+           best_bss_i = i;
+           best_bss_level = bss->level;
+        }
+	}
+
+    if ( best_bss_i >= 0 ) {
+        struct wpa_bss *bss = wpa_s->last_scan_res[best_bss_i];
+        *selected_ssid = group;
  		wpa_dbg(wpa_s, MSG_DEBUG, "   selected BSS " MACSTR
  			" ssid='%s'",
  			MAC2STR(bss->bssid),
  			wpa_ssid_txt(bss->ssid, bss->ssid_len));
-		return bss;
-	}
+        return bss;
+    }

  	return NULL;
  }
===============================================


On 2013-12-17 00:28, Kurt Bodiker wrote:
> Alex
> 
> We are experiencing the same issues. Could you please email me the
> patch you have?
> 
> Thanks,
> Kurt
> 
> On Sun, Dec 15, 2013 at 5:53 AM, <a.brooks2 at marathon-targets.com>
> wrote:
> 
>> Hi,
>> 
>> I've been trying to track down why a client seems to connect to the
>> (significantly) weaker of two access-points with identical SSIDs,
>> and refuses to roam to the stronger one subsequently.
>> 
>> I think there might be an error in wpa_supplicant_select_bss:
>> 
>> static struct wpa_bss *
>> wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
>> ? ? ? ? ? ? ? struct wpa_ssid *group,
>> ? ? ? ? ? ? ? struct wpa_ssid **selected_ssid)
>> {
>> ? ? unsigned int i;
>> 
>> ? ? wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group
>> %d",
>> ? ? ? ? group->priority);
>> 
>> ? ? for (i = 0; i < wpa_s->last_scan_res_used; i++) {
>> ? ? ? ? struct wpa_bss *bss = wpa_s->last_scan_res[i];
>> ? ? ? ? *selected_ssid = wpa_scan_res_match(wpa_s, i, bss,
>> group);
>> ? ? ? ? if (!*selected_ssid)
>> ? ? ? ? ? ? continue;
>> ? ? ? ? wpa_dbg(wpa_s, MSG_DEBUG, " ? selected BSS " MACSTR
>> ? ? ? ? ? ? " ssid='%s'",
>> ? ? ? ? ? ? MAC2STR(bss->bssid),
>> ? ? ? ? ? ? wpa_ssid_txt(bss->ssid, bss->ssid_len));
>> ? ? ? ? return bss;
>> ? ? }
>> 
>> ? ? return NULL;
>> }
>> 
>> The loop returns on the first BSS it finds with the appropriate
>> ssid. ?So the results depend on the order of the scan results.
>> In my case I have a client which happens to list the weaker BSS
>> first, so it does the wrong thing.
>> 
>> I think this loop should find the best BSS instead. ?I made this
>> change and now my client happily connects to the correct BSS, and
>> roams appropriately.
>> 
>> I can submit a patch but thought I'd ask the question first (this
>> code seems to have been around for a while so I'm surprised no-one
>> has found it if it is in fact a bug), let me know.
>> 
>> Cheers,
>> 
>> Alex
>> _______________________________________________
>> HostAP mailing list
>> HostAP at lists.shmoo.com
>> http://lists.shmoo.com/mailman/listinfo/hostap [1]
> 
> 
> 
> Links:
> ------
> [1] http://lists.shmoo.com/mailman/listinfo/hostap



More information about the Hostap mailing list