From 528cbf99ff6062420270e637df4d40a77514fe56 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 7 Aug 2018 12:29:35 +0200 Subject: xtables: Fix for wrong counter format in -S output Legacy iptables uses '-c PCNT BCNT' format in listed rules, nft-variant used '[PCNT BCNT]' prefix like with iptables-save. In order to pass the counter format preference along, FMT_C_COUNTS is introduced and related 'format' checks adjusted. Since legacy iptables prints the counters between matches and target, this change affects save_matches_and_target() function. In order to get access to the rule counters, it's declaration is adjusted to receive iptables_command_state pointer instead of match, target and jumpto pointers from the same object. While being at it, integrate jump to user-defined chain into it as well since the related code in both callers was almost identical. Though since different rule flags are used between iptables and ip6tables, pass a 'goto_flag' boolean instead of the actual 'flags' bitfield. Signed-off-by: Phil Sutter Signed-off-by: Florian Westphal --- iptables/nft-ipv6.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'iptables/nft-ipv6.c') diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c index c651b16d..dd23557c 100644 --- a/iptables/nft-ipv6.c +++ b/iptables/nft-ipv6.c @@ -296,14 +296,8 @@ static void nft_ipv6_save_rule(const void *data, unsigned int format) cs->fw6.ipv6.iniface, cs->fw6.ipv6.iniface_mask, cs->fw6.ipv6.outiface, cs->fw6.ipv6.outiface_mask); - save_matches_and_target(cs->matches, cs->target, - cs->jumpto, cs->fw6.ipv6.flags, &cs->fw6); - - if (cs->target == NULL && strlen(cs->jumpto) > 0) { - printf("-%c %s", cs->fw6.ipv6.flags & IP6T_F_GOTO ? 'g' : 'j', - cs->jumpto); - } - printf("\n"); + save_matches_and_target(cs, cs->fw6.ipv6.flags & IP6T_F_GOTO, + &cs->fw6, format); } /* These are invalid numbers as upper layer protocol */ -- cgit v1.2.3