From c3ef4d9b32ca653571f0976f73aaa99218a36db0 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Feb 2009 21:28:02 +0100 Subject: 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 --- include/netlink.h | 3 --- src/netlink.c | 36 ------------------------------------ src/run.c | 8 +++++--- 3 files changed, 5 insertions(+), 42 deletions(-) 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 #include #include +#include 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)); -- cgit v1.2.3