summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChander Govindarajan <mail@chandergovind.org>2022-05-25 15:25:43 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2022-05-31 10:21:34 +0200
commitc4ec825bea72951492408338ab23612c4d99cd2c (patch)
treec4baf9df1f375fe48a23d263079aebe2d1d99e81
parent4f6724f17c89eff4f2d472686d411dc2e93b365c (diff)
nft: simplify chain lookup in do_list_chain
use the chain_cache_find function for faster lookup of chain instead of iterating over all chains in table Signed-off-by: ChanderG <mail@chandergovind.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/rule.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rule.c b/src/rule.c
index 799092eb..7f61bdc1 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -2309,13 +2309,9 @@ static int do_list_chain(struct netlink_ctx *ctx, struct cmd *cmd,
table_print_declaration(table, &ctx->nft->output);
- list_for_each_entry(chain, &table->chain_cache.list, cache.list) {
- if (chain->handle.family != cmd->handle.family ||
- strcmp(cmd->handle.chain.name, chain->handle.chain.name) != 0)
- continue;
-
+ chain = chain_cache_find(table, cmd->handle.chain.name);
+ if (chain)
chain_print(chain, &ctx->nft->output);
- }
nft_print(&ctx->nft->output, "}\n");