diff options
author | Denis V. Lunev <den@openvz.org> | 2007-10-11 00:13:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-11 00:13:32 -0400 |
commit | 3b71535f357a2e5d013a44a06b0c26a6a8d8fb5b (patch) | |
tree | 259158a50b97626063a4c779e8cb2ed81c911555 /net/netfilter/nfnetlink.c | |
parent | 1536cc0d55a2820b71daf912060fe43ec15630c2 (diff) |
[NET]: Make netlink processing routines semi-synchronious (inspired by rtnl) v2
The code in netfilter/nfnetlink.c and in ./net/netlink/genetlink.c looks
like outdated copy/paste from rtnetlink.c. Push them into sync with the
original.
Changes from v1:
- deleted comment in nfnetlink_rcv_msg by request of Patrick McHardy
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter/nfnetlink.c')
-rw-r--r-- | net/netfilter/nfnetlink.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index cb41990f92e..99775af19ff 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
@@ -44,26 +44,14 @@ static struct sock *nfnl = NULL; | |||
44 | static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; | 44 | static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT]; |
45 | static DEFINE_MUTEX(nfnl_mutex); | 45 | static DEFINE_MUTEX(nfnl_mutex); |
46 | 46 | ||
47 | static void nfnl_lock(void) | 47 | static inline void nfnl_lock(void) |
48 | { | 48 | { |
49 | mutex_lock(&nfnl_mutex); | 49 | mutex_lock(&nfnl_mutex); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int nfnl_trylock(void) | 52 | static inline void nfnl_unlock(void) |
53 | { | ||
54 | return !mutex_trylock(&nfnl_mutex); | ||
55 | } | ||
56 | |||
57 | static void __nfnl_unlock(void) | ||
58 | { | ||
59 | mutex_unlock(&nfnl_mutex); | ||
60 | } | ||
61 | |||
62 | static void nfnl_unlock(void) | ||
63 | { | 53 | { |
64 | mutex_unlock(&nfnl_mutex); | 54 | mutex_unlock(&nfnl_mutex); |
65 | if (nfnl->sk_receive_queue.qlen) | ||
66 | nfnl->sk_data_ready(nfnl, 0); | ||
67 | } | 55 | } |
68 | 56 | ||
69 | int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n) | 57 | int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n) |
@@ -147,9 +135,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
147 | ss = nfnetlink_get_subsys(type); | 135 | ss = nfnetlink_get_subsys(type); |
148 | if (!ss) { | 136 | if (!ss) { |
149 | #ifdef CONFIG_KMOD | 137 | #ifdef CONFIG_KMOD |
150 | /* don't call nfnl_unlock, since it would reenter | 138 | nfnl_unlock(); |
151 | * with further packet processing */ | ||
152 | __nfnl_unlock(); | ||
153 | request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type)); | 139 | request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type)); |
154 | nfnl_lock(); | 140 | nfnl_lock(); |
155 | ss = nfnetlink_get_subsys(type); | 141 | ss = nfnetlink_get_subsys(type); |
@@ -188,10 +174,9 @@ static void nfnetlink_rcv(struct sock *sk, int len) | |||
188 | unsigned int qlen = 0; | 174 | unsigned int qlen = 0; |
189 | 175 | ||
190 | do { | 176 | do { |
191 | if (nfnl_trylock()) | 177 | nfnl_lock(); |
192 | return; | ||
193 | qlen = netlink_run_queue(sk, qlen, nfnetlink_rcv_msg); | 178 | qlen = netlink_run_queue(sk, qlen, nfnetlink_rcv_msg); |
194 | __nfnl_unlock(); | 179 | nfnl_unlock(); |
195 | } while (qlen); | 180 | } while (qlen); |
196 | } | 181 | } |
197 | 182 | ||