* [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
* Re: [PATCH iproute2-next] ip: ipneigh: json: print ndm_flags as boolean attributes
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
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2019-12-26 17:04 UTC (permalink / raw)
To: Julien Fortin; +Cc: netdev, roopa, dsahern
On Thu, 26 Dec 2019 15:44:15 +0100
Julien Fortin <julien@cumulusnetworks.com> wrote:
> 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"
> ]
> }
> ]
No, this was intentional. Null is a standard method in JSON
to encode an option being present.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2-next] ip: ipneigh: json: print ndm_flags as boolean attributes
2019-12-26 17:04 ` Stephen Hemminger
@ 2019-12-30 17:38 ` David Ahern
0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2019-12-30 17:38 UTC (permalink / raw)
To: Stephen Hemminger, Julien Fortin; +Cc: netdev, roopa, dsahern
On 12/26/19 10:04 AM, Stephen Hemminger wrote:
> On Thu, 26 Dec 2019 15:44:15 +0100
> Julien Fortin <julien@cumulusnetworks.com> wrote:
>
>> 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"
>> ]
>> }
>> ]
>
>
> No, this was intentional. Null is a standard method in JSON
> to encode an option being present.
>
seems weird for flags. ip mostly uses print_bool for flags; there are
only a few print_null.
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.