]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Combining --terse with --json has no effect
authorGopal Yadav <gopunop@gmail.com>
Tue, 22 Sep 2020 08:25:33 +0000 (13:55 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 22 Sep 2020 21:26:18 +0000 (23:26 +0200)
--terse with --json is ignored, fix this. This patch also includes a test.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1388
Signed-off-by: Gopal Yadav <gopunop@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/json.c
tests/shell/testcases/listing/0021ruleset_json_terse_0 [new file with mode: 0755]

index a9f5000fe6d7cb2a992713466c5c64a8d5766340..5856f9fc3a4da8405c86d3c0b0b4b869ae5f745d 100644 (file)
@@ -140,7 +140,7 @@ static json_t *set_print_json(struct output_ctx *octx, const struct set *set)
                json_object_set_new(root, "gc-interval", tmp);
        }
 
-       if (set->init && set->init->size > 0) {
+       if (!nft_output_terse(octx) && set->init && set->init->size > 0) {
                json_t *array = json_array();
                const struct expr *i;
 
diff --git a/tests/shell/testcases/listing/0021ruleset_json_terse_0 b/tests/shell/testcases/listing/0021ruleset_json_terse_0
new file mode 100755 (executable)
index 0000000..c739ac3
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+$NFT flush ruleset
+$NFT add table ip test
+$NFT add chain ip test c
+$NFT add set ip test s { type ipv4_addr\; }
+$NFT add element ip test s { 192.168.3.4, 192.168.3.5 }
+
+if $NFT -j -t list ruleset | grep '192'
+then
+       exit 1
+fi