linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] zd1211rw: use unaligned safe memcmp() in-place of compare_ether_addr()
       [not found] <492F8B65.40400@hotmail.com>
@ 2008-11-28  6:10 ` Shaddy Baddah
  2008-11-29 12:40   ` Holger Schurig
  0 siblings, 1 reply; 3+ messages in thread
From: Shaddy Baddah @ 2008-11-28  6:10 UTC (permalink / raw)
  To: linux-wireless

Forgot the sign-off. Take two:

Under my 2.6.28-rc6 sparc64, when associating to an AP through my
zd1211rw device, I was seeing kernel log messages like (not exact output):

  Kernel unaligned access at TPC[10129b68] zd_mac_rx+0x144/0x32c [zd1211rw]

For the zd1211rw module, on RX, the 80211 packet will be located after
the PLCP header in the skb data buffer. The PLCP header being 5 bytes
long, the 80211 header will start unaligned from an aligned skb
buffer.

As per Documentation/unaligned-memory-access.txt, we must replace the
not unaligned() safe compare_ether_addr() with memcmp() to protect
architectures that require alignment.

Signed-off-by: Shaddy Baddah <shaddy_baddah@hotmail.com>

diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c
b/drivers/net/wireless/zd1211rw/zd_mac.c
index e48d605..dd93f23 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -616,7 +616,7 @@ static int filter_ack(struct ieee80211_hw *hw,
struct ieee80211_hdr *rx_hdr,
         struct ieee80211_hdr *tx_hdr;

         tx_hdr = (struct ieee80211_hdr *)skb->data;
-        if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1)))
+        if (likely(!memcmp(tx_hdr->addr2, rx_hdr->addr1, ETH_ALEN)))
         {
             __skb_unlink(skb, q);
             tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1);


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

* Re: [PATCHv2] zd1211rw: use unaligned safe memcmp() in-place of compare_ether_addr()
  2008-11-28  6:10 ` [PATCHv2] zd1211rw: use unaligned safe memcmp() in-place of compare_ether_addr() Shaddy Baddah
@ 2008-11-29 12:40   ` Holger Schurig
       [not found]     ` <49313CFF.4070005@hotmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Holger Schurig @ 2008-11-29 12:40 UTC (permalink / raw)
  To: linux-wireless, Shaddy Baddah

> -        if (likely(!compare_ether_addr(tx_hdr->addr2,
> rx_hdr->addr1))) +        if (likely(!memcmp(tx_hdr->addr2,
> rx_hdr->addr1, ETH_ALEN))) {
>              __skb_unlink(skb, q);

Wouldn't it be better to fix compile_ether_addr instead?

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

* Re: [PATCHv2] zd1211rw: use unaligned safe memcmp() in-place of compare_ether_addr()
       [not found]     ` <49313CFF.4070005@hotmail.com>
@ 2008-11-29 13:00       ` Shaddy Baddah
  0 siblings, 0 replies; 3+ messages in thread
From: Shaddy Baddah @ 2008-11-29 13:00 UTC (permalink / raw)
  To: Holger Schurig; +Cc: linux-wireless

Hi,

On 29/11/08 23:40, Holger Schurig wrote:
>> -        if (likely(!compare_ether_addr(tx_hdr->addr2,
>> rx_hdr->addr1))) +        if (likely(!memcmp(tx_hdr->addr2,
>> rx_hdr->addr1, ETH_ALEN))) {
>>              __skb_unlink(skb, q);
> 
> Wouldn't it be better to fix compile_ether_addr instead?

 From Documentation/unaligned-memory-access.txt in reference to 
compare_ether_addr():

Despite the potential unaligned access problems with the above function, it
is included in the kernel anyway but is understood to only work on
16-bit-aligned addresses. It is up to the caller to ensure this alignment or
not use this function at all. This alignment-unsafe function is still useful
as it is a decent optimization for the cases when you can ensure alignment,
which is true almost all of the time in ethernet networking context.

Hope that helps,
Shaddy



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

end of thread, other threads:[~2008-11-29 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <492F8B65.40400@hotmail.com>
2008-11-28  6:10 ` [PATCHv2] zd1211rw: use unaligned safe memcmp() in-place of compare_ether_addr() Shaddy Baddah
2008-11-29 12:40   ` Holger Schurig
     [not found]     ` <49313CFF.4070005@hotmail.com>
2008-11-29 13:00       ` Shaddy Baddah

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).