diff options
author | Patrick McHardy <kaber@trash.net> | 2005-06-21 17:01:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-21 17:01:30 -0400 |
commit | e45b1be8bcb3643808975a426fa3e201a2588e87 (patch) | |
tree | 0c461d7bd90d0c2fb462b42e664cf8a099c750ec /net/ipv4/netfilter/ipt_CLUSTERIP.c | |
parent | c9e3e8b6958e02230079e6817862ea2968509866 (diff) |
[NETFILTER]: Kill lockhelp.h
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/netfilter/ipt_CLUSTERIP.c')
-rw-r--r-- | net/ipv4/netfilter/ipt_CLUSTERIP.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 0f12e3a3dc7..dc4362b57cf 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/netfilter_ipv4/ip_tables.h> | 29 | #include <linux/netfilter_ipv4/ip_tables.h> |
30 | #include <linux/netfilter_ipv4/ipt_CLUSTERIP.h> | 30 | #include <linux/netfilter_ipv4/ipt_CLUSTERIP.h> |
31 | #include <linux/netfilter_ipv4/ip_conntrack.h> | 31 | #include <linux/netfilter_ipv4/ip_conntrack.h> |
32 | #include <linux/netfilter_ipv4/lockhelp.h> | ||
33 | 32 | ||
34 | #define CLUSTERIP_VERSION "0.6" | 33 | #define CLUSTERIP_VERSION "0.6" |
35 | 34 | ||
@@ -41,6 +40,8 @@ | |||
41 | #define DEBUGP | 40 | #define DEBUGP |
42 | #endif | 41 | #endif |
43 | 42 | ||
43 | #define ASSERT_READ_LOCK(x) | ||
44 | |||
44 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
45 | MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); | 46 | MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); |
46 | MODULE_DESCRIPTION("iptables target for CLUSTERIP"); | 47 | MODULE_DESCRIPTION("iptables target for CLUSTERIP"); |
@@ -67,7 +68,7 @@ static LIST_HEAD(clusterip_configs); | |||
67 | 68 | ||
68 | /* clusterip_lock protects the clusterip_configs list _AND_ the configurable | 69 | /* clusterip_lock protects the clusterip_configs list _AND_ the configurable |
69 | * data within all structurses (num_local_nodes, local_nodes[]) */ | 70 | * data within all structurses (num_local_nodes, local_nodes[]) */ |
70 | static DECLARE_RWLOCK(clusterip_lock); | 71 | static DEFINE_RWLOCK(clusterip_lock); |
71 | 72 | ||
72 | #ifdef CONFIG_PROC_FS | 73 | #ifdef CONFIG_PROC_FS |
73 | static struct file_operations clusterip_proc_fops; | 74 | static struct file_operations clusterip_proc_fops; |
@@ -82,9 +83,9 @@ clusterip_config_get(struct clusterip_config *c) { | |||
82 | static inline void | 83 | static inline void |
83 | clusterip_config_put(struct clusterip_config *c) { | 84 | clusterip_config_put(struct clusterip_config *c) { |
84 | if (atomic_dec_and_test(&c->refcount)) { | 85 | if (atomic_dec_and_test(&c->refcount)) { |
85 | WRITE_LOCK(&clusterip_lock); | 86 | write_lock_bh(&clusterip_lock); |
86 | list_del(&c->list); | 87 | list_del(&c->list); |
87 | WRITE_UNLOCK(&clusterip_lock); | 88 | write_unlock_bh(&clusterip_lock); |
88 | dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0); | 89 | dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0); |
89 | dev_put(c->dev); | 90 | dev_put(c->dev); |
90 | kfree(c); | 91 | kfree(c); |
@@ -97,7 +98,7 @@ __clusterip_config_find(u_int32_t clusterip) | |||
97 | { | 98 | { |
98 | struct list_head *pos; | 99 | struct list_head *pos; |
99 | 100 | ||
100 | MUST_BE_READ_LOCKED(&clusterip_lock); | 101 | ASSERT_READ_LOCK(&clusterip_lock); |
101 | list_for_each(pos, &clusterip_configs) { | 102 | list_for_each(pos, &clusterip_configs) { |
102 | struct clusterip_config *c = list_entry(pos, | 103 | struct clusterip_config *c = list_entry(pos, |
103 | struct clusterip_config, list); | 104 | struct clusterip_config, list); |
@@ -114,14 +115,14 @@ clusterip_config_find_get(u_int32_t clusterip) | |||
114 | { | 115 | { |
115 | struct clusterip_config *c; | 116 | struct clusterip_config *c; |
116 | 117 | ||
117 | READ_LOCK(&clusterip_lock); | 118 | read_lock_bh(&clusterip_lock); |
118 | c = __clusterip_config_find(clusterip); | 119 | c = __clusterip_config_find(clusterip); |
119 | if (!c) { | 120 | if (!c) { |
120 | READ_UNLOCK(&clusterip_lock); | 121 | read_unlock_bh(&clusterip_lock); |
121 | return NULL; | 122 | return NULL; |
122 | } | 123 | } |
123 | atomic_inc(&c->refcount); | 124 | atomic_inc(&c->refcount); |
124 | READ_UNLOCK(&clusterip_lock); | 125 | read_unlock_bh(&clusterip_lock); |
125 | 126 | ||
126 | return c; | 127 | return c; |
127 | } | 128 | } |
@@ -160,9 +161,9 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip, | |||
160 | c->pde->data = c; | 161 | c->pde->data = c; |
161 | #endif | 162 | #endif |
162 | 163 | ||
163 | WRITE_LOCK(&clusterip_lock); | 164 | write_lock_bh(&clusterip_lock); |
164 | list_add(&c->list, &clusterip_configs); | 165 | list_add(&c->list, &clusterip_configs); |
165 | WRITE_UNLOCK(&clusterip_lock); | 166 | write_unlock_bh(&clusterip_lock); |
166 | 167 | ||
167 | return c; | 168 | return c; |
168 | } | 169 | } |
@@ -172,25 +173,25 @@ clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum) | |||
172 | { | 173 | { |
173 | int i; | 174 | int i; |
174 | 175 | ||
175 | WRITE_LOCK(&clusterip_lock); | 176 | write_lock_bh(&clusterip_lock); |
176 | 177 | ||
177 | if (c->num_local_nodes >= CLUSTERIP_MAX_NODES | 178 | if (c->num_local_nodes >= CLUSTERIP_MAX_NODES |
178 | || nodenum > CLUSTERIP_MAX_NODES) { | 179 | || nodenum > CLUSTERIP_MAX_NODES) { |
179 | WRITE_UNLOCK(&clusterip_lock); | 180 | write_unlock_bh(&clusterip_lock); |
180 | return 1; | 181 | return 1; |
181 | } | 182 | } |
182 | 183 | ||
183 | /* check if we alrady have this number in our array */ | 184 | /* check if we alrady have this number in our array */ |
184 | for (i = 0; i < c->num_local_nodes; i++) { | 185 | for (i = 0; i < c->num_local_nodes; i++) { |
185 | if (c->local_nodes[i] == nodenum) { | 186 | if (c->local_nodes[i] == nodenum) { |
186 | WRITE_UNLOCK(&clusterip_lock); | 187 | write_unlock_bh(&clusterip_lock); |
187 | return 1; | 188 | return 1; |
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
191 | c->local_nodes[c->num_local_nodes++] = nodenum; | 192 | c->local_nodes[c->num_local_nodes++] = nodenum; |
192 | 193 | ||
193 | WRITE_UNLOCK(&clusterip_lock); | 194 | write_unlock_bh(&clusterip_lock); |
194 | return 0; | 195 | return 0; |
195 | } | 196 | } |
196 | 197 | ||
@@ -199,10 +200,10 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum) | |||
199 | { | 200 | { |
200 | int i; | 201 | int i; |
201 | 202 | ||
202 | WRITE_LOCK(&clusterip_lock); | 203 | write_lock_bh(&clusterip_lock); |
203 | 204 | ||
204 | if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) { | 205 | if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) { |
205 | WRITE_UNLOCK(&clusterip_lock); | 206 | write_unlock_bh(&clusterip_lock); |
206 | return 1; | 207 | return 1; |
207 | } | 208 | } |
208 | 209 | ||
@@ -211,12 +212,12 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum) | |||
211 | int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1)); | 212 | int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1)); |
212 | memmove(&c->local_nodes[i], &c->local_nodes[i+1], size); | 213 | memmove(&c->local_nodes[i], &c->local_nodes[i+1], size); |
213 | c->num_local_nodes--; | 214 | c->num_local_nodes--; |
214 | WRITE_UNLOCK(&clusterip_lock); | 215 | write_unlock_bh(&clusterip_lock); |
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
217 | } | 218 | } |
218 | 219 | ||
219 | WRITE_UNLOCK(&clusterip_lock); | 220 | write_unlock_bh(&clusterip_lock); |
220 | return 1; | 221 | return 1; |
221 | } | 222 | } |
222 | 223 | ||
@@ -286,21 +287,21 @@ clusterip_responsible(struct clusterip_config *config, u_int32_t hash) | |||
286 | { | 287 | { |
287 | int i; | 288 | int i; |
288 | 289 | ||
289 | READ_LOCK(&clusterip_lock); | 290 | read_lock_bh(&clusterip_lock); |
290 | 291 | ||
291 | if (config->num_local_nodes == 0) { | 292 | if (config->num_local_nodes == 0) { |
292 | READ_UNLOCK(&clusterip_lock); | 293 | read_unlock_bh(&clusterip_lock); |
293 | return 0; | 294 | return 0; |
294 | } | 295 | } |
295 | 296 | ||
296 | for (i = 0; i < config->num_local_nodes; i++) { | 297 | for (i = 0; i < config->num_local_nodes; i++) { |
297 | if (config->local_nodes[i] == hash) { | 298 | if (config->local_nodes[i] == hash) { |
298 | READ_UNLOCK(&clusterip_lock); | 299 | read_unlock_bh(&clusterip_lock); |
299 | return 1; | 300 | return 1; |
300 | } | 301 | } |
301 | } | 302 | } |
302 | 303 | ||
303 | READ_UNLOCK(&clusterip_lock); | 304 | read_unlock_bh(&clusterip_lock); |
304 | 305 | ||
305 | return 0; | 306 | return 0; |
306 | } | 307 | } |
@@ -578,7 +579,7 @@ static void *clusterip_seq_start(struct seq_file *s, loff_t *pos) | |||
578 | struct clusterip_config *c = pde->data; | 579 | struct clusterip_config *c = pde->data; |
579 | unsigned int *nodeidx; | 580 | unsigned int *nodeidx; |
580 | 581 | ||
581 | READ_LOCK(&clusterip_lock); | 582 | read_lock_bh(&clusterip_lock); |
582 | if (*pos >= c->num_local_nodes) | 583 | if (*pos >= c->num_local_nodes) |
583 | return NULL; | 584 | return NULL; |
584 | 585 | ||
@@ -608,7 +609,7 @@ static void clusterip_seq_stop(struct seq_file *s, void *v) | |||
608 | { | 609 | { |
609 | kfree(v); | 610 | kfree(v); |
610 | 611 | ||
611 | READ_UNLOCK(&clusterip_lock); | 612 | read_unlock_bh(&clusterip_lock); |
612 | } | 613 | } |
613 | 614 | ||
614 | static int clusterip_seq_show(struct seq_file *s, void *v) | 615 | static int clusterip_seq_show(struct seq_file *s, void *v) |