Skip to contentSkip to conversation

Solves Bug 1388 - Combining --terse with --json has no effect (with test)

PATCH Applied Gopal 2 participants 2 messages Sep 22, 2020 netfilter

lore
Share & tools
lore

Gopal

author
#0 lore raw

PATCH 1/1 Solves Bug 1388 - Combining --terse with --json has no effect (with test)

From: Gopal Yadav <[email protected]>

Solves Bug 1388 - Combining --terse with --json has no effect (with test)

---
 src/json.c                                             | 2 +-
 tests/shell/testcases/listing/0021ruleset_json_terse_0 | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 tests/shell/testcases/listing/0021ruleset_json_terse_0
src/json.c +1 -1
index a9f5000f..5856f9fc 100644
@@ -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;
 
tests/shell/testcases/listing/0021ruleset_json_terse_0 new file +9 -0
new file mode 100644
index 00000000..3fa22565
@@ -0,0 +1,9 @@
+#!/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 }
+
+test $($NFT -j -t list ruleset | grep 192) || exit 0
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Gopal

From: Gopal Yadav <[email protected]>

Solves Bug 1388 - Combining --terse with --json has no effect (with test)

Applied, thanks.