netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next] ip: ipneigh: json: print ndm_flags as boolean attributes
@ 2019-12-26 14:44 Julien Fortin
  2019-12-26 17:04 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Fortin @ 2019-12-26 14:44 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dsahern, Julien Fortin

From: Julien Fortin <julien@cumulusnetworks.com>

Today the following attributes are printed as json "null" attributes
NTF_ROUTER
NTF_PROXY
NTF_EXT_LEARNED
NTF_OFFLOADED

$ ip -j neigh show
[
  {
    "dst": "10.0.2.2",
    "dev": "enp0s3",
    "lladdr": "52:54:00:12:35:02",
    "router": null,
    "proxy": null,
    "extern_learn": null,
    "offload": null,
    "state": [
      "REACHABLE"
    ]
  }
]

The goal of this patch is to replace those null attributes with booleans

$ ip -j neigh show
[
  {
    "dst": "10.0.2.2",
    "dev": "enp0s3",
    "lladdr": "52:54:00:12:35:02",
    "router": true,
    "proxy": true,
    "extern_learn": true,
    "offload": true,
    "state": [
      "REACHABLE"
    ]
  }
]

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
---
 ip/ipneigh.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index 678b4034..b1f212f4 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -380,16 +380,16 @@ int print_neigh(struct nlmsghdr *n, void *arg)
 	}
 
 	if (r->ndm_flags & NTF_ROUTER)
-		print_null(PRINT_ANY, "router", " %s", "router");
+		print_bool(PRINT_ANY, "router", " router", true);
 
 	if (r->ndm_flags & NTF_PROXY)
-		print_null(PRINT_ANY, "proxy", " %s", "proxy");
+		print_bool(PRINT_ANY, "proxy", " proxy", true);
 
 	if (r->ndm_flags & NTF_EXT_LEARNED)
-		print_null(PRINT_ANY, "extern_learn", " %s ", "extern_learn");
+		print_bool(PRINT_ANY, "extern_learn", " extern_learn ", true);
 
 	if (r->ndm_flags & NTF_OFFLOADED)
-		print_null(PRINT_ANY, "offload", " %s", "offload");
+		print_bool(PRINT_ANY, "offload", " offload", true);
 
 	if (show_stats) {
 		if (tb[NDA_CACHEINFO])
-- 
2.23.0


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

end of thread, other threads:[~2019-12-30 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-26 14:44 [PATCH iproute2-next] ip: ipneigh: json: print ndm_flags as boolean attributes Julien Fortin
2019-12-26 17:04 ` Stephen Hemminger
2019-12-30 17:38   ` David Ahern

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