linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benoit PAPILLAULT <benoit.papillault@free.fr>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, ath5k-devel@lists.ath5k.org
Subject: [PATCH] ath5k : Fix correct padding
Date: Thu, 11 Dec 2008 22:58:59 +0100	[thread overview]
Message-ID: <49418D23.8060905@free.fr> (raw)

Padding the 802.11 header to a multiple of 4 bytes needs to be done only
for DATA frames. This fixes a bug where 2 bytes were missing in monitor
mode for ACK frames.

Ref: http://bugzilla.kernel.org/show_bug.cgi?id=12101 :
Signed-off-by: Benoit Papillault <benoit.papillault@free.fr>
---
  drivers/net/wireless/ath5k/base.c |   49
+++++++++++++++++++++++-------------
  1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath5k/base.c
b/drivers/net/wireless/ath5k/base.c
index bfb0c49..2318b1c 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -1668,6 +1668,7 @@ ath5k_tasklet_rx(unsigned long data)
  	int ret;
  	int hdrlen;
  	int pad;
+	struct ieee80211_hdr * hdr;

  	spin_lock(&sc->rxbuflock);
  	if (list_empty(&sc->rxbuf)) {
@@ -1754,14 +1755,19 @@ accept:

  		/*
  		 * the hardware adds a padding to 4 byte boundaries between
-		 * the header and the payload data if the header length is
-		 * not multiples of 4 - remove it
+		 * the header and the payload data if the header length is not
+		 * multiple of 4 - remove it. This only affect data frames.
  		 */
-		hdrlen = ieee80211_get_hdrlen_from_skb(skb);
-		if (hdrlen & 3) {
-			pad = hdrlen % 4;
-			memmove(skb->data + pad, skb->data, hdrlen);
-			skb_pull(skb, pad);
+
+		hdr = (struct ieee80211_hdr *) skb;
+		if ((skb->len >= 2) && ieee80211_is_data(hdr->frame_control)) {
+
+			hdrlen = ieee80211_get_hdrlen_from_skb(skb);
+			if (hdrlen & 3) {
+				pad = hdrlen % 4;
+				memmove(skb->data + pad, skb->data, hdrlen);
+				skb_pull(skb, pad);
+			}
  		}

  		/*
@@ -2623,6 +2629,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
  	unsigned long flags;
  	int hdrlen;
  	int pad;
+	const struct ieee80211_hdr * hdr = (const struct ieee80211_hdr *)skb;

  	ath5k_debug_dump_skb(sc, skb, "TX  ", 1);

@@ -2630,19 +2637,25 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff
*skb)
  		ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, "tx in monitor (scan?)\n");

  	/*
-	 * the hardware expects the header padded to 4 byte boundaries
-	 * if this is not the case we add the padding after the header
+	 * the hardware expects the header padded to 4 byte boundaries for
+	 * data frames, if this is not the case we add the padding after the
+	 * header
  	 */
-	hdrlen = ieee80211_get_hdrlen_from_skb(skb);
-	if (hdrlen & 3) {
-		pad = hdrlen % 4;
-		if (skb_headroom(skb) < pad) {
-			ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough"
-				" headroom to pad %d\n", hdrlen, pad);
-			return -1;
+
+	if ((skb->len >= 2) && ieee80211_is_data(hdr->frame_control)) {
+
+		hdrlen = ieee80211_get_hdrlen_from_skb(skb);
+		if (hdrlen & 3) {
+			pad = hdrlen % 4;
+			if (skb_headroom(skb) < pad) {
+				ATH5K_ERR(sc,
+					  "tx hdrlen not %%4: %d not enough"
+					  " headroom to pad %d\n", hdrlen, pad);
+				return -1;
+			}
+			skb_push(skb, pad);
+			memmove(skb->data, skb->data+pad, hdrlen);
  		}
-		skb_push(skb, pad);
-		memmove(skb->data, skb->data+pad, hdrlen);
  	}

  	spin_lock_irqsave(&sc->txbuflock, flags);
-- 1.5.6.5


             reply	other threads:[~2008-12-11 21:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 21:58 Benoit PAPILLAULT [this message]
2008-12-11 21:58 ` [PATCH] ath5k : Fix correct padding Michael Buesch
2008-12-11 22:05   ` Johannes Berg
2008-12-11 22:07 ` Johannes Berg
2008-12-11 22:50   ` [ath5k-devel] " Bob Copeland
2008-12-11 22:08 ` Harvey Harrison
2008-12-11 22:10   ` Johannes Berg
2008-12-12  8:49     ` Benoit PAPILLAULT
2008-12-12 15:38       ` [ath5k-devel] " Bob Copeland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49418D23.8060905@free.fr \
    --to=benoit.papillault@free.fr \
    --cc=ath5k-devel@lists.ath5k.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).