From 4b727361f0bc7ee7378298941066d8aa15023ffb Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 19 Oct 2011 23:14:46 +0000 Subject: [PATCH] virtio_net: fix truesize underestimation 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 CC: Rusty Russell CC: "Michael S. Tsirkin" CC: virtualization@lists.linux-foundation.org CC: Krishna Kumar Signed-off-by: David S. Miller --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index abbf34fcf4cd..765ab9ac9d17 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -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; } @@ -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; -- 2.39.2