netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Varsha Rao <rvarsha016@gmail.com>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 2/3] include: Remove __init macro definition.
Date: Fri, 30 Jun 2017 14:57:12 +0530	[thread overview]
Message-ID: <252529ca943916a9b9473b7a443460a6559dc8d2.1498814530.git.rvarsha016@gmail.com> (raw)
In-Reply-To: <cover.1498814530.git.rvarsha016@gmail.com>

Add nft_init function, which calls _init functions in main.c file.
Remove __init macro definition as libnftables library will be created
soon. Rename realm_table_init() function to avoid ambiguity as
realm_table_rt_init() and realm_table_meta_init() in rt.c and meta.c
files.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
 include/nftables.h |  9 +++++++++
 include/utils.h    |  1 -
 src/ct.c           |  2 +-
 src/datatype.c     |  2 +-
 src/gmputil.c      |  2 +-
 src/main.c         | 15 +++++++++++++++
 src/meta.c         |  4 ++--
 src/netlink.c      |  2 +-
 src/rt.c           |  2 +-
 src/xt.c           |  2 +-
 10 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/include/nftables.h b/include/nftables.h
index 26fd344..b188b9e 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -117,5 +117,14 @@ struct parser_state;
 
 int nft_run(struct nft_ctx *nft, void *scanner, struct parser_state *state,
 	    struct list_head *msgs);
+void ct_label_table_init(void);
+void mark_table_init(void);
+void gmp_init(void);
+void realm_table_rt_init(void);
+void devgroup_table_init(void);
+void netlink_open_sock(void);
+void realm_table_meta_init(void);
+void xt_init(void);
+void nft_init(void);
 
 #endif /* NFTABLES_NFTABLES_H */
diff --git a/include/utils.h b/include/utils.h
index 3199388..0c3341b 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -32,7 +32,6 @@
 #define __gmp_fmtstring(x, y)
 #endif
 
-#define __init			__attribute__((constructor))
 #define __exit			__attribute__((destructor))
 #define __must_check		__attribute__((warn_unused_result))
 #define __noreturn		__attribute__((__noreturn__))
diff --git a/src/ct.c b/src/ct.c
index 9b7140b..25efc70 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -205,7 +205,7 @@ static const struct datatype ct_label_type = {
 	.parse		= ct_label_type_parse,
 };
 
-static void __init ct_label_table_init(void)
+void ct_label_table_init(void)
 {
 	ct_label_tbl = rt_symbol_table_init(CONNLABEL_CONF);
 }
diff --git a/src/datatype.c b/src/datatype.c
index b3c8f66..4f74c06 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -717,7 +717,7 @@ void rt_symbol_table_free(struct symbol_table *tbl)
 }
 
 static struct symbol_table *mark_tbl;
-static void __init mark_table_init(void)
+void mark_table_init(void)
 {
 	mark_tbl = rt_symbol_table_init("/etc/iproute2/rt_marks");
 }
diff --git a/src/gmputil.c b/src/gmputil.c
index c763792..844ea61 100644
--- a/src/gmputil.c
+++ b/src/gmputil.c
@@ -207,7 +207,7 @@ static void *gmp_xrealloc(void *ptr, size_t old_size, size_t new_size)
 	return xrealloc(ptr, new_size);
 }
 
-static void __init gmp_init(void)
+void gmp_init(void)
 {
 	mp_set_memory_functions(xmalloc, gmp_xrealloc, NULL);
 }
diff --git a/src/main.c b/src/main.c
index 7fbf00a..301bce0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -262,6 +262,20 @@ err1:
 	return ret;
 }
 
+void nft_init(void)
+{
+        mark_table_init();
+        realm_table_rt_init();
+        devgroup_table_init();
+        realm_table_meta_init();
+        ct_label_table_init();
+        netlink_open_sock();
+        gmp_init();
+#ifdef HAVE_LIBXTABLES
+         xt_init();
+#endif
+}
+
 int main(int argc, char * const *argv)
 {
 	struct parser_state state;
@@ -272,6 +286,7 @@ int main(int argc, char * const *argv)
 	bool interactive = false;
 	int i, val, rc = NFT_EXIT_SUCCESS;
 
+	nft_init();
 	while (1) {
 		val = getopt_long(argc, argv, OPTSTRING, options, NULL);
 		if (val == -1)
diff --git a/src/meta.c b/src/meta.c
index e9334b8..4fb26d5 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -37,7 +37,7 @@
 #include <iface.h>
 
 static struct symbol_table *realm_tbl;
-static void __init realm_table_init(void)
+void realm_table_meta_init(void)
 {
 	realm_tbl = rt_symbol_table_init("/etc/iproute2/rt_realms");
 }
@@ -333,7 +333,7 @@ const struct datatype pkttype_type = {
 };
 
 static struct symbol_table *devgroup_tbl;
-static void __init devgroup_table_init(void)
+void devgroup_table_init(void)
 {
 	devgroup_tbl = rt_symbol_table_init("/etc/iproute2/group");
 }
diff --git a/src/netlink.c b/src/netlink.c
index 880502c..3993aa1 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -61,7 +61,7 @@ static struct mnl_socket *nfsock_open(void)
 	return s;
 }
 
-static void __init netlink_open_sock(void)
+void netlink_open_sock(void)
 {
 	nf_sock = nfsock_open();
 	fcntl(mnl_socket_get_fd(nf_sock), F_SETFL, O_NONBLOCK);
diff --git a/src/rt.c b/src/rt.c
index 530ebe6..5f57cf0 100644
--- a/src/rt.c
+++ b/src/rt.c
@@ -24,7 +24,7 @@
 #include <rule.h>
 
 static struct symbol_table *realm_tbl;
-static void __init realm_table_init(void)
+void realm_table_rt_init(void)
 {
 	realm_tbl = rt_symbol_table_init("/etc/iproute2/rt_realms");
 }
diff --git a/src/xt.c b/src/xt.c
index e24b0af..9680f8e 100644
--- a/src/xt.c
+++ b/src/xt.c
@@ -351,7 +351,7 @@ static struct xtables_globals xt_nft_globals = {
 	.compat_rev		= nft_xt_compatible_revision,
 };
 
-static void __init xt_init(void)
+void xt_init(void)
 {
 	/* Default to IPv4, but this changes in runtime */
 	xtables_init_all(&xt_nft_globals, NFPROTO_IPV4);
-- 
2.9.4


  parent reply	other threads:[~2017-06-30  9:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  9:24 [PATCH nft 0/3] include: Remove datatype_register(), __init and __exit macros Varsha Rao
2017-06-30  9:26 ` [PATCH nft 1/3] include: Remove datatype_register() Varsha Rao
2017-06-30 10:45   ` Pablo Neira Ayuso
2017-06-30  9:27 ` Varsha Rao [this message]
2017-06-30 10:56   ` [PATCH nft 2/3] include: Remove __init macro definition Pablo Neira Ayuso
2017-06-30  9:28 ` [PATCH nft 3/3] include: Remove __exit " Varsha Rao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=252529ca943916a9b9473b7a443460a6559dc8d2.1498814530.git.rvarsha016@gmail.com \
    --to=rvarsha016@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).