tun/macvtap: use consume_skb() instead of kfree_skb() when needed
authorJason Wang <jasowang@redhat.com>
Mon, 1 Dec 2014 08:53:15 +0000 (16:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 6 Dec 2014 05:45:09 +0000 (21:45 -0800)
To be more friendly with drop monitor, we should only call kfree_skb() when
the packets were dropped and use consume_skb() in other cases.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvtap.c
drivers/net/tun.c

index 22b4cf2fa108fe17b9fec38267efb364b9fd28df..ba1e5db2152e5519f644338bb170398d91853128 100644 (file)
@@ -859,7 +859,10 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q,
        }
        if (skb) {
                ret = macvtap_put_user(q, skb, to);
-               kfree_skb(skb);
+               if (unlikely(ret < 0))
+                       kfree_skb(skb);
+               else
+                       consume_skb(skb);
        }
        if (!noblock)
                finish_wait(sk_sleep(&q->sk), &wait);
index 6d44da1845945ba9400e5fba82f2d718a7a8a944..9c58286b8a42d20189f34801fca3e4a21e7c10e7 100644 (file)
@@ -1362,7 +1362,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
                return 0;
 
        ret = tun_put_user(tun, tfile, skb, to);
-       kfree_skb(skb);
+       if (unlikely(ret < 0))
+               kfree_skb(skb);
+       else
+               consume_skb(skb);
 
        return ret;
 }