mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: __sock_gen_cookie() cleanup
Adopt atomic64_try_cmpxchg() and remove the loop, to make the intent more obvious. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									4ffa1d1c68
								
							
						
					
					
						commit
						4ebf802cf1
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -25,14 +25,14 @@ DEFINE_COOKIE(sock_cookie);
 | 
			
		|||
 | 
			
		||||
u64 __sock_gen_cookie(struct sock *sk)
 | 
			
		||||
{
 | 
			
		||||
	while (1) {
 | 
			
		||||
	u64 res = atomic64_read(&sk->sk_cookie);
 | 
			
		||||
 | 
			
		||||
		if (res)
 | 
			
		||||
			return res;
 | 
			
		||||
		res = gen_cookie_next(&sock_cookie);
 | 
			
		||||
		atomic64_cmpxchg(&sk->sk_cookie, 0, res);
 | 
			
		||||
	if (!res) {
 | 
			
		||||
		u64 new = gen_cookie_next(&sock_cookie);
 | 
			
		||||
 | 
			
		||||
		atomic64_try_cmpxchg(&sk->sk_cookie, &res, new);
 | 
			
		||||
	}
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue