All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: giuseppelng@gmail.com, pablo@netfilter.org
Subject: [ebtables-compat PATCH] ebtables-compat: fix counter listing
Date: Tue, 23 Dec 2014 13:24:26 +0100	[thread overview]
Message-ID: <20141223122426.22985.47607.stgit@nfdev.cica.es> (raw)

With this patch:

% sudo ebtables-compat -L --Lc
Bridge table: filter

Bridge chain: INPUT, entries: 0, policy: ACCEPT
-j ACCEPT , pcnt = 123 -- bcnt = 123

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 iptables/nft-bridge.c |    5 +++++
 iptables/xtables-eb.c |   12 +++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c
index a1bd906..98f8a4e 100644
--- a/iptables/nft-bridge.c
+++ b/iptables/nft-bridge.c
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <netinet/ether.h>
+#include <inttypes.h>
 
 #include <xtables.h>
 #include <libiptc/libxtc.h>
@@ -464,6 +465,10 @@ static void nft_bridge_print_firewall(struct nft_rule *r, unsigned int num,
 		}
 	}
 
+	if (!(format & FMT_NOCOUNTS))
+		printf(" , pcnt = %"PRIu64" -- bcnt = %"PRIu64"",
+		       (uint64_t)cs.counters.pcnt, (uint64_t)cs.counters.bcnt);
+
 	if (!(format & FMT_NONEWLINE))
 		fputc('\n', stdout);
 }
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index b924daf..9d13868 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -443,14 +443,12 @@ static void print_help(const struct xtables_target *t,
 /* Execute command L */
 static int list_rules(struct nft_handle *h, const char *chain, const char *table,
 		      int rule_nr, int verbose, int numeric, int expanded,
-		      int linenumbers)
+		      int linenumbers, int counters)
 {
 	unsigned int format;
 
 	format = FMT_OPTIONS;
-	if (!verbose)
-		format |= FMT_NOCOUNTS;
-	else
+	if (verbose)
 		format |= FMT_VIA;
 
 	if (numeric)
@@ -462,6 +460,9 @@ static int list_rules(struct nft_handle *h, const char *chain, const char *table
 	if (linenumbers)
 		format |= FMT_LINENUMBERS;
 
+	if (!counters)
+		format |= FMT_NOCOUNTS;
+
 	return nft_rule_list(h, chain, table, rule_nr, format);
 }
 
@@ -1179,7 +1180,8 @@ check_extension: */
 				 flags&OPT_VERBOSE,
 				 flags&OPT_NUMERIC,
 				 /*flags&OPT_EXPANDED*/0,
-				 flags&LIST_N);
+				 flags&LIST_N,
+				 flags & LIST_C);
 		if (!(flags & OPT_ZERO) && exec_style == EXEC_STYLE_PRG)
 			exit(0);
 	}


             reply	other threads:[~2014-12-23 12:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 12:24 Arturo Borrero Gonzalez [this message]
2014-12-23 13:28 ` [ebtables-compat PATCH] ebtables-compat: fix counter listing Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141223122426.22985.47607.stgit@nfdev.cica.es \
    --to=arturo.borrero.glez@gmail.com \
    --cc=giuseppelng@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.