forked from mirrors/linux
		
	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>
This commit is contained in:
		
							parent
							
								
									868eefeb17
								
							
						
					
					
						commit
						1080e512d4
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue