All of lore.kernel.org
 help / color / mirror / Atom feed
* Line numbering broken since bb34082d
@ 2008-06-13  9:14 Jan Engelhardt
  2008-06-13 10:59 ` [Patch] " Henrik Nordstrom
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Engelhardt @ 2008-06-13  9:14 UTC (permalink / raw)
  To: henrik; +Cc: Netfilter Developer Mailing List, kaber

Hi,


`iptables -nvL --lin`, starting with bb34082de, gives a wrong count:

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               
destination         
2        0     0 LOG        all  --  *      *       0.0.0.0/0            
0.0.0.0/0           LOG flags 0 level 4 


Yes, it starts with '2'. The offending part is 
because now you increased num before calling print_firewal.

-                       print_firewall(i,
-                                      ip6tc_get_target(i, handle),
-                                      num++,
-                                      format,
-                                      *handle);
+                       num++;
+                       if (!rulenum || num == rulenum)
+                               print_firewall(i,
+                                              ip6tc_get_target(i, handle),
+                                              num,
+                                              format,
+                                              *handle);

Moving down incrementing num solves the problem for me, but does it 
still do the right thing for num==rulenum? BTW, in the first iteration,
num==rulenum  is 1==0!

=====
commit 372dc8c92e1deae8d5942e889090347f415813d0
Author: Jan Engelhardt <jengelh@medozas.de>
Date:   Fri Jun 13 11:14:45 2008 +0200

    iptables: fix printing of line numbers with --line-numbers arg
    
    Commit bb34082d ("iptables --list chain rulenum") broke the line
    numbering, starting with printing an offset of 2.
    
    Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 ip6tables.c |    2 +-
 iptables.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip6tables.c b/ip6tables.c
index 8e135f1..54b8c4d 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -1092,7 +1092,6 @@ list_entries(const ip6t_chainlabel chain, int rulenum, int verbose, int numeric,
 
 		num = 0;
 		while (i) {
-			num++;
 			if (!rulenum || num == rulenum)
 				print_firewall(i,
 					       ip6tc_get_target(i, handle),
@@ -1100,6 +1099,7 @@ list_entries(const ip6t_chainlabel chain, int rulenum, int verbose, int numeric,
 					       format,
 					       *handle);
 			i = ip6tc_next_rule(i, handle);
+			++num;
 		}
 		found = 1;
 	}
diff --git a/iptables.c b/iptables.c
index cff8cf4..6b113ad 100644
--- a/iptables.c
+++ b/iptables.c
@@ -1095,7 +1095,6 @@ list_entries(const ipt_chainlabel chain, int rulenum, int verbose, int numeric,
 
 		num = 0;
 		while (i) {
-			num++;
 			if (!rulenum || num == rulenum)
 				print_firewall(i,
 					       iptc_get_target(i, handle),
@@ -1103,6 +1102,7 @@ list_entries(const ipt_chainlabel chain, int rulenum, int verbose, int numeric,
 					       format,
 					       *handle);
 			i = iptc_next_rule(i, handle);
+			++num;
 		}
 		found = 1;
 	}

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

end of thread, other threads:[~2008-06-13 15:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13  9:14 Line numbering broken since bb34082d Jan Engelhardt
2008-06-13 10:59 ` [Patch] " Henrik Nordstrom
2008-06-13 12:19   ` Jan Engelhardt
2008-06-13 15:58     ` Patrick McHardy

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.