]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
monitor: Fix printing of set declarations
authorPhil Sutter <phil@nwl.cc>
Tue, 25 Jul 2017 18:39:42 +0000 (20:39 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 27 Jul 2017 08:50:21 +0000 (10:50 +0200)
The optional attributes 'flags', 'gc-interval' and 'timeout' have to be
delimited by stmt_separator (either newline or semicolon), not 'nl'
which is set to whitespace by set_print_plain().

In order to restore readability, change stmt_separator to include a
single whitespace after the semicolon.

Here's monitor output for the following command:

| # nft add set ip t testset { type inet_service; \
| timeout 60s; gc-interval 120s; }

Before this patch:

| add set ip t testset { type inet_service;timeout 1m gc-interval 2m }

With this patch applied:

| add set ip t testset { type inet_service; timeout 1m; gc-interval 2m; }

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c
tests/monitor/testcases/set-maps.t
tests/monitor/testcases/set-mixed.t
tests/monitor/testcases/set-multiple.t
tests/monitor/testcases/set-simple.t

index 7f83980c60818a5bd78244819059c2da714b1697..12714ed3ccc709d4e3f3c5009e00617b158af09a 100644 (file)
@@ -335,18 +335,18 @@ static void set_print_declaration(const struct set *set,
                        printf("%stimeout", delim);
                        delim = ",";
                }
-               printf("%s", opts->nl);
+               printf("%s", opts->stmt_separator);
        }
 
        if (set->timeout) {
                printf("%s%stimeout ", opts->tab, opts->tab);
                time_print(set->timeout / 1000);
-               printf("%s", opts->nl);
+               printf("%s", opts->stmt_separator);
        }
        if (set->gc_int) {
                printf("%s%sgc-interval ", opts->tab, opts->tab);
                time_print(set->gc_int / 1000);
-               printf("%s", opts->nl);
+               printf("%s", opts->stmt_separator);
        }
 }
 
@@ -381,7 +381,7 @@ void set_print_plain(const struct set *s, struct output_ctx *octx)
                .nl             = " ",
                .table          = s->handle.table,
                .family         = family2str(s->handle.family),
-               .stmt_separator = ";",
+               .stmt_separator = "; ",
        };
 
        do_set_print(s, &opts, octx);
index d94016beb0767f6cdc4eb38978b2edfdc6c85827..6ea36cb9d11d6931c7ed1e246f2b2aab95769f82 100644 (file)
@@ -2,7 +2,7 @@
 I add table ip t
 O add table ip t
 I add map ip t portip { type inet_service: ipv4_addr; flags interval; }
-O add map ip t portip { type inet_service : ipv4_addr;flags interval }
+O add map ip t portip { type inet_service : ipv4_addr;flags interval; }
 
 I add element ip t portip { 80-100: 10.0.0.1 }
 O add element ip t portip { 80-100 : 10.0.0.1 }
index c4699edacec11b52d3cb4fb2c83f61c080e1b18a..2eb35b5aa1efb40ca900aed85963f9f0058b3240 100644 (file)
@@ -2,7 +2,7 @@
 I add table ip t
 O add table ip t
 I add set ip t portrange { type inet_service; flags interval; }
-O add set ip t portrange { type inet_service;flags interval }
+O add set ip t portrange { type inet_service;flags interval; }
 I add set ip t ports { type inet_service; }
 O add set ip t ports { type inet_service;}
 
index d94f941b39693d141890c8c02f433cd08dd382c7..ce919125a593f594e612540d5dbb255d34183427 100644 (file)
@@ -2,9 +2,9 @@
 I add table ip t
 O add table ip t
 I add set ip t portrange { type inet_service; flags interval; }
-O add set ip t portrange { type inet_service;flags interval }
+O add set ip t portrange { type inet_service;flags interval; }
 I add set ip t portrange2 { type inet_service; flags interval; }
-O add set ip t portrange2 { type inet_service;flags interval }
+O add set ip t portrange2 { type inet_service;flags interval; }
 
 # make sure concurrent adds work
 I add element ip t portrange { 1024-65535 }
index 22f648dbfa2322e8cdbbf1a969dd947476256f8b..e44cce08f575c7bfa1782d7dd878681629267e70 100644 (file)
@@ -2,7 +2,7 @@
 I add table ip t
 O add table ip t
 I add set ip t portrange { type inet_service; flags interval; }
-O add set ip t portrange { type inet_service;flags interval }
+O add set ip t portrange { type inet_service;flags interval; }
 
 # adding some ranges
 I add element ip t portrange { 1-10 }