Skip to content

Commit

Permalink
[PACKET]: Don't truncate non-linear skbs with mmaped IO
Browse files Browse the repository at this point in the history
Non-linear skbs are truncated to their linear part with mmaped IO.
Fix by using skb_copy_bits instead of memcpy.

Signed-off-by: Patrick McHardy <[email protected]>
Acked-by: Alexey Kuznetsov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kaber authored and davem330 committed Sep 18, 2006
1 parent 080f22c commit cbe21d8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
if ((int)snaplen < 0)
snaplen = 0;
}
if (snaplen > skb->len-skb->data_len)
snaplen = skb->len-skb->data_len;

spin_lock(&sk->sk_receive_queue.lock);
h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head);
Expand All @@ -644,7 +642,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
status &= ~TP_STATUS_LOSING;
spin_unlock(&sk->sk_receive_queue.lock);

memcpy((u8*)h + macoff, skb->data, snaplen);
skb_copy_bits(skb, 0, (u8*)h + macoff, snaplen);

h->tp_len = skb->len;
h->tp_snaplen = snaplen;
Expand Down

0 comments on commit cbe21d8

Please sign in to comment.