diff options
author | Harald Welte <laforge@netfilter.org> | 2005-08-09 23:23:36 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:51:21 -0400 |
commit | d72367b6f36e557f122beefaa8c6b80eb1c7f245 (patch) | |
tree | 650d0bdca48e7f3ea6bc356f6aa868f34c6a226f | |
parent | bbd86b9fc469b7e91dc7444e6abb8930811d79cb (diff) |
[NETFILTER]: more verbose return codes from nf_{log,queue}
This adds EEXIST to distinguish between the following return values:
0: nobody was registered, registration successful
EEXIST: the exact same handler was already registered, no registration
required
EBUSY: somebody else is registered, registration unsuccessful.
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/netfilter/nf_log.c | 6 | ||||
-rw-r--r-- | net/netfilter/nf_queue.c | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index 31a9d63921d6..e104760f7a67 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c | |||
@@ -18,6 +18,8 @@ | |||
18 | static struct nf_logger *nf_logging[NPROTO]; /* = NULL */ | 18 | static struct nf_logger *nf_logging[NPROTO]; /* = NULL */ |
19 | static DEFINE_SPINLOCK(nf_log_lock); | 19 | static DEFINE_SPINLOCK(nf_log_lock); |
20 | 20 | ||
21 | /* return EBUSY if somebody else is registered, EEXIST if the same logger | ||
22 | * is registred, 0 on success. */ | ||
21 | int nf_log_register(int pf, struct nf_logger *logger) | 23 | int nf_log_register(int pf, struct nf_logger *logger) |
22 | { | 24 | { |
23 | int ret = -EBUSY; | 25 | int ret = -EBUSY; |
@@ -28,7 +30,9 @@ int nf_log_register(int pf, struct nf_logger *logger) | |||
28 | if (!nf_logging[pf]) { | 30 | if (!nf_logging[pf]) { |
29 | rcu_assign_pointer(nf_logging[pf], logger); | 31 | rcu_assign_pointer(nf_logging[pf], logger); |
30 | ret = 0; | 32 | ret = 0; |
31 | } | 33 | } else if (nf_logging[pf] == logger) |
34 | ret = -EEXIST; | ||
35 | |||
32 | spin_unlock(&nf_log_lock); | 36 | spin_unlock(&nf_log_lock); |
33 | return ret; | 37 | return ret; |
34 | } | 38 | } |
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index 8a67bde8b640..d10d552d9c40 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c | |||
@@ -20,6 +20,8 @@ static struct nf_queue_rerouter *queue_rerouter; | |||
20 | 20 | ||
21 | static DEFINE_RWLOCK(queue_handler_lock); | 21 | static DEFINE_RWLOCK(queue_handler_lock); |
22 | 22 | ||
23 | /* return EBUSY when somebody else is registered, return EEXIST if the | ||
24 | * same handler is registered, return 0 in case of success. */ | ||
23 | int nf_register_queue_handler(int pf, struct nf_queue_handler *qh) | 25 | int nf_register_queue_handler(int pf, struct nf_queue_handler *qh) |
24 | { | 26 | { |
25 | int ret; | 27 | int ret; |
@@ -28,7 +30,9 @@ int nf_register_queue_handler(int pf, struct nf_queue_handler *qh) | |||
28 | return -EINVAL; | 30 | return -EINVAL; |
29 | 31 | ||
30 | write_lock_bh(&queue_handler_lock); | 32 | write_lock_bh(&queue_handler_lock); |
31 | if (queue_handler[pf]) | 33 | if (queue_handler[pf] == qh) |
34 | ret = -EEXIST; | ||
35 | else if (queue_handler[pf]) | ||
32 | ret = -EBUSY; | 36 | ret = -EBUSY; |
33 | else { | 37 | else { |
34 | queue_handler[pf] = qh; | 38 | queue_handler[pf] = qh; |