From 8a3b2e7327a3057b5976df4af387b8143aad6110 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 25 Jul 2017 20:39:42 +0200 Subject: monitor: Fix printing of set declarations 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 Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 7f83980c..12714ed3 100644 --- a/src/rule.c +++ b/src/rule.c @@ -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); -- cgit v1.2.3