diff options
author | Patrick McHardy <kaber@trash.net> | 2007-03-14 19:39:25 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:25:43 -0400 |
commit | a3c5029cf7a96da3acdf6884a21581b5bef310c3 (patch) | |
tree | c599a8870e199562f4937193f2b3dc3d56a55145 /net | |
parent | c6a1e615d1ba942b9e783079d53f741e4a8e1c89 (diff) |
[NETFILTER]: nfnetlink: use mutex instead of semaphore
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/nfnetlink.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index bf23e489e4cd..7865a47c981e 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
29 | #include <asm/system.h> | 29 | #include <asm/system.h> |
30 | #include <net/sock.h> | 30 | #include <net/sock.h> |
31 | #include <net/netlink.h> | ||
31 | #include <linux/init.h> | 32 | #include <linux/init.h> |
32 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
33 | 34 | ||
@@ -51,16 +52,28 @@ static char __initdata nfversion[] = "0.30"; | |||
51 | 52 | ||
52 | static struct sock *nfnl = NULL; | 53 | static struct sock *nfnl = NULL; |
53 | static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; | 54 | static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; |
54 | DECLARE_MUTEX(nfnl_sem); | 55 | static DEFINE_MUTEX(nfnl_mutex); |
55 | 56 | ||
56 | void nfnl_lock(void) | 57 | static void nfnl_lock(void) |
57 | { | 58 | { |
58 | nfnl_shlock(); | 59 | mutex_lock(&nfnl_mutex); |
59 | } | 60 | } |
60 | 61 | ||
61 | void nfnl_unlock(void) | 62 | static int nfnl_trylock(void) |
62 | { | 63 | { |
63 | nfnl_shunlock(); | 64 | return !mutex_trylock(&nfnl_mutex); |
65 | } | ||
66 | |||
67 | static void __nfnl_unlock(void) | ||
68 | { | ||
69 | mutex_unlock(&nfnl_mutex); | ||
70 | } | ||
71 | |||
72 | static void nfnl_unlock(void) | ||
73 | { | ||
74 | mutex_unlock(&nfnl_mutex); | ||
75 | if (nfnl->sk_receive_queue.qlen) | ||
76 | nfnl->sk_data_ready(nfnl, 0); | ||
64 | } | 77 | } |
65 | 78 | ||
66 | int nfnetlink_subsys_register(struct nfnetlink_subsystem *n) | 79 | int nfnetlink_subsys_register(struct nfnetlink_subsystem *n) |
@@ -248,11 +261,11 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, | |||
248 | ss = nfnetlink_get_subsys(type); | 261 | ss = nfnetlink_get_subsys(type); |
249 | if (!ss) { | 262 | if (!ss) { |
250 | #ifdef CONFIG_KMOD | 263 | #ifdef CONFIG_KMOD |
251 | /* don't call nfnl_shunlock, since it would reenter | 264 | /* don't call nfnl_unlock, since it would reenter |
252 | * with further packet processing */ | 265 | * with further packet processing */ |
253 | up(&nfnl_sem); | 266 | __nfnl_unlock(); |
254 | request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type)); | 267 | request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type)); |
255 | nfnl_shlock(); | 268 | nfnl_lock(); |
256 | ss = nfnetlink_get_subsys(type); | 269 | ss = nfnetlink_get_subsys(type); |
257 | if (!ss) | 270 | if (!ss) |
258 | #endif | 271 | #endif |
@@ -322,7 +335,7 @@ static void nfnetlink_rcv(struct sock *sk, int len) | |||
322 | do { | 335 | do { |
323 | struct sk_buff *skb; | 336 | struct sk_buff *skb; |
324 | 337 | ||
325 | if (nfnl_shlock_nowait()) | 338 | if (nfnl_trylock()) |
326 | return; | 339 | return; |
327 | 340 | ||
328 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 341 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
@@ -337,9 +350,9 @@ static void nfnetlink_rcv(struct sock *sk, int len) | |||
337 | kfree_skb(skb); | 350 | kfree_skb(skb); |
338 | } | 351 | } |
339 | 352 | ||
340 | /* don't call nfnl_shunlock, since it would reenter | 353 | /* don't call nfnl_unlock, since it would reenter |
341 | * with further packet processing */ | 354 | * with further packet processing */ |
342 | up(&nfnl_sem); | 355 | __nfnl_unlock(); |
343 | } while(nfnl && nfnl->sk_receive_queue.qlen); | 356 | } while(nfnl && nfnl->sk_receive_queue.qlen); |
344 | } | 357 | } |
345 | 358 | ||