diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-08-08 00:30:28 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-08-08 12:03:57 +0200 |
commit | 45cb29a2ada4edfc2b547fe023d923ce0299a61d (patch) | |
tree | f47fb5792e1d6cfaad2ef7efe83fc37c2833b927 /src/libnftables.c | |
parent | a805eab34e34aaf2f08c607e770ec0b8df992f4a (diff) |
src: remove global symbol_table
Store symbol tables in context object instead. Use the nft_ctx object to
store the dynamic symbol table. Pass it on to the parse_ctx object so
this can be accessed from the parse routines. This dynamic symbol table
is also accesible from the output_ctx object for print routines.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/libnftables.c')
-rw-r--r-- | src/libnftables.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/libnftables.c b/src/libnftables.c index 4a139c58..a693c0c6 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -84,26 +84,25 @@ out: return ret; } -static void nft_init(void) +static void nft_init(struct nft_ctx *ctx) { - mark_table_init(); - realm_table_rt_init(); - devgroup_table_init(); - realm_table_meta_init(); - ct_label_table_init(); + mark_table_init(ctx); + realm_table_rt_init(ctx); + devgroup_table_init(ctx); + ct_label_table_init(ctx); + gmp_init(); #ifdef HAVE_LIBXTABLES xt_init(); #endif } -static void nft_exit(void) +static void nft_exit(struct nft_ctx *ctx) { - ct_label_table_exit(); - realm_table_rt_exit(); - devgroup_table_exit(); - realm_table_meta_exit(); - mark_table_exit(); + ct_label_table_exit(ctx); + realm_table_rt_exit(ctx); + devgroup_table_exit(ctx); + mark_table_exit(ctx); } EXPORT_SYMBOL(nft_ctx_add_include_path); @@ -145,10 +144,10 @@ struct nft_ctx *nft_ctx_new(uint32_t flags) { struct nft_ctx *ctx; - nft_init(); ctx = xzalloc(sizeof(struct nft_ctx)); - ctx->state = xzalloc(sizeof(struct parser_state)); + nft_init(ctx); + ctx->state = xzalloc(sizeof(struct parser_state)); nft_ctx_add_include_path(ctx, DEFAULT_INCLUDE_PATH); ctx->parser_max_errors = 10; init_list_head(&ctx->cache.list); @@ -291,7 +290,7 @@ void nft_ctx_free(struct nft_ctx *ctx) nft_ctx_clear_include_paths(ctx); xfree(ctx->state); xfree(ctx); - nft_exit(); + nft_exit(ctx); } EXPORT_SYMBOL(nft_ctx_set_output); |