[PATCH] nft: simplify chain lookup in do_list_chain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



use the chain_cache_find function for faster lookup of chain instead of
iterating over all chains in table

Signed-off-by: ChanderG <mail@xxxxxxxxxxxxxxxxx>
---
 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");

--
2.27.0



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux