netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nftables 1/2] monitor: add assignment check for json_echo
@ 2020-12-06 10:12 Jose M. Guisado Gomez
  2020-12-06 10:12 ` [PATCH nftables 2/2] monitor: fix formatting of if statements Jose M. Guisado Gomez
  2020-12-08 11:43 ` [PATCH nftables 1/2] monitor: add assignment check for json_echo Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Jose M. Guisado Gomez @ 2020-12-06 10:12 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

When --echo and --json is specified and native syntax is read, only the
last instruction is printed. This happens because the reference to the
json_echo is reassigned each time netlink_echo_callback is executed for
an instruction to be echoed.

Add an assignment check for json_echo to avoid reassigning it.

Fixes: cb7e02f4 (src: enable json echo output when reading native
syntax)
Signed-off-by: Jose M. Guisado Gomez <guigom@riseup.net>
---
 src/monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/monitor.c b/src/monitor.c
index a733a9f0..2b5325ea 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -939,8 +939,8 @@ int netlink_echo_callback(const struct nlmsghdr *nlh, void *data)
 	if (nft_output_json(&nft->output)) {
 		if (nft->json_root)
 			return json_events_cb(nlh, &echo_monh);
-
-		json_alloc_echo(nft);
+		if (!nft->json_echo)
+			json_alloc_echo(nft);
 		echo_monh.format = NFTNL_OUTPUT_JSON;
 	}
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-08 11:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-06 10:12 [PATCH nftables 1/2] monitor: add assignment check for json_echo Jose M. Guisado Gomez
2020-12-06 10:12 ` [PATCH nftables 2/2] monitor: fix formatting of if statements Jose M. Guisado Gomez
2020-12-08 11:45   ` Pablo Neira Ayuso
2020-12-08 11:43 ` [PATCH nftables 1/2] monitor: add assignment check for json_echo Pablo Neira Ayuso

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).