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 | |
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>
-rw-r--r-- | include/net/ipip.h | 4 | ||||
-rw-r--r-- | include/net/xfrm.h | 2 | ||||
-rw-r--r-- | net/ipv4/tunnel4.c | 29 |
3 files changed, 22 insertions, 13 deletions
diff --git a/include/net/ipip.h b/include/net/ipip.h index 0403fe4c4519..a32654d52730 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h | |||
@@ -34,12 +34,12 @@ struct ip_tunnel { | |||
34 | #ifdef CONFIG_IPV6_SIT_6RD | 34 | #ifdef CONFIG_IPV6_SIT_6RD |
35 | struct ip_tunnel_6rd_parm ip6rd; | 35 | struct ip_tunnel_6rd_parm ip6rd; |
36 | #endif | 36 | #endif |
37 | struct ip_tunnel_prl_entry *prl; /* potential router list */ | 37 | struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ |
38 | unsigned int prl_count; /* # of entries in PRL */ | 38 | unsigned int prl_count; /* # of entries in PRL */ |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct ip_tunnel_prl_entry { | 41 | struct ip_tunnel_prl_entry { |
42 | struct ip_tunnel_prl_entry *next; | 42 | struct ip_tunnel_prl_entry __rcu *next; |
43 | __be32 addr; | 43 | __be32 addr; |
44 | u16 flags; | 44 | u16 flags; |
45 | struct rcu_head rcu_head; | 45 | struct rcu_head rcu_head; |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index ffcd47820a5b..bcfb6b24b019 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -1264,7 +1264,7 @@ struct xfrm_tunnel { | |||
1264 | int (*handler)(struct sk_buff *skb); | 1264 | int (*handler)(struct sk_buff *skb); |
1265 | int (*err_handler)(struct sk_buff *skb, u32 info); | 1265 | int (*err_handler)(struct sk_buff *skb, u32 info); |
1266 | 1266 | ||
1267 | struct xfrm_tunnel *next; | 1267 | struct xfrm_tunnel __rcu *next; |
1268 | int priority; | 1268 | int priority; |
1269 | }; | 1269 | }; |
1270 | 1270 | ||
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; |