All of lore.kernel.org
 help / color / mirror / Atom feed
* [iptables-nftables PATCH v2] src: display rule by number
@ 2013-07-12 11:27 Giuseppe Longo
  2013-07-12 11:50 ` Tomasz Bursztyka
  2013-07-15 11:12 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Giuseppe Longo @ 2013-07-12 11:27 UTC (permalink / raw)
  To: netfilter-devel

This patch fixes the display of rule by number.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
---
 iptables/nft.c               |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/iptables/nft.c b/iptables/nft.c
index 98d602c..7ff9c70 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2450,19 +2450,19 @@ __nft_rule_list(struct nft_handle *h, struct nft_chain *c, const char *table,
 		    strcmp(chain, rule_chain) != 0)
 			goto next;
 
-		if (rulenum > 0) {
+		if (rulenum > 0 && rule_ctr != rulenum) {
 			/* List by rule number case */
-			if (rule_ctr != rulenum) {
-				rule_ctr++;
-				goto next;
-			}
-		} else {
-			struct iptables_command_state cs = {};
-			/* Show all rules case */
-			nft_rule_to_iptables_command_state(r, &cs);
-
-			cb(&cs, r, rule_ctr, format);
+			goto next;
 		}
+		
+		struct iptables_command_state cs = {};
+		/* Show all rules case */
+		nft_rule_to_iptables_command_state(r, &cs);
+
+		cb(&cs, r, rule_ctr, format);
+		if (rulenum > 0 && rule_ctr == rulenum)
+			break; 
+
 next:
 		r = nft_rule_list_iter_next(iter);
 	}


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-15 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12 11:27 [iptables-nftables PATCH v2] src: display rule by number Giuseppe Longo
2013-07-12 11:50 ` Tomasz Bursztyka
2013-07-15 11:12 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.