summaryrefslogtreecommitdiffstats
path: root/src/meta.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2019-08-08 00:30:28 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-08-08 12:03:57 +0200
commit45cb29a2ada4edfc2b547fe023d923ce0299a61d (patch)
treef47fb5792e1d6cfaad2ef7efe83fc37c2833b927 /src/meta.c
parenta805eab34e34aaf2f08c607e770ec0b8df992f4a (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/meta.c')
-rw-r--r--src/meta.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/meta.c b/src/meta.c
index 5c0c4e29..5901c991 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -37,17 +37,6 @@
#include <iface.h>
#include <json.h>
-static struct symbol_table *realm_tbl;
-void realm_table_meta_init(void)
-{
- realm_tbl = rt_symbol_table_init("/etc/iproute2/rt_realms");
-}
-
-void realm_table_meta_exit(void)
-{
- rt_symbol_table_free(realm_tbl);
-}
-
static void tchandle_type_print(const struct expr *expr,
struct output_ctx *octx)
{
@@ -341,29 +330,27 @@ const struct datatype pkttype_type = {
.sym_tbl = &pkttype_type_tbl,
};
-struct symbol_table *devgroup_tbl = NULL;
-
-void devgroup_table_init(void)
+void devgroup_table_init(struct nft_ctx *ctx)
{
- devgroup_tbl = rt_symbol_table_init("/etc/iproute2/group");
+ ctx->output.tbl.devgroup = rt_symbol_table_init("/etc/iproute2/group");
}
-void devgroup_table_exit(void)
+void devgroup_table_exit(struct nft_ctx *ctx)
{
- rt_symbol_table_free(devgroup_tbl);
+ rt_symbol_table_free(ctx->output.tbl.devgroup);
}
static void devgroup_type_print(const struct expr *expr,
- struct output_ctx *octx)
+ struct output_ctx *octx)
{
- return symbolic_constant_print(devgroup_tbl, expr, true, octx);
+ return symbolic_constant_print(octx->tbl.devgroup, expr, true, octx);
}
static struct error_record *devgroup_type_parse(struct parse_ctx *ctx,
const struct expr *sym,
struct expr **res)
{
- return symbolic_constant_parse(ctx, sym, devgroup_tbl, res);
+ return symbolic_constant_parse(ctx, sym, ctx->tbl->devgroup, res);
}
const struct datatype devgroup_type = {