]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ipnetns: don't print unassigned nsid in json export
authorGuillaume Nault <gnault@redhat.com>
Fri, 8 Nov 2019 17:00:18 +0000 (18:00 +0100)
committerDavid Ahern <dsahern@gmail.com>
Sat, 9 Nov 2019 01:33:05 +0000 (01:33 +0000)
Don't output the nsid and current-nsid json keys if they're not set.
Otherwise a parser would have to special case the "not-assigned"
string.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/ipnetns.c

index 355455dbc3e00d2d90bbec8c71cddf5bdb15e83c..cb8c0019f7ad35e5587899434f208a8cb23e1b84 100644 (file)
@@ -329,15 +329,15 @@ int print_nsid(struct nlmsghdr *n, void *arg)
 
        nsid = rta_getattr_s32(tb[NETNSA_NSID]);
        if (nsid < 0)
-               print_string(PRINT_ANY, "nsid", "nsid %s ", "not-assigned");
+               print_string(PRINT_FP, NULL, "nsid unassigned ", NULL);
        else
                print_int(PRINT_ANY, "nsid", "nsid %d ", nsid);
 
        if (tb[NETNSA_CURRENT_NSID]) {
                current = rta_getattr_s32(tb[NETNSA_CURRENT_NSID]);
                if (current < 0)
-                       print_string(PRINT_ANY, "current-nsid",
-                                    "current-nsid %s ", "not-assigned");
+                       print_string(PRINT_FP, NULL,
+                                    "current-nsid unassigned ", NULL);
                else
                        print_int(PRINT_ANY, "current-nsid",
                                  "current-nsid %d ", current);