diff options
Diffstat (limited to 'net/packet/af_packet.c')
| -rw-r--r-- | net/packet/af_packet.c | 25 | 
1 files changed, 11 insertions, 14 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index e3eeed19cc7a..e3beb28203eb 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -188,7 +188,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,  #define BLOCK_PRIV(x)		((void *)((char *)(x) + BLOCK_O2PRIV(x)))  struct packet_sock; -static int tpacket_snd(struct packet_sock *po, struct msghdr *msg);  static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,  		       struct packet_type *pt, struct net_device *orig_dev); @@ -196,8 +195,7 @@ static void *packet_previous_frame(struct packet_sock *po,  		struct packet_ring_buffer *rb,  		int status);  static void packet_increment_head(struct packet_ring_buffer *buff); -static int prb_curr_blk_in_use(struct tpacket_kbdq_core *, -			struct tpacket_block_desc *); +static int prb_curr_blk_in_use(struct tpacket_block_desc *);  static void *prb_dispatch_next_block(struct tpacket_kbdq_core *,  			struct packet_sock *);  static void prb_retire_current_block(struct tpacket_kbdq_core *, @@ -721,7 +719,7 @@ static void prb_retire_rx_blk_timer_expired(unsigned long data)  			/* Case 1. Queue was frozen because user-space was  			 *	   lagging behind.  			 */ -			if (prb_curr_blk_in_use(pkc, pbd)) { +			if (prb_curr_blk_in_use(pbd)) {  				/*  				 * Ok, user-space is still behind.  				 * So just refresh the timer. @@ -972,8 +970,7 @@ static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,  	}  } -static int prb_curr_blk_in_use(struct tpacket_kbdq_core *pkc, -				      struct tpacket_block_desc *pbd) +static int prb_curr_blk_in_use(struct tpacket_block_desc *pbd)  {  	return TP_STATUS_USER & BLOCK_STATUS(pbd);  } @@ -1064,7 +1061,7 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po,  		 * Check if that last block which caused the queue to freeze,  		 * is still in_use by user-space.  		 */ -		if (prb_curr_blk_in_use(pkc, pbd)) { +		if (prb_curr_blk_in_use(pbd)) {  			/* Can't record this packet */  			return NULL;  		} else { @@ -1320,7 +1317,7 @@ static void packet_sock_destruct(struct sock *sk)  	skb_queue_purge(&sk->sk_error_queue);  	WARN_ON(atomic_read(&sk->sk_rmem_alloc)); -	WARN_ON(atomic_read(&sk->sk_wmem_alloc)); +	WARN_ON(refcount_read(&sk->sk_wmem_alloc));  	if (!sock_flag(sk, SOCK_DEAD)) {  		pr_err("Attempt to release alive packet socket: %p\n", sk); @@ -1742,7 +1739,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)  		match->flags = flags;  		INIT_LIST_HEAD(&match->list);  		spin_lock_init(&match->lock); -		atomic_set(&match->sk_ref, 0); +		refcount_set(&match->sk_ref, 0);  		fanout_init_data(match);  		match->prot_hook.type = po->prot_hook.type;  		match->prot_hook.dev = po->prot_hook.dev; @@ -1756,10 +1753,10 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)  	    match->prot_hook.type == po->prot_hook.type &&  	    match->prot_hook.dev == po->prot_hook.dev) {  		err = -ENOSPC; -		if (atomic_read(&match->sk_ref) < PACKET_FANOUT_MAX) { +		if (refcount_read(&match->sk_ref) < PACKET_FANOUT_MAX) {  			__dev_remove_pack(&po->prot_hook);  			po->fanout = match; -			atomic_inc(&match->sk_ref); +			refcount_set(&match->sk_ref, refcount_read(&match->sk_ref) + 1);  			__fanout_link(sk, po);  			err = 0;  		} @@ -1788,7 +1785,7 @@ static struct packet_fanout *fanout_release(struct sock *sk)  	if (f) {  		po->fanout = NULL; -		if (atomic_dec_and_test(&f->sk_ref)) +		if (refcount_dec_and_test(&f->sk_ref))  			list_del(&f->list);  		else  			f = NULL; @@ -2526,7 +2523,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,  	skb->data_len = to_write;  	skb->len += to_write;  	skb->truesize += to_write; -	atomic_add(to_write, &po->sk.sk_wmem_alloc); +	refcount_add(to_write, &po->sk.sk_wmem_alloc);  	while (likely(to_write)) {  		nr_frags = skb_shinfo(skb)->nr_frags; @@ -4498,7 +4495,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)  		seq_printf(seq,  			   "%pK %-6d %-4d %04x   %-5d %1d %-6u %-6u %-6lu\n",  			   s, -			   atomic_read(&s->sk_refcnt), +			   refcount_read(&s->sk_refcnt),  			   s->sk_type,  			   ntohs(po->num),  			   po->ifindex,  | 
