netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gopal <gopunop@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Gopal Yadav <gopunop@gmail.com>
Subject: [PATCH] Solves Bug 1388 - Combining --terse with --json has no effect (with test)
Date: Tue, 22 Sep 2020 13:55:33 +0530	[thread overview]
Message-ID: <20200922082533.20920-1-gopunop@gmail.com> (raw)

From: Gopal Yadav <gopunop@gmail.com>

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

Signed-off-by: Gopal Yadav <gopunop@gmail.com>
---
 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

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 100644
index 00000000..3fa22565
--- /dev/null
+++ b/tests/shell/testcases/listing/0021ruleset_json_terse_0
@@ -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
-- 
2.17.1


             reply	other threads:[~2020-09-22  8:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  8:25 Gopal [this message]
2020-09-22 21:10 ` [PATCH] Solves Bug 1388 - Combining --terse with --json has no effect (with test) Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200922082533.20920-1-gopunop@gmail.com \
    --to=gopunop@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).