linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cfg80211: fix BSS comparison
@ 2012-04-30  7:23 Emmanuel Grumbach
  2012-04-30  8:09 ` Felix Fietkau
  0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Grumbach @ 2012-04-30  7:23 UTC (permalink / raw)
  To: linux-wireless; +Cc: Emmanuel Grumbach, Felix Fietkau

Since the BSS table is organized in a RB tree, the BSSs need to be
comparable. This means that we must define a < and > operator to
the BSS object.
compare_ethr_addr isn't enough since it returns only a binary value.

Since Felix's

cfg80211: use compare_ether_addr on MAC addresses instead of memcmp

    Because of the constant size and guaranteed 16 bit alignment, the inline
    compare_ether_addr function is much cheaper than calling memcmp.

    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
    Signed-off-by: John W. Linville <linville@tuxdriver.com>

The BSS table is corrupted: rb_find_bss can't find the bss.
As a result BSSes are duplicated in the BSS table, and we get stuck
while probing an AP before associating (in STA mode).

Change-Id: I85928756f4328028230832c1565ece7f412f3843
CC: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
v2: add a comment to warn the next guy that will try to over optimize :-)
---
 net/wireless/scan.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index bd6a0ee..aa01335 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -378,7 +378,11 @@ static int cmp_bss_core(struct cfg80211_bss *a,
 			       b->len_information_elements);
 	}
 
-	return compare_ether_addr(a->bssid, b->bssid);
+	/*
+	 * we can't use compare_ether_addr here since we need a < > operator.
+	 * The binary return value of compare_ether_addr isn't enough
+	 */
+	return memcmp(a->bssid, b->bssid, sizeof(a->bssid));
 }
 
 static int cmp_bss(struct cfg80211_bss *a,
-- 
1.7.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] cfg80211: fix BSS comparison
  2012-04-30  7:23 [PATCH v2] cfg80211: fix BSS comparison Emmanuel Grumbach
@ 2012-04-30  8:09 ` Felix Fietkau
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Fietkau @ 2012-04-30  8:09 UTC (permalink / raw)
  To: Emmanuel Grumbach; +Cc: linux-wireless

On 2012-04-30 9:23 AM, Emmanuel Grumbach wrote:
> Since the BSS table is organized in a RB tree, the BSSs need to be
> comparable. This means that we must define a < and > operator to
> the BSS object.
> compare_ethr_addr isn't enough since it returns only a binary value.
> 
> Since Felix's
> 
> cfg80211: use compare_ether_addr on MAC addresses instead of memcmp
> 
>     Because of the constant size and guaranteed 16 bit alignment, the inline
>     compare_ether_addr function is much cheaper than calling memcmp.
> 
>     Signed-off-by: Felix Fietkau <nbd@openwrt.org>
>     Signed-off-by: John W. Linville <linville@tuxdriver.com>
> 
> The BSS table is corrupted: rb_find_bss can't find the bss.
> As a result BSSes are duplicated in the BSS table, and we get stuck
> while probing an AP before associating (in STA mode).
> 
> Change-Id: I85928756f4328028230832c1565ece7f412f3843
> CC: Felix Fietkau <nbd@openwrt.org>
> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Looks good, thanks for finding this.
Acked-by: Felix Fietkau <nbd@openwrt.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-30  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-30  7:23 [PATCH v2] cfg80211: fix BSS comparison Emmanuel Grumbach
2012-04-30  8:09 ` Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).