Skip to contentSkip to conversation

nft: loop optimization

PATCH Applied Giuseppe Longo 2 participants 2 messages Jun 19, 2013 – Jun 20, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nft: loop optimization

This patch prevent in some functions to continue looping after the chain is found.

---
 iptables/nft.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
iptables/nft.c +7 -0
index d51f2f3..42bf50f 100644
@@ -1275,6 +1275,8 @@ int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table)
 
 		__nft_rule_flush(h, table_name, chain_name);
 
+		if (chain != NULL)
+			break;
 next:
 		c = nft_chain_list_iter_next(iter);
 	}
@@ -1390,6 +1392,9 @@ int nft_chain_user_del(struct nft_handle *h, const char *chain, const char *tabl
 			break;
 
 		deleted_ctr++;
+
+		if (chain != NULL)
+			break;
 next:
 		c = nft_chain_list_iter_next(iter);
 	}
@@ -2893,6 +2898,8 @@ int nft_chain_zero_counters(struct nft_handle *h, const char *chain,
 		if (ret < 0)
 			perror("mnl_talk:nft_chain_zero_counters");
 
+		if (chain != NULL)
+			break;
 next:
 		c = nft_chain_list_iter_next(iter);
 	}
maintainer Applied
#1 lore raw
Quoted 1 line · Giuseppe Longo

This patch prevent in some functions to continue looping after the chain is found.

Applied, thanks Giuseppe!