Message ID | 20191226144415.50682-1-julien@cumulusnetworks.com |
---|---|
State | Rejected |
Delegated to: | stephen hemminger |
Headers | show |
Series | [iproute2-next] ip: ipneigh: json: print ndm_flags as boolean attributes | expand |
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.
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.
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])