Skip to content

Commit

Permalink
ethoc: align received packet to make IP header at word boundary
Browse files Browse the repository at this point in the history
The packet buffer is allocated at 4 bytes boundary, but the IP header
length and version bits is located at byte 14. These bit fields access
as 32 bits word and caused exception on processors that do not support
unaligned access.

The patch adds 2 bytes offset to make the bit fields word aligned.

Signed-off-by: Thomas Chou <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
hippo5329 authored and davem330 committed Oct 7, 2009
1 parent 3ee19a8 commit 050f91d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/ethoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ static int ethoc_rx(struct net_device *dev, int limit)
if (ethoc_update_rx_stats(priv, &bd) == 0) {
int size = bd.stat >> 16;
struct sk_buff *skb = netdev_alloc_skb(dev, size);

size -= 4; /* strip the CRC */
skb_reserve(skb, 2); /* align TCP/IP header */

if (likely(skb)) {
void *src = phys_to_virt(bd.addr);
memcpy_fromio(skb_put(skb, size), src, size);
Expand Down

0 comments on commit 050f91d

Please sign in to comment.