Skip to content

Commit f51a5e8

Browse files
jasowangdavem330
authored andcommitted
tun/macvtap: use consume_skb() instead of kfree_skb() when needed
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]>
1 parent 6db1671 commit f51a5e8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/net/macvtap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,10 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q,
859859
}
860860
if (skb) {
861861
ret = macvtap_put_user(q, skb, to);
862-
kfree_skb(skb);
862+
if (unlikely(ret < 0))
863+
kfree_skb(skb);
864+
else
865+
consume_skb(skb);
863866
}
864867
if (!noblock)
865868
finish_wait(sk_sleep(&q->sk), &wait);

drivers/net/tun.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
13621362
return 0;
13631363

13641364
ret = tun_put_user(tun, tfile, skb, to);
1365-
kfree_skb(skb);
1365+
if (unlikely(ret < 0))
1366+
kfree_skb(skb);
1367+
else
1368+
consume_skb(skb);
13661369

13671370
return ret;
13681371
}

0 commit comments

Comments
 (0)