diff options
| author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-10-25 17:01:26 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-10-27 14:37:32 -0400 |
| commit | b33eab08445d86c3d0dec3111ce10df561328705 (patch) | |
| tree | 381a37141d4da9cf6cb3a8c8c37c6363d856f8e4 /net | |
| parent | e0ad61ec867fdd262804afa7a68e11fc9930c2b9 (diff) | |
tunnels: add __rcu annotations
Add __rcu annotations to :
(struct ip_tunnel)->prl
(struct ip_tunnel_prl_entry)->next
(struct xfrm_tunnel)->next
struct xfrm_tunnel *tunnel4_handlers
struct xfrm_tunnel *tunnel64_handlers
And use appropriate rcu primitives to reduce sparse warnings if
CONFIG_SPARSE_RCU_POINTER=y
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
| -rw-r--r-- | net/ipv4/tunnel4.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c index 9a17bd2a0a37..ac3b3ee4b07c 100644 --- a/net/ipv4/tunnel4.c +++ b/net/ipv4/tunnel4.c | |||
| @@ -14,27 +14,32 @@ | |||
| 14 | #include <net/protocol.h> | 14 | #include <net/protocol.h> |
| 15 | #include <net/xfrm.h> | 15 | #include <net/xfrm.h> |
| 16 | 16 | ||
| 17 | static struct xfrm_tunnel *tunnel4_handlers __read_mostly; | 17 | static struct xfrm_tunnel __rcu *tunnel4_handlers __read_mostly; |
| 18 | static struct xfrm_tunnel *tunnel64_handlers __read_mostly; | 18 | static struct xfrm_tunnel __rcu *tunnel64_handlers __read_mostly; |
| 19 | static DEFINE_MUTEX(tunnel4_mutex); | 19 | static DEFINE_MUTEX(tunnel4_mutex); |
| 20 | 20 | ||
| 21 | static inline struct xfrm_tunnel **fam_handlers(unsigned short family) | 21 | static inline struct xfrm_tunnel __rcu **fam_handlers(unsigned short family) |
| 22 | { | 22 | { |
| 23 | return (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; | 23 | return (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) | 26 | int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) |
| 27 | { | 27 | { |
| 28 | struct xfrm_tunnel **pprev; | 28 | struct xfrm_tunnel __rcu **pprev; |
| 29 | struct xfrm_tunnel *t; | ||
| 30 | |||
| 29 | int ret = -EEXIST; | 31 | int ret = -EEXIST; |
| 30 | int priority = handler->priority; | 32 | int priority = handler->priority; |
| 31 | 33 | ||
| 32 | mutex_lock(&tunnel4_mutex); | 34 | mutex_lock(&tunnel4_mutex); |
| 33 | 35 | ||
| 34 | for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) { | 36 | for (pprev = fam_handlers(family); |
| 35 | if ((*pprev)->priority > priority) | 37 | (t = rcu_dereference_protected(*pprev, |
| 38 | lockdep_is_held(&tunnel4_mutex))) != NULL; | ||
| 39 | pprev = &t->next) { | ||
| 40 | if (t->priority > priority) | ||
| 36 | break; | 41 | break; |
| 37 | if ((*pprev)->priority == priority) | 42 | if (t->priority == priority) |
| 38 | goto err; | 43 | goto err; |
| 39 | } | 44 | } |
| 40 | 45 | ||
| @@ -52,13 +57,17 @@ EXPORT_SYMBOL(xfrm4_tunnel_register); | |||
| 52 | 57 | ||
| 53 | int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family) | 58 | int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family) |
| 54 | { | 59 | { |
| 55 | struct xfrm_tunnel **pprev; | 60 | struct xfrm_tunnel __rcu **pprev; |
| 61 | struct xfrm_tunnel *t; | ||
| 56 | int ret = -ENOENT; | 62 | int ret = -ENOENT; |
| 57 | 63 | ||
| 58 | mutex_lock(&tunnel4_mutex); | 64 | mutex_lock(&tunnel4_mutex); |
| 59 | 65 | ||
| 60 | for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) { | 66 | for (pprev = fam_handlers(family); |
| 61 | if (*pprev == handler) { | 67 | (t = rcu_dereference_protected(*pprev, |
| 68 | lockdep_is_held(&tunnel4_mutex))) != NULL; | ||
| 69 | pprev = &t->next) { | ||
| 70 | if (t == handler) { | ||
| 62 | *pprev = handler->next; | 71 | *pprev = handler->next; |
| 63 | ret = 0; | 72 | ret = 0; |
| 64 | break; | 73 | break; |
