aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-25 04:41:10 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-25 04:41:10 -0500
commit9e19bb6d7a0959f5028d46e1ab99c50f0d36eda8 (patch)
treef6b3044e9bd57053f066f1dc087e1927d0088b43 /net/netfilter
parentcef2685e0053945ea0f3c02297386b040f486ea7 (diff)
[NETFILTER] x_table.c: sem2mutex
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/x_tables.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 0a29a24d9a7..a657ab5394c 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -21,10 +21,12 @@
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
24#include <linux/mutex.h>
24 25
25#include <linux/netfilter/x_tables.h> 26#include <linux/netfilter/x_tables.h>
26#include <linux/netfilter_arp.h> 27#include <linux/netfilter_arp.h>
27 28
29
28MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
29MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 31MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
30MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module"); 32MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
@@ -32,7 +34,7 @@ MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
32#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1)) 34#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
33 35
34struct xt_af { 36struct xt_af {
35 struct semaphore mutex; 37 struct mutex mutex;
36 struct list_head match; 38 struct list_head match;
37 struct list_head target; 39 struct list_head target;
38 struct list_head tables; 40 struct list_head tables;
@@ -64,11 +66,11 @@ xt_register_target(struct xt_target *target)
64{ 66{
65 int ret, af = target->family; 67 int ret, af = target->family;
66 68
67 ret = down_interruptible(&xt[af].mutex); 69 ret = mutex_lock_interruptible(&xt[af].mutex);
68 if (ret != 0) 70 if (ret != 0)
69 return ret; 71 return ret;
70 list_add(&target->list, &xt[af].target); 72 list_add(&target->list, &xt[af].target);
71 up(&xt[af].mutex); 73 mutex_unlock(&xt[af].mutex);
72 return ret; 74 return ret;
73} 75}
74EXPORT_SYMBOL(xt_register_target); 76EXPORT_SYMBOL(xt_register_target);
@@ -78,9 +80,9 @@ xt_unregister_target(struct xt_target *target)
78{ 80{
79 int af = target->family; 81 int af = target->family;
80 82
81 down(&xt[af].mutex); 83 mutex_lock(&xt[af].mutex);
82 LIST_DELETE(&xt[af].target, target); 84 LIST_DELETE(&xt[af].target, target);
83 up(&xt[af].mutex); 85 mutex_unlock(&xt[af].mutex);
84} 86}
85EXPORT_SYMBOL(xt_unregister_target); 87EXPORT_SYMBOL(xt_unregister_target);
86 88
@@ -89,12 +91,12 @@ xt_register_match(struct xt_match *match)
89{ 91{
90 int ret, af = match->family; 92 int ret, af = match->family;
91 93
92 ret = down_interruptible(&xt[af].mutex); 94 ret = mutex_lock_interruptible(&xt[af].mutex);
93 if (ret != 0) 95 if (ret != 0)
94 return ret; 96 return ret;
95 97
96 list_add(&match->list, &xt[af].match); 98 list_add(&match->list, &xt[af].match);
97 up(&xt[af].mutex); 99 mutex_unlock(&xt[af].mutex);
98 100
99 return ret; 101 return ret;
100} 102}
@@ -105,9 +107,9 @@ xt_unregister_match(struct xt_match *match)
105{ 107{
106 int af = match->family; 108 int af = match->family;
107 109
108 down(&xt[af].mutex); 110 mutex_lock(&xt[af].mutex);
109 LIST_DELETE(&xt[af].match, match); 111 LIST_DELETE(&xt[af].match, match);
110 up(&xt[af].mutex); 112 mutex_unlock(&xt[af].mutex);
111} 113}
112EXPORT_SYMBOL(xt_unregister_match); 114EXPORT_SYMBOL(xt_unregister_match);
113 115
@@ -124,21 +126,21 @@ struct xt_match *xt_find_match(int af, const char *name, u8 revision)
124 struct xt_match *m; 126 struct xt_match *m;
125 int err = 0; 127 int err = 0;
126 128
127 if (down_interruptible(&xt[af].mutex) != 0) 129 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
128 return ERR_PTR(-EINTR); 130 return ERR_PTR(-EINTR);
129 131
130 list_for_each_entry(m, &xt[af].match, list) { 132 list_for_each_entry(m, &xt[af].match, list) {
131 if (strcmp(m->name, name) == 0) { 133 if (strcmp(m->name, name) == 0) {
132 if (m->revision == revision) { 134 if (m->revision == revision) {
133 if (try_module_get(m->me)) { 135 if (try_module_get(m->me)) {
134 up(&xt[af].mutex); 136 mutex_unlock(&xt[af].mutex);
135 return m; 137 return m;
136 } 138 }
137 } else 139 } else
138 err = -EPROTOTYPE; /* Found something. */ 140 err = -EPROTOTYPE; /* Found something. */
139 } 141 }
140 } 142 }
141 up(&xt[af].mutex); 143 mutex_unlock(&xt[af].mutex);
142 return ERR_PTR(err); 144 return ERR_PTR(err);
143} 145}
144EXPORT_SYMBOL(xt_find_match); 146EXPORT_SYMBOL(xt_find_match);
@@ -149,21 +151,21 @@ struct xt_target *xt_find_target(int af, const char *name, u8 revision)
149 struct xt_target *t; 151 struct xt_target *t;
150 int err = 0; 152 int err = 0;
151 153
152 if (down_interruptible(&xt[af].mutex) != 0) 154 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
153 return ERR_PTR(-EINTR); 155 return ERR_PTR(-EINTR);
154 156
155 list_for_each_entry(t, &xt[af].target, list) { 157 list_for_each_entry(t, &xt[af].target, list) {
156 if (strcmp(t->name, name) == 0) { 158 if (strcmp(t->name, name) == 0) {
157 if (t->revision == revision) { 159 if (t->revision == revision) {
158 if (try_module_get(t->me)) { 160 if (try_module_get(t->me)) {
159 up(&xt[af].mutex); 161 mutex_unlock(&xt[af].mutex);
160 return t; 162 return t;
161 } 163 }
162 } else 164 } else
163 err = -EPROTOTYPE; /* Found something. */ 165 err = -EPROTOTYPE; /* Found something. */
164 } 166 }
165 } 167 }
166 up(&xt[af].mutex); 168 mutex_unlock(&xt[af].mutex);
167 return ERR_PTR(err); 169 return ERR_PTR(err);
168} 170}
169EXPORT_SYMBOL(xt_find_target); 171EXPORT_SYMBOL(xt_find_target);
@@ -218,7 +220,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
218{ 220{
219 int have_rev, best = -1; 221 int have_rev, best = -1;
220 222
221 if (down_interruptible(&xt[af].mutex) != 0) { 223 if (mutex_lock_interruptible(&xt[af].mutex) != 0) {
222 *err = -EINTR; 224 *err = -EINTR;
223 return 1; 225 return 1;
224 } 226 }
@@ -226,7 +228,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
226 have_rev = target_revfn(af, name, revision, &best); 228 have_rev = target_revfn(af, name, revision, &best);
227 else 229 else
228 have_rev = match_revfn(af, name, revision, &best); 230 have_rev = match_revfn(af, name, revision, &best);
229 up(&xt[af].mutex); 231 mutex_unlock(&xt[af].mutex);
230 232
231 /* Nothing at all? Return 0 to try loading module. */ 233 /* Nothing at all? Return 0 to try loading module. */
232 if (best == -1) { 234 if (best == -1) {
@@ -352,20 +354,20 @@ struct xt_table *xt_find_table_lock(int af, const char *name)
352{ 354{
353 struct xt_table *t; 355 struct xt_table *t;
354 356
355 if (down_interruptible(&xt[af].mutex) != 0) 357 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
356 return ERR_PTR(-EINTR); 358 return ERR_PTR(-EINTR);
357 359
358 list_for_each_entry(t, &xt[af].tables, list) 360 list_for_each_entry(t, &xt[af].tables, list)
359 if (strcmp(t->name, name) == 0 && try_module_get(t->me)) 361 if (strcmp(t->name, name) == 0 && try_module_get(t->me))
360 return t; 362 return t;
361 up(&xt[af].mutex); 363 mutex_unlock(&xt[af].mutex);
362 return NULL; 364 return NULL;
363} 365}
364EXPORT_SYMBOL_GPL(xt_find_table_lock); 366EXPORT_SYMBOL_GPL(xt_find_table_lock);
365 367
366void xt_table_unlock(struct xt_table *table) 368void xt_table_unlock(struct xt_table *table)
367{ 369{
368 up(&xt[table->af].mutex); 370 mutex_unlock(&xt[table->af].mutex);
369} 371}
370EXPORT_SYMBOL_GPL(xt_table_unlock); 372EXPORT_SYMBOL_GPL(xt_table_unlock);
371 373
@@ -405,7 +407,7 @@ int xt_register_table(struct xt_table *table,
405 int ret; 407 int ret;
406 struct xt_table_info *private; 408 struct xt_table_info *private;
407 409
408 ret = down_interruptible(&xt[table->af].mutex); 410 ret = mutex_lock_interruptible(&xt[table->af].mutex);
409 if (ret != 0) 411 if (ret != 0)
410 return ret; 412 return ret;
411 413
@@ -431,7 +433,7 @@ int xt_register_table(struct xt_table *table,
431 433
432 ret = 0; 434 ret = 0;
433 unlock: 435 unlock:
434 up(&xt[table->af].mutex); 436 mutex_unlock(&xt[table->af].mutex);
435 return ret; 437 return ret;
436} 438}
437EXPORT_SYMBOL_GPL(xt_register_table); 439EXPORT_SYMBOL_GPL(xt_register_table);
@@ -440,10 +442,10 @@ void *xt_unregister_table(struct xt_table *table)
440{ 442{
441 struct xt_table_info *private; 443 struct xt_table_info *private;
442 444
443 down(&xt[table->af].mutex); 445 mutex_lock(&xt[table->af].mutex);
444 private = table->private; 446 private = table->private;
445 LIST_DELETE(&xt[table->af].tables, table); 447 LIST_DELETE(&xt[table->af].tables, table);
446 up(&xt[table->af].mutex); 448 mutex_unlock(&xt[table->af].mutex);
447 449
448 return private; 450 return private;
449} 451}
@@ -507,7 +509,7 @@ static void *xt_tgt_seq_start(struct seq_file *seq, loff_t *pos)
507 if (!list) 509 if (!list)
508 return NULL; 510 return NULL;
509 511
510 if (down_interruptible(&xt[af].mutex) != 0) 512 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
511 return NULL; 513 return NULL;
512 514
513 return xt_get_idx(list, seq, *pos); 515 return xt_get_idx(list, seq, *pos);
@@ -536,7 +538,7 @@ static void xt_tgt_seq_stop(struct seq_file *seq, void *v)
536 struct proc_dir_entry *pde = seq->private; 538 struct proc_dir_entry *pde = seq->private;
537 u_int16_t af = (unsigned long)pde->data & 0xffff; 539 u_int16_t af = (unsigned long)pde->data & 0xffff;
538 540
539 up(&xt[af].mutex); 541 mutex_unlock(&xt[af].mutex);
540} 542}
541 543
542static int xt_name_seq_show(struct seq_file *seq, void *v) 544static int xt_name_seq_show(struct seq_file *seq, void *v)
@@ -668,7 +670,7 @@ static int __init xt_init(void)
668 return -ENOMEM; 670 return -ENOMEM;
669 671
670 for (i = 0; i < NPROTO; i++) { 672 for (i = 0; i < NPROTO; i++) {
671 init_MUTEX(&xt[i].mutex); 673 mutex_init(&xt[i].mutex);
672 INIT_LIST_HEAD(&xt[i].target); 674 INIT_LIST_HEAD(&xt[i].target);
673 INIT_LIST_HEAD(&xt[i].match); 675 INIT_LIST_HEAD(&xt[i].match);
674 INIT_LIST_HEAD(&xt[i].tables); 676 INIT_LIST_HEAD(&xt[i].tables);