[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180709194856.18922-2-stephen@networkplumber.org>
Date: Mon, 9 Jul 2018 12:48:48 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <sthemmin@...rosoft.com>
Subject: [PATCH iproute2-next 1/9] tc: use JSON in error handling
From: Stephen Hemminger <sthemmin@...rosoft.com>
If option or qdisc is unknown, still output in JSON.
Signed-off-by: Stephen Hemminger <sthemmin@...rosoft.com>
---
tc/tc.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/tc/tc.c b/tc/tc.c
index 0d223281ba25..b6d2a6151793 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -56,9 +56,11 @@ static struct filter_util *filter_list;
static int print_noqopt(struct qdisc_util *qu, FILE *f,
struct rtattr *opt)
{
- if (opt && RTA_PAYLOAD(opt))
- fprintf(f, "[Unknown qdisc, optlen=%u] ",
- (unsigned int) RTA_PAYLOAD(opt));
+ if (opt && RTA_PAYLOAD(opt)) {
+ print_string(PRINT_JSON, "qdisc", NULL, "UNKNOWN");
+ print_uint(PRINT_ANY, "optlen", "[Unknown qdisc, optlen=%u] ",
+ RTA_PAYLOAD(opt));
+ }
return 0;
}
@@ -76,11 +78,12 @@ static int parse_noqopt(struct qdisc_util *qu, int argc, char **argv,
static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle)
{
- if (opt && RTA_PAYLOAD(opt))
- fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
- fhandle, (unsigned int) RTA_PAYLOAD(opt));
- else if (fhandle)
- fprintf(f, "fh %08x ", fhandle);
+ if (opt && RTA_PAYLOAD(opt)) {
+ print_0xhex(PRINT_ANY, "handle", "fh %08x ", fhandle);
+ print_uint(PRINT_ANY, "optlen", "[Unknown filter, optlen=%u] ",
+ RTA_PAYLOAD(opt));
+ } else if (fhandle)
+ print_0xhex(PRINT_ANY, "handle", "fh %08x ", fhandle);
return 0;
}
--
2.18.0
Powered by blists - more mailing lists