From a3ac2527724dd27628e12caaa55f731b109e4586 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 1 Apr 2021 22:19:30 +0200 Subject: src: split chain list in table This patch splits table->lists in two: - Chains that reside in the cache are stored in the new tables->cache_chain and tables->cache_chain_ht. The hashtable chain cache allows for fast chain lookups. - Chains that defined via command line / ruleset file reside in tables->chains. Note that chains in the cache (already in the kernel) are not placed in the table->chains. By keeping separated lists, chains defined via command line / ruleset file can be added to cache. Signed-off-by: Pablo Neira Ayuso --- src/json.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/json.c') diff --git a/src/json.c b/src/json.c index defbc8fb..14e403fe 100644 --- a/src/json.c +++ b/src/json.c @@ -1584,7 +1584,7 @@ static json_t *table_print_json_full(struct netlink_ctx *ctx, tmp = flowtable_print_json(flowtable); json_array_append_new(root, tmp); } - list_for_each_entry(chain, &table->chains, list) { + list_for_each_entry(chain, &table->cache_chain, cache_list) { tmp = chain_print_json(chain); json_array_append_new(root, tmp); @@ -1646,7 +1646,7 @@ static json_t *do_list_chain_json(struct netlink_ctx *ctx, struct chain *chain; struct rule *rule; - list_for_each_entry(chain, &table->chains, list) { + list_for_each_entry(chain, &table->cache_chain, cache_list) { if (chain->handle.family != cmd->handle.family || strcmp(cmd->handle.chain.name, chain->handle.chain.name)) continue; @@ -1674,7 +1674,7 @@ static json_t *do_list_chains_json(struct netlink_ctx *ctx, struct cmd *cmd) cmd->handle.family != table->handle.family) continue; - list_for_each_entry(chain, &table->chains, list) { + list_for_each_entry(chain, &table->cache_chain, cache_list) { json_t *tmp = chain_print_json(chain); json_array_append_new(root, tmp); -- cgit v1.2.3