Commit 4ebf802c authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: __sock_gen_cookie() cleanup

Adopt atomic64_try_cmpxchg() and remove the loop,
to make the intent more obvious.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4ffa1d1c
...@@ -25,14 +25,14 @@ DEFINE_COOKIE(sock_cookie); ...@@ -25,14 +25,14 @@ DEFINE_COOKIE(sock_cookie);
u64 __sock_gen_cookie(struct sock *sk) u64 __sock_gen_cookie(struct sock *sk)
{ {
while (1) {
u64 res = atomic64_read(&sk->sk_cookie); u64 res = atomic64_read(&sk->sk_cookie);
if (res) if (!res) {
return res; u64 new = gen_cookie_next(&sock_cookie);
res = gen_cookie_next(&sock_cookie);
atomic64_cmpxchg(&sk->sk_cookie, 0, res); atomic64_try_cmpxchg(&sk->sk_cookie, &res, new);
} }
return res;
} }
int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie) int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment