include: Remove __init macro definition.
PATCH 1/1 include: Remove __init macro definition.
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 <[email protected]>
--- include/nftables.h | 16 +++++++++++++++- include/utils.h | 1 - src/ct.c | 4 ++-- src/datatype.c | 2 +- src/exthdr.c | 2 +- src/fib.c | 2 +- src/gmputil.c | 2 +- src/main.c | 20 ++++++++++++++++++++ src/meta.c | 6 +++--- src/netlink.c | 2 +- src/proto.c | 2 +- src/rt.c | 4 ++-- src/xt.c | 2 +- 13 files changed, 49 insertions(+), 16 deletions(-)
include/nftables.h +15 -1
@@ -112,5 +112,19 @@ struct parser_state;int nft_run (void *scanner,struct parser_state *state,struct list_head *msgs,struct output_ctx *octx); - +void ct_label_table_init (void ); +void ct_init (void ); +void mark_table_init (void ); +void exthdr_init (void ); +void fib_init (void ); +void gmp_init (void ); +void realm_table_rt_init (void ); +void devgroup_table_init (void ); +void meta_init (void ); +void netlink_open_sock (void ); +void proto_init (void ); +void realm_table_meta_init (void ); +void rt_init (void ); +void xt_init (void ); +void nft_init (void );#endif /* NFTABLES_NFTABLES_H */
include/utils.h +0 -1
@@ -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__))
src/ct.c +2 -2
@@ -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 ); }
@@ -486,7 +486,7 @@ struct stmt *notrack_stmt_alloc(const struct location *loc)return stmt_alloc (loc, ¬rack_stmt_ops); } -static void __init ct_init (void ) +void ct_init (void ) {datatype_register (&ct_state_type);datatype_register (&ct_dir_type);
src/datatype.c +1 -1
@@ -704,7 +704,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" ); }
src/exthdr.c +1 -1
@@ -344,7 +344,7 @@ const struct exthdr_desc exthdr_mh = { }, }; -static void __init exthdr_init (void ) +void exthdr_init (void ) {datatype_register (&mh_type_type); }
src/fib.c +1 -1
@@ -142,7 +142,7 @@ struct expr *fib_expr_alloc(const struct location *loc,return expr; } -static void __init fib_init (void ) +void fib_init (void ) {datatype_register (&fib_addr_type); }
src/gmputil.c +1 -1
@@ -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 ); }
src/main.c +20 -0
@@ -255,6 +255,25 @@ err1:return ret; } +void nft_init (void ) +{ +mark_table_init (); +proto_init (); +exthdr_init (); +fib_init (); +realm_table_rt_init (); +devgroup_table_init (); +meta_init (); +realm_table_meta_init (); +rt_init (); +ct_label_table_init (); +ct_init (); +netlink_open_sock (); +gmp_init (); +#ifdef HAVE_LIBXTABLES +xt_init (); +#endif +}int main (int argc,char *const *argv) {struct parser_state state;
@@ -265,6 +284,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 )
src/meta.c +3 -3
@@ -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" ); }
@@ -356,7 +356,7 @@ static 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" ); }
@@ -621,7 +621,7 @@ struct stmt *meta_stmt_alloc(const struct location *loc, enum nft_meta_keys key,return stmt; } -static void __init meta_init (void ) +void meta_init (void ) {datatype_register (&ifindex_type);datatype_register (&realm_type);
src/netlink.c +1 -1
@@ -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 );
src/proto.c +1 -1
@@ -961,7 +961,7 @@ const struct proto_desc proto_netdev = { }, }; -static void __init proto_init (void ) +void proto_init (void ) {datatype_register (&icmp_type_type);datatype_register (&tcp_flag_type);
src/rt.c +2 -2
@@ -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" ); }
@@ -135,7 +135,7 @@ void rt_expr_update_type(struct proto_ctx *ctx, struct expr *expr) } } -static void __init rt_init (void ) +void rt_init (void ) {datatype_register (&realm_type); }
src/xt.c +1 -1
@@ -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 );
Signature · 1 line
2.9.4