Skip to content

Commit

Permalink
virtio_net: fix truesize underestimation
Browse files Browse the repository at this point in the history
We must account in skb->truesize, the size of the fragments, not the
used part of them.

Doing this work is important to avoid unexpected OOM situations.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: virtualization@lists.linux-foundation.org
CC: Krishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 21, 2011
1 parent e1ac50f commit 4b72736
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ static void set_skb_frag(struct sk_buff *skb, struct page *page,

skb->data_len += size;
skb->len += size;
skb->truesize += PAGE_SIZE;
skb_shinfo(skb)->nr_frags++;
*len -= size;
}
Expand Down Expand Up @@ -287,7 +288,6 @@ static void receive_buf(struct net_device *dev, void *buf, unsigned int len)
}

hdr = skb_vnet_hdr(skb);
skb->truesize += skb->data_len;

u64_stats_update_begin(&stats->syncp);
stats->rx_bytes += skb->len;
Expand Down

0 comments on commit 4b72736

Please sign in to comment.