summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2012-05-02 11:41:44 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-02 10:30:34 -0700
commitbfd1678ca0143060686d87ae0c07bebab6f0245b (patch)
tree9b7a27a90e3251f4c7fd73ba7762b5f44a6e842e /drivers/net
parent2b9ec261e3f247dc84b50263564778bcbefec79b (diff)
downloadlinux-3.10-bfd1678ca0143060686d87ae0c07bebab6f0245b.tar.gz
linux-3.10-bfd1678ca0143060686d87ae0c07bebab6f0245b.tar.bz2
linux-3.10-bfd1678ca0143060686d87ae0c07bebab6f0245b.zip
macvtap: zerocopy: fix truesize underestimation
commit 4ef67ebedffa44ed9939b34708ac2fee06d2f65f upstream. As the skb fragment were pinned/built from user pages, we should account the page instead of length for truesize. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/macvtap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 0302bc5adc6..cf096e0693e 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -520,6 +520,7 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
struct page *page[MAX_SKB_FRAGS];
int num_pages;
unsigned long base;
+ unsigned long truesize;
len = from->iov_len - offset;
if (!len) {
@@ -535,10 +536,11 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
if (num_pages != size)
/* put_page is in skb free */
return -EFAULT;
+ truesize = size * PAGE_SIZE;
skb->data_len += len;
skb->len += len;
- skb->truesize += len;
- atomic_add(len, &skb->sk->sk_wmem_alloc);
+ skb->truesize += truesize;
+ atomic_add(truesize, &skb->sk->sk_wmem_alloc);
while (len) {
int off = base & ~PAGE_MASK;
int size = min_t(int, len, PAGE_SIZE - off);