ebtables-compat: fix counter listing
PATCH 1/1 ebtables-compat: fix counter listing
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 <[email protected]>
--- iptables/nft-bridge.c | 5 +++++ iptables/xtables-eb.c | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-)
iptables/nft-bridge.c +5 -0
@@ -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); }
iptables/xtables-eb.c +7 -5
@@ -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 *tableif (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 ); }
Quoted 7 lines · Arturo Borrero Gonzalez
With this patch:
% sudo ebtables-compat -L --Lc
Bridge table: filterBridge chain: INPUT, entries: 0, policy: ACCEPT
-j ACCEPT , pcnt = 123 -- bcnt = 123
Applied to the ebtables-compat-experimental branch, thanks.