Skip to content

Commit

Permalink
net: orphan frags on receive
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael S. Tsirkin authored and David S. Miller committed Jul 22, 2012
1 parent 868eefe commit 1080e51
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,8 @@ static inline int deliver_skb(struct sk_buff *skb,
struct packet_type *pt_prev,
struct net_device *orig_dev)
{
if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
return -ENOMEM;
atomic_inc(&skb->users);
return pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
}
Expand Down Expand Up @@ -3262,7 +3264,10 @@ static int __netif_receive_skb(struct sk_buff *skb)
}

if (pt_prev) {
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
ret = -ENOMEM;
else
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
} else {
atomic_long_inc(&skb->dev->rx_dropped);
kfree_skb(skb);
Expand Down

0 comments on commit 1080e51

Please sign in to comment.