diff options
author | Phil Sutter <phil@nwl.cc> | 2019-07-22 12:16:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-07-23 21:14:40 +0200 |
commit | 43a87268372a2d2da1ec0d95cee60da0a6f83bff (patch) | |
tree | b22a5a6bd0812f22f6643e773b9851346763530d /iptables/xtables-save.c | |
parent | 1b8210f84863115690332135f9cb58f679d447de (diff) |
ebtables-save: Fix counter formatting
The initial problem was 'ebtables-save -c' printing iptables-style
counters but at the same time not disabling ebtables-style counter
output (which was even printed in wrong format for ebtables-save).
The code around counter output was complicated enough to motivate a
larger rework:
* Make FMT_C_COUNTS indicate the appended counter style for ebtables.
* Use FMT_EBT_SAVE to distinguish between '-c' style counters and the
legacy pcnt/bcnt ones.
Consequently, ebtables-save sets format to:
FMT_NOCOUNTS - for no counters
FMT_EBT_SAVE - for iptables-style counters
FMT_EBT_SAVE | FMT_C_COUNTS - for '-c' style counters
For regular ebtables, list_rules() always sets FMT_C_COUNTS
(iptables-style counters are never used there) and FMT_NOCOUNTS if no
counters are requested.
The big plus is if neither FMT_NOCOUNTS nor FMT_C_COUNTS is set,
iptables-style counters are to be printed - both in iptables and
ebtables. This allows to drop the ebtables-specific 'save_counters'
callback.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/xtables-save.c')
-rw-r--r-- | iptables/xtables-save.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index b8d19705..491122f3 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -274,7 +274,8 @@ static int __ebt_save(struct nft_handle *h, const char *tablename, bool counters printf("*%s\n", tablename); if (counters) - format = ebt_legacy_counter_format ? FMT_EBT_SAVE : 0; + format = FMT_EBT_SAVE | + (ebt_legacy_counter_format ? FMT_C_COUNTS : 0); /* Dump out chain names first, * thereby preventing dependency conflicts */ |