diff options
author | Varsha Rao <rvarsha016@gmail.com> | 2017-07-17 13:59:07 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-07-17 14:26:31 +0200 |
commit | d2b93afad7a67840d16d424b3cf5ce5255fca7ad (patch) | |
tree | 739c88495c1b33f9066bd38aa0545a88b25042f7 /src | |
parent | e0146fa254496dc12187053cd0cd6e5d20eb6a43 (diff) |
src: Remove __init and __exit macro definitions.
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/ct.c | 4 | ||||
-rw-r--r-- | src/datatype.c | 4 | ||||
-rw-r--r-- | src/gmputil.c | 2 | ||||
-rw-r--r-- | src/main.c | 24 | ||||
-rw-r--r-- | src/meta.c | 8 | ||||
-rw-r--r-- | src/rt.c | 4 | ||||
-rw-r--r-- | src/xt.c | 2 |
7 files changed, 36 insertions, 12 deletions
@@ -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); } diff --git a/src/datatype.c b/src/datatype.c index 287ca009..5bd0c7b3 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -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); } diff --git a/src/gmputil.c b/src/gmputil.c index c7637927..844ea618 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); } @@ -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; } @@ -37,12 +37,12 @@ #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); } @@ -24,12 +24,12 @@ #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); } @@ -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); |