ipnetns: don't print unassigned nsid in json export
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>
This commit is contained in:
parent
08ba67db7b
commit
1c9b69276c
|
|
@ -329,15 +329,15 @@ int print_nsid(struct nlmsghdr *n, void *arg)
|
||||||
|
|
||||||
nsid = rta_getattr_s32(tb[NETNSA_NSID]);
|
nsid = rta_getattr_s32(tb[NETNSA_NSID]);
|
||||||
if (nsid < 0)
|
if (nsid < 0)
|
||||||
print_string(PRINT_ANY, "nsid", "nsid %s ", "not-assigned");
|
print_string(PRINT_FP, NULL, "nsid unassigned ", NULL);
|
||||||
else
|
else
|
||||||
print_int(PRINT_ANY, "nsid", "nsid %d ", nsid);
|
print_int(PRINT_ANY, "nsid", "nsid %d ", nsid);
|
||||||
|
|
||||||
if (tb[NETNSA_CURRENT_NSID]) {
|
if (tb[NETNSA_CURRENT_NSID]) {
|
||||||
current = rta_getattr_s32(tb[NETNSA_CURRENT_NSID]);
|
current = rta_getattr_s32(tb[NETNSA_CURRENT_NSID]);
|
||||||
if (current < 0)
|
if (current < 0)
|
||||||
print_string(PRINT_ANY, "current-nsid",
|
print_string(PRINT_FP, NULL,
|
||||||
"current-nsid %s ", "not-assigned");
|
"current-nsid unassigned ", NULL);
|
||||||
else
|
else
|
||||||
print_int(PRINT_ANY, "current-nsid",
|
print_int(PRINT_ANY, "current-nsid",
|
||||||
"current-nsid %d ", current);
|
"current-nsid %d ", current);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue