From 5ec5c706d993a68502801433c3bb2bcbb078efff Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 29 Apr 2021 22:23:05 +0200 Subject: cache: add hashtable cache for table Add a hashtable for fast table lookups. Tables that reside in the cache use the table->cache_hlist and table->cache_list heads. Table that are created from command line / ruleset are also added to the cache. Signed-off-by: Pablo Neira Ayuso --- src/libnftables.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libnftables.c') diff --git a/src/libnftables.c b/src/libnftables.c index 56c51a61..e080eb03 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -105,6 +105,7 @@ static void nft_init(struct nft_ctx *ctx) static void nft_exit(struct nft_ctx *ctx) { + cache_free(&ctx->cache.table_cache); expr_handler_exit(); ct_label_table_exit(ctx); realm_table_rt_exit(ctx); @@ -166,7 +167,7 @@ struct nft_ctx *nft_ctx_new(uint32_t flags) 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); + cache_init(&ctx->cache.table_cache); ctx->top_scope = scope_alloc(); ctx->flags = flags; ctx->output.output_fp = stdout; -- cgit v1.2.3