mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	packet: uses kfree_skb() for errors.
consume_skb() isn't for error cases that kfree_skb() is more proper one. At this patch, it fixed tpacket_rcv() and packet_rcv() to be consistent for error or non-error cases letting perf trace its event properly. Signed-off-by: Weongyo Jeong <weongyo.linux@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									333f796235
								
							
						
					
					
						commit
						da37845fdc
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
					@ -2052,6 +2052,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
	u8 *skb_head = skb->data;
 | 
						u8 *skb_head = skb->data;
 | 
				
			||||||
	int skb_len = skb->len;
 | 
						int skb_len = skb->len;
 | 
				
			||||||
	unsigned int snaplen, res;
 | 
						unsigned int snaplen, res;
 | 
				
			||||||
 | 
						bool is_drop_n_account = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (skb->pkt_type == PACKET_LOOPBACK)
 | 
						if (skb->pkt_type == PACKET_LOOPBACK)
 | 
				
			||||||
		goto drop;
 | 
							goto drop;
 | 
				
			||||||
| 
						 | 
					@ -2140,6 +2141,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
drop_n_acct:
 | 
					drop_n_acct:
 | 
				
			||||||
 | 
						is_drop_n_account = true;
 | 
				
			||||||
	spin_lock(&sk->sk_receive_queue.lock);
 | 
						spin_lock(&sk->sk_receive_queue.lock);
 | 
				
			||||||
	po->stats.stats1.tp_drops++;
 | 
						po->stats.stats1.tp_drops++;
 | 
				
			||||||
	atomic_inc(&sk->sk_drops);
 | 
						atomic_inc(&sk->sk_drops);
 | 
				
			||||||
| 
						 | 
					@ -2151,7 +2153,10 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
		skb->len = skb_len;
 | 
							skb->len = skb_len;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
drop:
 | 
					drop:
 | 
				
			||||||
 | 
						if (!is_drop_n_account)
 | 
				
			||||||
		consume_skb(skb);
 | 
							consume_skb(skb);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							kfree_skb(skb);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2170,6 +2175,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
	struct sk_buff *copy_skb = NULL;
 | 
						struct sk_buff *copy_skb = NULL;
 | 
				
			||||||
	struct timespec ts;
 | 
						struct timespec ts;
 | 
				
			||||||
	__u32 ts_status;
 | 
						__u32 ts_status;
 | 
				
			||||||
 | 
						bool is_drop_n_account = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
 | 
						/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
 | 
				
			||||||
	 * We may add members to them until current aligned size without forcing
 | 
						 * We may add members to them until current aligned size without forcing
 | 
				
			||||||
| 
						 | 
					@ -2377,10 +2383,14 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
		skb->len = skb_len;
 | 
							skb->len = skb_len;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
drop:
 | 
					drop:
 | 
				
			||||||
 | 
						if (!is_drop_n_account)
 | 
				
			||||||
 | 
							consume_skb(skb);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
		kfree_skb(skb);
 | 
							kfree_skb(skb);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
drop_n_account:
 | 
					drop_n_account:
 | 
				
			||||||
 | 
						is_drop_n_account = true;
 | 
				
			||||||
	po->stats.stats1.tp_drops++;
 | 
						po->stats.stats1.tp_drops++;
 | 
				
			||||||
	spin_unlock(&sk->sk_receive_queue.lock);
 | 
						spin_unlock(&sk->sk_receive_queue.lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue