aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-02-12 14:11:39 -0500
committerDavid S. Miller <davem@davemloft.net>2007-02-12 14:11:39 -0500
commit9b73534dc57fa2fd5ef567586adb83c16e88a52f (patch)
tree7ebf77f9dc34f06acfac126ce496442a5735625e /net
parent9dc6aa5fcfc104becd86c89c5e7ec90e840e0163 (diff)
[NETFILTER]: nf_log: switch logger registration/unregistration 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>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_log.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 814bab700db6..243d66b1c02c 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -15,27 +15,31 @@
15#define NF_LOG_PREFIXLEN 128 15#define NF_LOG_PREFIXLEN 128
16 16
17static struct nf_logger *nf_logging[NPROTO]; /* = NULL */ 17static struct nf_logger *nf_logging[NPROTO]; /* = NULL */
18static DEFINE_SPINLOCK(nf_log_lock); 18static DEFINE_MUTEX(nf_log_mutex);
19 19
20/* return EBUSY if somebody else is registered, EEXIST if the same logger 20/* return EBUSY if somebody else is registered, EEXIST if the same logger
21 * is registred, 0 on success. */ 21 * is registred, 0 on success. */
22int nf_log_register(int pf, struct nf_logger *logger) 22int nf_log_register(int pf, struct nf_logger *logger)
23{ 23{
24 int ret = -EBUSY; 24 int ret;
25 25
26 if (pf >= NPROTO) 26 if (pf >= NPROTO)
27 return -EINVAL; 27 return -EINVAL;
28 28
29 /* Any setup of logging members must be done before 29 /* Any setup of logging members must be done before
30 * substituting pointer. */ 30 * substituting pointer. */
31 spin_lock(&nf_log_lock); 31 ret = mutex_lock_interruptible(&nf_log_mutex);
32 if (!nf_logging[pf]) { 32 if (ret < 0)
33 return ret;
34
35 if (!nf_logging[pf])
33 rcu_assign_pointer(nf_logging[pf], logger); 36 rcu_assign_pointer(nf_logging[pf], logger);
34 ret = 0; 37 else if (nf_logging[pf] == logger)
35 } else if (nf_logging[pf] == logger)
36 ret = -EEXIST; 38 ret = -EEXIST;
39 else
40 ret = -EBUSY;
37 41
38 spin_unlock(&nf_log_lock); 42 mutex_unlock(&nf_log_mutex);
39 return ret; 43 return ret;
40} 44}
41EXPORT_SYMBOL(nf_log_register); 45EXPORT_SYMBOL(nf_log_register);
@@ -44,9 +48,9 @@ void nf_log_unregister_pf(int pf)
44{ 48{
45 if (pf >= NPROTO) 49 if (pf >= NPROTO)
46 return; 50 return;
47 spin_lock(&nf_log_lock); 51 mutex_lock(&nf_log_mutex);
48 rcu_assign_pointer(nf_logging[pf], NULL); 52 rcu_assign_pointer(nf_logging[pf], NULL);
49 spin_unlock(&nf_log_lock); 53 mutex_unlock(&nf_log_mutex);
50 54
51 /* Give time to concurrent readers. */ 55 /* Give time to concurrent readers. */
52 synchronize_rcu(); 56 synchronize_rcu();
@@ -57,12 +61,12 @@ void nf_log_unregister_logger(struct nf_logger *logger)
57{ 61{
58 int i; 62 int i;
59 63
60 spin_lock(&nf_log_lock); 64 mutex_lock(&nf_log_mutex);
61 for (i = 0; i < NPROTO; i++) { 65 for (i = 0; i < NPROTO; i++) {
62 if (nf_logging[i] == logger) 66 if (nf_logging[i] == logger)
63 rcu_assign_pointer(nf_logging[i], NULL); 67 rcu_assign_pointer(nf_logging[i], NULL);
64 } 68 }
65 spin_unlock(&nf_log_lock); 69 mutex_unlock(&nf_log_mutex);
66 70
67 synchronize_rcu(); 71 synchronize_rcu();
68} 72}