53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
From f02aa3764a48c2afd17761a211f70da941c71d00 Mon Sep 17 00:00:00 2001
|
|
From: Gopal Yadav <gopunop@gmail.com>
|
|
Date: Tue, 22 Sep 2020 13:55:33 +0530
|
|
Subject: json: Combining --terse with --json has no effect
|
|
|
|
--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>
|
|
Conflict: NA
|
|
Reference: http://git.netfilter.org/nftables/commit/?id=f02aa3764a48c2afd17761a211f70da941c71d00
|
|
|
|
---
|
|
src/json.c | 2 +-
|
|
tests/shell/testcases/listing/0021ruleset_json_terse_0 | 12 ++++++++++++
|
|
2 files changed, 13 insertions(+), 1 deletion(-)
|
|
create mode 100755 tests/shell/testcases/listing/0021ruleset_json_terse_0
|
|
|
|
diff --git a/src/json.c b/src/json.c
|
|
index a9f5000f..5856f9fc 100644
|
|
--- a/src/json.c
|
|
+++ b/src/json.c
|
|
@@ -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
|
|
index 00000000..c739ac3f
|
|
--- /dev/null
|
|
+++ b/tests/shell/testcases/listing/0021ruleset_json_terse_0
|
|
@@ -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
|
|
--
|
|
cgit v1.2.3
|