From c4ec825bea72951492408338ab23612c4d99cd2c Mon Sep 17 00:00:00 2001 From: Chander Govindarajan Date: Wed, 25 May 2022 15:25:43 +0530 Subject: 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 Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 8 ++------ 1 file 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"); -- cgit v1.2.3