]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables-save: Pass format flags to do_output()
authorPhil Sutter <phil@nwl.cc>
Mon, 22 Jul 2019 10:16:26 +0000 (12:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 23 Jul 2019 19:14:40 +0000 (21:14 +0200)
Let callers define the flags to pass to nft_rule_save() instead of just
setting the counters boolean.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/xtables-save.c

index 249b396091af4b5b7ad37ac21db4f3df97b5148d..980a80ff06f96ff8c28e7afe3726c776b0799055 100644 (file)
@@ -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':