]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables-compat: fix counter listing
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Tue, 23 Dec 2014 12:24:26 +0000 (13:24 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 23 Dec 2014 13:27:01 +0000 (14:27 +0100)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft-bridge.c
iptables/xtables-eb.c

index 9772b5fedaca28ccefa496430b30b72347c3e23a..807c4da0fd67fb1c8f0258a0a874da2ac76b22e7 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <netinet/ether.h>
+#include <inttypes.h>
 
 #include <xtables.h>
 #include <libiptc/libxtc.h>
@@ -470,6 +471,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);
 }
index 22ae4fdf1e1753ace2f02c19668bfec6d35b6d6b..d0f6a3e37bd88120e061800ecdf92ee805347f82 100644 (file)
@@ -486,14 +486,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)
@@ -505,6 +503,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);
 }
 
@@ -1269,7 +1270,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);
        }