Skip to content

Commit 1080e51

Browse files
mstsirkindavem330
authored andcommitted
net: orphan frags on receive
zero copy packets are normally sent to the outside network, but bridging, tun etc might loop them back to host networking stack. If this happens destructors will never be called, so orphan the frags immediately on receive. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 868eefe commit 1080e51

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/core/dev.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,8 @@ static inline int deliver_skb(struct sk_buff *skb,
16321632
struct packet_type *pt_prev,
16331633
struct net_device *orig_dev)
16341634
{
1635+
if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
1636+
return -ENOMEM;
16351637
atomic_inc(&skb->users);
16361638
return pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
16371639
}
@@ -3262,7 +3264,10 @@ static int __netif_receive_skb(struct sk_buff *skb)
32623264
}
32633265

32643266
if (pt_prev) {
3265-
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
3267+
if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
3268+
ret = -ENOMEM;
3269+
else
3270+
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
32663271
} else {
32673272
atomic_long_inc(&skb->dev->rx_dropped);
32683273
kfree_skb(skb);

0 commit comments

Comments
 (0)