Commit d72367b6 authored by Harald Welte's avatar Harald Welte Committed by David S. Miller

[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: default avatarHarald Welte <laforge@netfilter.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bbd86b9f
......@@ -18,6 +18,8 @@
static struct nf_logger *nf_logging[NPROTO]; /* = NULL */
static DEFINE_SPINLOCK(nf_log_lock);
/* return EBUSY if somebody else is registered, EEXIST if the same logger
* is registred, 0 on success. */
int nf_log_register(int pf, struct nf_logger *logger)
{
int ret = -EBUSY;
......@@ -28,7 +30,9 @@ int nf_log_register(int pf, struct nf_logger *logger)
if (!nf_logging[pf]) {
rcu_assign_pointer(nf_logging[pf], logger);
ret = 0;
}
} else if (nf_logging[pf] == logger)
ret = -EEXIST;
spin_unlock(&nf_log_lock);
return ret;
}
......
......@@ -20,6 +20,8 @@ static struct nf_queue_rerouter *queue_rerouter;
static DEFINE_RWLOCK(queue_handler_lock);
/* return EBUSY when somebody else is registered, return EEXIST if the
* same handler is registered, return 0 in case of success. */
int nf_register_queue_handler(int pf, struct nf_queue_handler *qh)
{
int ret;
......@@ -28,7 +30,9 @@ int nf_register_queue_handler(int pf, struct nf_queue_handler *qh)
return -EINVAL;
write_lock_bh(&queue_handler_lock);
if (queue_handler[pf])
if (queue_handler[pf] == qh)
ret = -EEXIST;
else if (queue_handler[pf])
ret = -EBUSY;
else {
queue_handler[pf] = qh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment