diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2013-09-24 10:25:40 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-30 14:22:59 -0400 |
commit | 559835ea7292e2f09304d81eda16f4209433245e (patch) | |
tree | 516a56d352969181deffa05466c7a0cfd0e15dc1 /include/net/sock.h | |
parent | 9a3bab6b05383f1e4c3716b3615500c51285959e (diff) | |
download | linux-559835ea7292e2f09304d81eda16f4209433245e.tar.bz2 |
vxlan: Use RCU apis to access sk_user_data.
Use of RCU api makes vxlan code easier to understand. It also
fixes bug due to missing ACCESS_ONCE() on sk_user_data dereference.
In rare case without ACCESS_ONCE() compiler might omit vs on
sk_user_data dereference.
Compiler can use vs as alias for sk->sk_user_data, resulting in
multiple sk_user_data dereference in rcu read context which
could change.
CC: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 6ba2e7b0e2b1..1d37a8086bed 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -409,6 +409,11 @@ struct sock { void (*sk_destruct)(struct sock *sk); }; +#define __sk_user_data(sk) ((*((void __rcu **)&(sk)->sk_user_data))) + +#define rcu_dereference_sk_user_data(sk) rcu_dereference(__sk_user_data((sk))) +#define rcu_assign_sk_user_data(sk, ptr) rcu_assign_pointer(__sk_user_data((sk)), ptr) + /* * SK_CAN_REUSE and SK_NO_REUSE on a socket mean that the socket is OK * or not whether his port will be reused by someone else. SK_FORCE_REUSE |