From: Guillaume Nault <gnault@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: [PATCH iproute2-next 4/5] ipnetns: don't print unassigned nsid in json export
Date: Fri, 8 Nov 2019 18:00:18 +0100 [thread overview]
Message-ID: <d01111c517a07dbb07f1280c0a7055218b1fcf43.1573231189.git.gnault@redhat.com> (raw)
In-Reply-To: <cover.1573231189.git.gnault@redhat.com>
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>
---
ip/ipnetns.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 77531d6c..4eb4a09a 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -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);
--
2.21.0
next prev parent reply other threads:[~2019-11-08 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 17:00 [PATCH iproute2-next 0/5] ipnetns: cleanup and harden processing of netns ids Guillaume Nault
2019-11-08 17:00 ` [PATCH iproute2-next 1/5] ipnetns: treat NETNSA_NSID and NETNSA_CURRENT_NSID as signed Guillaume Nault
2019-11-08 17:00 ` [PATCH iproute2-next 2/5] ipnetns: fix misleading comment about 'ip monitor nsid' Guillaume Nault
2019-11-08 17:00 ` [PATCH iproute2-next 3/5] ipnetns: harden helper functions wrt. negative netns ids Guillaume Nault
2019-11-08 17:00 ` Guillaume Nault [this message]
2019-11-08 17:00 ` [PATCH iproute2-next 5/5] ipnetns: remove blank lines printed by invarg() messages Guillaume Nault
2019-11-09 1:36 ` [PATCH iproute2-next 0/5] ipnetns: cleanup and harden processing of netns ids David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d01111c517a07dbb07f1280c0a7055218b1fcf43.1573231189.git.gnault@redhat.com \
--to=gnault@redhat.com \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).