diff mbox series

[nft] monitor: Don't print newgen message with JSON output

Message ID 20210217114323.25322-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] monitor: Don't print newgen message with JSON output | expand

Commit Message

Phil Sutter Feb. 17, 2021, 11:43 a.m. UTC
Iff this should be printed, it must adhere to output format settings. In
its current form it breaks JSON syntax, so skip it for non-default
output formats.

Fixes: cb7e02f44d6a6 ("src: enable json echo output when reading native syntax")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/monitor.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/src/monitor.c b/src/monitor.c
index af2998d4272b2..047d89db933a4 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -842,6 +842,9 @@  static int netlink_events_newgen_cb(const struct nlmsghdr *nlh, int type,
 	char name[256] = "";
 	int genid = -1, pid = -1;
 
+	if (monh->format != NFTNL_OUTPUT_DEFAULT)
+		return MNL_CB_OK;
+
 	mnl_attr_for_each(attr, nlh, sizeof(struct nfgenmsg)) {
 		switch (mnl_attr_get_type(attr)) {
 		case NFTA_GEN_ID: