From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Leblond Subject: [PATCH 3/7] netfilter: bind at registration if no logger is already set. Date: Mon, 9 Feb 2009 22:11:12 +0100 Message-ID: <1234213876-8176-3-git-send-email-eric@inl.fr> References: <49909B3E.0@inl.fr> Cc: netfilter-devel@vger.kernel.org, Eric Leblond To: kaber@trash.net Return-path: Received: from bayen.regit.org ([81.57.69.189]:36899 "EHLO ice-age" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753723AbZBIVLW (ORCPT ); Mon, 9 Feb 2009 16:11:22 -0500 In-Reply-To: <49909B3E.0@inl.fr> Sender: netfilter-devel-owner@vger.kernel.org List-ID: This patch adds a bind operation when registration is done and when there is currently no logger defined for the protocol. This emulates the first registered wins policy and thus achieves backward compatibility. Signed-off-by: Eric Leblond --- net/netfilter/nf_log.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index a1dcd46..1655a1f 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c @@ -35,6 +35,7 @@ static struct nf_logger *__find_logger(int pf, const char *str_logger) int nf_log_register(u_int8_t pf, struct nf_logger *logger) { int ret; + const struct nf_logger *llog; if (pf >= ARRAY_SIZE(nf_loggers)) return -EINVAL; @@ -58,13 +59,17 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger) if (__find_logger(pf, logger->name) == NULL) { ret = 0; INIT_LIST_HEAD(&(logger->list[pf])); - /* register at end of list to honor first register win */ list_add_tail(&(logger->list[pf]), &nf_loggers_l[pf]); + llog = rcu_dereference(nf_loggers[pf]); + if (llog == NULL) + rcu_assign_pointer(nf_loggers[pf], logger); } } spin_unlock_bh(&nf_log_lock); + + synchronize_rcu(); return ret; } EXPORT_SYMBOL(nf_log_register); -- 1.5.6.3