[conntrack-tools] netlink: refactorize several nl_init_*_handler() functions
Pablo Neira
netfilter-cvslog-bounces at lists.netfilter.org
Fri Feb 6 14:44:08 CET 2009
Gitweb: http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=c3ef4d9b32ca653571f0976f73aaa99218a36db0
commit c3ef4d9b32ca653571f0976f73aaa99218a36db0
Author: Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Thu Feb 5 21:28:02 2009 +0100
Commit: Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Thu Feb 5 21:28:02 2009 +0100
netlink: refactorize several nl_init_*_handler() functions
This patch removes:
* nl_init_dump_handler()
* nl_init_request_handler()
* nl_init_resync_handler()
since they all look very similar.
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
via c3ef4d9b32ca653571f0976f73aaa99218a36db0 (commit)
from 9a29b01005868fef138651e9bc831e179a767b89 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c3ef4d9b32ca653571f0976f73aaa99218a36db0
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date: Thu Feb 5 21:28:02 2009 +0100
netlink: refactorize several nl_init_*_handler() functions
This patch removes:
* nl_init_dump_handler()
* nl_init_request_handler()
* nl_init_resync_handler()
since they all look very similar.
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
-----------------------------------------------------------------------
include/netlink.h | 3 ---
src/netlink.c | 36 ------------------------------------
src/run.c | 8 +++++---
3 files changed, 5 insertions(+), 42 deletions(-)
This patch removes:
* nl_init_dump_handler()
* nl_init_request_handler()
* nl_init_resync_handler()
since they all look very similar.
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
diff --git a/include/netlink.h b/include/netlink.h
index 9d67165..0df0cbb 100644
--- a/include/netlink.h
+++ b/include/netlink.h
@@ -7,9 +7,6 @@ struct nf_conntrack;
struct nfct_handle;
struct nfct_handle *nl_init_event_handler(void);
-struct nfct_handle *nl_init_dump_handler(void);
-struct nfct_handle *nl_init_request_handler(void);
-struct nfct_handle *nl_init_resync_handler(void);
struct nlif_handle *nl_init_interface_handler(void);
int nl_send_resync(struct nfct_handle *h);
diff --git a/src/netlink.c b/src/netlink.c
index a9e3d2d..78cc466 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -79,42 +79,6 @@ struct nfct_handle *nl_init_event_handler(void)
return h;
}
-struct nfct_handle *nl_init_dump_handler(void)
-{
- struct nfct_handle *h;
-
- /* open dump netlink socket */
- h = nfct_open(CONNTRACK, 0);
- if (h == NULL)
- return NULL;
-
- return h;
-}
-
-struct nfct_handle *nl_init_resync_handler(void)
-{
- struct nfct_handle *h;
-
- h = nfct_open(CONNTRACK, 0);
- if (h == NULL)
- return NULL;
-
- fcntl(nfct_fd(h), F_SETFL, O_NONBLOCK);
-
- return h;
-}
-
-struct nfct_handle *nl_init_request_handler(void)
-{
- struct nfct_handle *h;
-
- h = nfct_open(CONNTRACK, 0);
- if (h == NULL)
- return NULL;
-
- return h;
-}
-
struct nlif_handle *nl_init_interface_handler(void)
{
struct nlif_handle *h;
diff --git a/src/run.c b/src/run.c
index a483ab3..7d48865 100644
--- a/src/run.c
+++ b/src/run.c
@@ -33,6 +33,7 @@
#include <sys/wait.h>
#include <string.h>
#include <time.h>
+#include <fcntl.h>
void killer(int foo)
{
@@ -317,7 +318,7 @@ init(void)
register_fd(nfct_fd(STATE(event)), STATE(fds));
}
- STATE(dump) = nl_init_dump_handler();
+ STATE(dump) = nfct_open(CONNTRACK, 0);
if (STATE(dump) == NULL) {
dlog(LOG_ERR, "can't open netlink handler: %s",
strerror(errno));
@@ -331,7 +332,7 @@ init(void)
return -1;
}
- STATE(resync) = nl_init_resync_handler();
+ STATE(resync) = nfct_open(CONNTRACK, 0);
if (STATE(resync)== NULL) {
dlog(LOG_ERR, "can't open netlink handler: %s",
strerror(errno));
@@ -343,9 +344,10 @@ init(void)
STATE(mode)->resync,
NULL);
register_fd(nfct_fd(STATE(resync)), STATE(fds));
+ fcntl(nfct_fd(STATE(resync)), F_SETFL, O_NONBLOCK);
/* no callback, it does not do anything with the output */
- STATE(request) = nl_init_request_handler();
+ STATE(request) = nfct_open(CONNTRACK, 0);
if (STATE(request) == NULL) {
dlog(LOG_ERR, "can't open netlink handler: %s",
strerror(errno));
More information about the netfilter-cvslog
mailing list