]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: Remove __init and __exit macro definitions.
authorVarsha Rao <rvarsha016@gmail.com>
Mon, 17 Jul 2017 11:59:07 +0000 (13:59 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jul 2017 12:26:31 +0000 (14:26 +0200)
Add nft_init and nft_exit functions, which calls _init and _exit
functions in main.c file. Remove __init and __exit macro definitions as
libnftables library will be created soon. Rename realm_table_init() and
realm_table_exit() functions to avoid ambiguity as
realm_table_rt_init(), realm_table_meta_init, realm_table_rt_exit() and
realm_table_meta_exit() in rt.c and meta.c files.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/nftables.h
include/utils.h
src/ct.c
src/datatype.c
src/gmputil.c
src/main.c
src/meta.c
src/rt.c
src/xt.c

index 70bf6b5ade4dcb877a6938da8fc9cc1ce174eeb9..640d3c7e715d8b1ad0d401878a66458511e25a95 100644 (file)
@@ -119,4 +119,20 @@ struct mnl_socket;
 int nft_run(struct nft_ctx *nft, struct mnl_socket *nf_sock, 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 realm_table_meta_init(void);
+void xt_init(void);
+void nft_init(void);
+
+void ct_label_table_exit(void);
+void mark_table_exit(void);
+void realm_table_meta_exit(void);
+void devgroup_table_exit(void);
+void realm_table_rt_exit(void);
+void nft_exit(void);
+
 #endif /* NFTABLES_NFTABLES_H */
index 3199388a3ab20e66052856447c7aa02b42245251..0605eeed3b06f4ac02b445e1d383295167b0276e 100644 (file)
@@ -32,8 +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__))
 
index 9b7140b352bb444d2955597ffbfded8fa96b93ab..d64f46724002a5f788c6cf94e763260265ec8b82 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -205,12 +205,12 @@ 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);
 }
 
-static void __exit ct_label_table_exit(void)
+void ct_label_table_exit(void)
 {
        rt_symbol_table_free(ct_label_tbl);
 }
index 287ca009a40c180bc5105398d21588e7b2d0cd79..5bd0c7b37a2b6ef12c23704c303db97d3d18b294 100644 (file)
@@ -719,12 +719,12 @@ 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");
 }
 
-static void __exit mark_table_exit(void)
+void mark_table_exit(void)
 {
        rt_symbol_table_free(mark_tbl);
 }
index c7637927d547bfb01dbb7dffd8402b502e68c71a..844ea6185b9ec39304a5b8207a537979c8fad093 100644 (file)
@@ -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);
 }
index 36b4bbc6f5cd99dd0c8ddde2f5f171cbfa7391c3..1535153ec815df0fce912c76d34a9f746ac14feb 100644 (file)
@@ -263,6 +263,28 @@ 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();
+       gmp_init();
+#ifdef HAVE_LIBXTABLES
+       xt_init();
+#endif
+}
+
+void nft_exit(void)
+{
+       ct_label_table_exit();
+       realm_table_rt_exit();
+       devgroup_table_exit();
+       realm_table_meta_exit();
+       mark_table_exit();
+}
+
 int main(int argc, char * const *argv)
 {
        struct parser_state state;
@@ -274,6 +296,7 @@ int main(int argc, char * const *argv)
        int i, val, rc = NFT_EXIT_SUCCESS;
        struct mnl_socket *nf_sock;
 
+       nft_init();
        nf_sock = netlink_open_sock();
        while (1) {
                val = getopt_long(argc, argv, OPTSTRING, options, NULL);
@@ -401,6 +424,7 @@ out:
        cache_release();
        iface_cache_release();
        netlink_close_sock(nf_sock);
+       nft_exit();
 
        return rc;
 }
index e9334b8642782669bae0b077e00fd64f836b6297..9c808930532eabf1079c55610cf4822ae3ba5f38 100644 (file)
 #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");
 }
 
-static void __exit realm_table_exit(void)
+void realm_table_meta_exit(void)
 {
        rt_symbol_table_free(realm_tbl);
 }
@@ -333,12 +333,12 @@ 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");
 }
 
-static void __exit devgroup_table_exit(void)
+void devgroup_table_exit(void)
 {
        rt_symbol_table_free(devgroup_tbl);
 }
index 530ebe6e3362bbc97f3b05c2c4f1ee76175148c4..cd2d5a4ed7b95c44a02a46ec44d73404b0665eab 100644 (file)
--- a/src/rt.c
+++ b/src/rt.c
 #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");
 }
 
-static void __exit realm_table_exit(void)
+void realm_table_rt_exit(void)
 {
        rt_symbol_table_free(realm_tbl);
 }
index e24b0af05bab071f2a0d2289b8a36ee3ef61d92c..9680f8ec4b0399cb4bb66186ea4f925fbaa4dfc6 100644 (file)
--- 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);