diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-08-30 07:07:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-01 13:57:53 -0400 |
commit | 875168a9330d3aa6481ce62ce8fa77c7be0c75fb (patch) | |
tree | 137a2d264cf960c8f6cc1a8961704cc1062014e7 /net | |
parent | 064270132602c6e11482439e0e257f208cae79c0 (diff) |
net: tunnels should use rcu_dereference
tunnel4_handlers, tunnel64_handlers, tunnel6_handlers and
tunnel46_handlers are protected by RCU, but we dont use appropriate rcu
primitives to scan them. rcu_lock() is already held by caller.
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 | 13 | ||||
-rw-r--r-- | net/ipv6/tunnel6.c | 11 |
2 files changed, 17 insertions, 7 deletions
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c index 942f02da07d8..df59d16337f2 100644 --- a/net/ipv4/tunnel4.c +++ b/net/ipv4/tunnel4.c | |||
@@ -73,6 +73,11 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family) | |||
73 | } | 73 | } |
74 | EXPORT_SYMBOL(xfrm4_tunnel_deregister); | 74 | EXPORT_SYMBOL(xfrm4_tunnel_deregister); |
75 | 75 | ||
76 | #define for_each_tunnel_rcu(head, handler) \ | ||
77 | for (handler = rcu_dereference(head); \ | ||
78 | handler != NULL; \ | ||
79 | handler = rcu_dereference(handler->next)) \ | ||
80 | |||
76 | static int tunnel4_rcv(struct sk_buff *skb) | 81 | static int tunnel4_rcv(struct sk_buff *skb) |
77 | { | 82 | { |
78 | struct xfrm_tunnel *handler; | 83 | struct xfrm_tunnel *handler; |
@@ -80,7 +85,7 @@ static int tunnel4_rcv(struct sk_buff *skb) | |||
80 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) | 85 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) |
81 | goto drop; | 86 | goto drop; |
82 | 87 | ||
83 | for (handler = tunnel4_handlers; handler; handler = handler->next) | 88 | for_each_tunnel_rcu(tunnel4_handlers, handler) |
84 | if (!handler->handler(skb)) | 89 | if (!handler->handler(skb)) |
85 | return 0; | 90 | return 0; |
86 | 91 | ||
@@ -99,7 +104,7 @@ static int tunnel64_rcv(struct sk_buff *skb) | |||
99 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) | 104 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) |
100 | goto drop; | 105 | goto drop; |
101 | 106 | ||
102 | for (handler = tunnel64_handlers; handler; handler = handler->next) | 107 | for_each_tunnel_rcu(tunnel64_handlers, handler) |
103 | if (!handler->handler(skb)) | 108 | if (!handler->handler(skb)) |
104 | return 0; | 109 | return 0; |
105 | 110 | ||
@@ -115,7 +120,7 @@ static void tunnel4_err(struct sk_buff *skb, u32 info) | |||
115 | { | 120 | { |
116 | struct xfrm_tunnel *handler; | 121 | struct xfrm_tunnel *handler; |
117 | 122 | ||
118 | for (handler = tunnel4_handlers; handler; handler = handler->next) | 123 | for_each_tunnel_rcu(tunnel4_handlers, handler) |
119 | if (!handler->err_handler(skb, info)) | 124 | if (!handler->err_handler(skb, info)) |
120 | break; | 125 | break; |
121 | } | 126 | } |
@@ -125,7 +130,7 @@ static void tunnel64_err(struct sk_buff *skb, u32 info) | |||
125 | { | 130 | { |
126 | struct xfrm_tunnel *handler; | 131 | struct xfrm_tunnel *handler; |
127 | 132 | ||
128 | for (handler = tunnel64_handlers; handler; handler = handler->next) | 133 | for_each_tunnel_rcu(tunnel64_handlers, handler) |
129 | if (!handler->err_handler(skb, info)) | 134 | if (!handler->err_handler(skb, info)) |
130 | break; | 135 | break; |
131 | } | 136 | } |
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c index d203e6df1f8b..3177fe0459e0 100644 --- a/net/ipv6/tunnel6.c +++ b/net/ipv6/tunnel6.c | |||
@@ -88,6 +88,11 @@ int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family) | |||
88 | 88 | ||
89 | EXPORT_SYMBOL(xfrm6_tunnel_deregister); | 89 | EXPORT_SYMBOL(xfrm6_tunnel_deregister); |
90 | 90 | ||
91 | #define for_each_tunnel_rcu(head, handler) \ | ||
92 | for (handler = rcu_dereference(head); \ | ||
93 | handler != NULL; \ | ||
94 | handler = rcu_dereference(handler->next)) \ | ||
95 | |||
91 | static int tunnel6_rcv(struct sk_buff *skb) | 96 | static int tunnel6_rcv(struct sk_buff *skb) |
92 | { | 97 | { |
93 | struct xfrm6_tunnel *handler; | 98 | struct xfrm6_tunnel *handler; |
@@ -95,7 +100,7 @@ static int tunnel6_rcv(struct sk_buff *skb) | |||
95 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) | 100 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) |
96 | goto drop; | 101 | goto drop; |
97 | 102 | ||
98 | for (handler = tunnel6_handlers; handler; handler = handler->next) | 103 | for_each_tunnel_rcu(tunnel6_handlers, handler) |
99 | if (!handler->handler(skb)) | 104 | if (!handler->handler(skb)) |
100 | return 0; | 105 | return 0; |
101 | 106 | ||
@@ -113,7 +118,7 @@ static int tunnel46_rcv(struct sk_buff *skb) | |||
113 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) | 118 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) |
114 | goto drop; | 119 | goto drop; |
115 | 120 | ||
116 | for (handler = tunnel46_handlers; handler; handler = handler->next) | 121 | for_each_tunnel_rcu(tunnel46_handlers, handler) |
117 | if (!handler->handler(skb)) | 122 | if (!handler->handler(skb)) |
118 | return 0; | 123 | return 0; |
119 | 124 | ||
@@ -129,7 +134,7 @@ static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
129 | { | 134 | { |
130 | struct xfrm6_tunnel *handler; | 135 | struct xfrm6_tunnel *handler; |
131 | 136 | ||
132 | for (handler = tunnel6_handlers; handler; handler = handler->next) | 137 | for_each_tunnel_rcu(tunnel6_handlers, handler) |
133 | if (!handler->err_handler(skb, opt, type, code, offset, info)) | 138 | if (!handler->err_handler(skb, opt, type, code, offset, info)) |
134 | break; | 139 | break; |
135 | } | 140 | } |