diff options
author | Patrick McHardy <kaber@trash.net> | 2007-02-12 14:09:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-02-12 14:09:55 -0500 |
commit | d486dd1fb8573fad5b8dab61a7d1406116fd4baf (patch) | |
tree | f9cbb12e031beb6d0038846b731a62c0b85804d7 | |
parent | e4ba13088de7fa384087af398df6629fadb363ba (diff) |
[NETFILTER]: Switch nf_register_afinfo/nf_unregister_afinfo to mutex
The spinlock is only used in process context (register/unregister),
switch to a mutex.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/netfilter/core.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/netfilter/core.c b/net/netfilter/core.c index a66bd6af44fa..716603f05c02 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c | |||
@@ -22,29 +22,34 @@ | |||
22 | #include <linux/netdevice.h> | 22 | #include <linux/netdevice.h> |
23 | #include <linux/inetdevice.h> | 23 | #include <linux/inetdevice.h> |
24 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
25 | #include <linux/mutex.h> | ||
25 | #include <net/sock.h> | 26 | #include <net/sock.h> |
26 | 27 | ||
27 | #include "nf_internals.h" | 28 | #include "nf_internals.h" |
28 | 29 | ||
29 | static DEFINE_SPINLOCK(afinfo_lock); | 30 | static DEFINE_MUTEX(afinfo_mutex); |
30 | 31 | ||
31 | struct nf_afinfo *nf_afinfo[NPROTO] __read_mostly; | 32 | struct nf_afinfo *nf_afinfo[NPROTO] __read_mostly; |
32 | EXPORT_SYMBOL(nf_afinfo); | 33 | EXPORT_SYMBOL(nf_afinfo); |
33 | 34 | ||
34 | int nf_register_afinfo(struct nf_afinfo *afinfo) | 35 | int nf_register_afinfo(struct nf_afinfo *afinfo) |
35 | { | 36 | { |
36 | spin_lock(&afinfo_lock); | 37 | int err; |
38 | |||
39 | err = mutex_lock_interruptible(&afinfo_mutex); | ||
40 | if (err < 0) | ||
41 | return err; | ||
37 | rcu_assign_pointer(nf_afinfo[afinfo->family], afinfo); | 42 | rcu_assign_pointer(nf_afinfo[afinfo->family], afinfo); |
38 | spin_unlock(&afinfo_lock); | 43 | mutex_unlock(&afinfo_mutex); |
39 | return 0; | 44 | return 0; |
40 | } | 45 | } |
41 | EXPORT_SYMBOL_GPL(nf_register_afinfo); | 46 | EXPORT_SYMBOL_GPL(nf_register_afinfo); |
42 | 47 | ||
43 | void nf_unregister_afinfo(struct nf_afinfo *afinfo) | 48 | void nf_unregister_afinfo(struct nf_afinfo *afinfo) |
44 | { | 49 | { |
45 | spin_lock(&afinfo_lock); | 50 | mutex_lock(&afinfo_mutex); |
46 | rcu_assign_pointer(nf_afinfo[afinfo->family], NULL); | 51 | rcu_assign_pointer(nf_afinfo[afinfo->family], NULL); |
47 | spin_unlock(&afinfo_lock); | 52 | mutex_unlock(&afinfo_mutex); |
48 | synchronize_rcu(); | 53 | synchronize_rcu(); |
49 | } | 54 | } |
50 | EXPORT_SYMBOL_GPL(nf_unregister_afinfo); | 55 | EXPORT_SYMBOL_GPL(nf_unregister_afinfo); |