From 632ed15a9c9b2f4fd967c98e34a0d741903a9c3b Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 22 Jul 2019 12:16:26 +0200 Subject: xtables-save: Pass format flags to do_output() Let callers define the flags to pass to nft_rule_save() instead of just setting the counters boolean. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- iptables/xtables-save.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'iptables') diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index 249b3960..980a80ff 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -66,7 +66,7 @@ static const struct option ebt_save_options[] = { static bool ebt_legacy_counter_format; struct do_output_data { - bool counters; + unsigned int format; bool commit; }; @@ -98,7 +98,7 @@ __do_output(struct nft_handle *h, const char *tablename, void *data) /* Dump out chain names first, * thereby preventing dependency conflicts */ nft_chain_save(h, chain_list); - nft_rule_save(h, tablename, d->counters ? 0 : FMT_NOCOUNTS); + nft_rule_save(h, tablename, d->format); if (d->commit) printf("COMMIT\n"); @@ -139,7 +139,9 @@ xtables_save_main(int family, int argc, char *argv[], { const struct builtin_table *tables; const char *tablename = NULL; - struct do_output_data d = {}; + struct do_output_data d = { + .format = FMT_NOCOUNTS, + }; bool dump = false; struct nft_handle h = { .family = family, @@ -162,7 +164,7 @@ xtables_save_main(int family, int argc, char *argv[], fprintf(stderr, "-b/--binary option is not implemented\n"); break; case 'c': - d.counters = true; + d.format &= ~FMT_NOCOUNTS; break; case 't': -- cgit v1.2.3