Skip to content

Commit

Permalink
tun/macvtap: use consume_skb() instead of kfree_skb() when needed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jasowang authored and davem330 committed Dec 6, 2014
1 parent 6db1671 commit f51a5e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f51a5e8

Please sign in to comment.