linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rt2x00: Further L2 padding fixes.
@ 2009-11-28 18:32 Gertjan van Wingerde
  2009-11-28 21:26 ` Ivo van Doorn
  0 siblings, 1 reply; 6+ messages in thread
From: Gertjan van Wingerde @ 2009-11-28 18:32 UTC (permalink / raw)
  To: users, linux-wireless; +Cc: Ivo van Doorn, Alban Browaeys, Gertjan van Wingerde

Fix a couple of more bugs in the L2 padding code:
1. Compute the amount of L2 padding correctly (in 2 places).
2. Trim the skb correctly when the L2 padding has been applied.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2x00queue.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index b8f0954..562a344 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -181,7 +181,7 @@ void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
 	unsigned int frame_length = skb->len;
 	unsigned int header_align = ALIGN_SIZE(skb, 0);
 	unsigned int payload_align = ALIGN_SIZE(skb, header_length);
-	unsigned int l2pad = 4 - (payload_align - header_align);
+	unsigned int l2pad = 4 - (header_length & 3);
 
 	if (header_align == payload_align) {
 		/*
@@ -216,6 +216,7 @@ void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
 		memmove(skb->data + header_length + l2pad,
 			skb->data + header_length + l2pad + payload_align,
 			frame_length - header_length);
+		skb_trim(skb, frame_length + l2pad);
 		skbdesc->flags |= SKBDESC_L2_PADDED;
 	}
 }
@@ -346,7 +347,7 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
 	 * Header and alignment information.
 	 */
 	txdesc->header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
-	txdesc->l2pad = ALIGN_SIZE(entry->skb, txdesc->header_length);
+	txdesc->l2pad = 4 - (txdesc->header_length & 3);
 
 	/*
 	 * Check whether this frame is to be acked.
-- 
1.6.5.3


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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-28 18:32 [PATCH] rt2x00: Further L2 padding fixes Gertjan van Wingerde
2009-11-28 21:26 ` Ivo van Doorn
2009-11-28 21:44   ` Gertjan van Wingerde
2009-11-28 23:55     ` [rt2x00-users] " Benoit PAPILLAULT
2009-11-29 11:44       ` Gertjan van Wingerde
2009-11-29 13:02         ` Andreas Schwab

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