From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: [patch iproute2 11/11] tc: jsonify vlan action Date: Sat, 25 Nov 2017 15:48:35 +0100 Message-ID: <20171125144835.5045-12-jiri@resnulli.us> References: <20171125144835.5045-1-jiri@resnulli.us> Cc: stephen@networkplumber.org, jhs@mojatatu.com, mlxsw@mellanox.com To: netdev@vger.kernel.org Return-path: Received: from mail-wr0-f193.google.com ([209.85.128.193]:38940 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbdKYOsr (ORCPT ); Sat, 25 Nov 2017 09:48:47 -0500 Received: by mail-wr0-f193.google.com with SMTP id 11so19220287wrb.6 for ; Sat, 25 Nov 2017 06:48:47 -0800 (PST) In-Reply-To: <20171125144835.5045-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org List-ID: From: Jiri Pirko Add json output to vlan action. Signed-off-by: Jiri Pirko --- tc/m_vlan.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tc/m_vlan.c b/tc/m_vlan.c index cccb499..44254b6 100644 --- a/tc/m_vlan.c +++ b/tc/m_vlan.c @@ -195,39 +195,37 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg) parse_rtattr_nested(tb, TCA_VLAN_MAX, arg); if (!tb[TCA_VLAN_PARMS]) { - fprintf(f, "[NULL vlan parameters]"); + print_string(PRINT_FP, NULL, "%s", "[NULL vlan parameters]"); return -1; } parm = RTA_DATA(tb[TCA_VLAN_PARMS]); - fprintf(f, " vlan"); + print_string(PRINT_ANY, "kind", "%s ", "vlan"); + print_string(PRINT_ANY, "vlan_action", " %s", action_names[parm->v_action]); switch (parm->v_action) { - case TCA_VLAN_ACT_POP: - fprintf(f, " pop"); - break; case TCA_VLAN_ACT_PUSH: case TCA_VLAN_ACT_MODIFY: - fprintf(f, " %s", action_names[parm->v_action]); if (tb[TCA_VLAN_PUSH_VLAN_ID]) { val = rta_getattr_u16(tb[TCA_VLAN_PUSH_VLAN_ID]); - fprintf(f, " id %u", val); + print_uint(PRINT_ANY, "id", " id %u", val); } if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) { - fprintf(f, " protocol %s", - ll_proto_n2a(rta_getattr_u16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]), - b1, sizeof(b1))); + print_string(PRINT_ANY, "protocol", " protocol %s", + ll_proto_n2a(rta_getattr_u16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]), + b1, sizeof(b1))); } if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY]) { val = rta_getattr_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]); - fprintf(f, " priority %u", val); + print_uint(PRINT_ANY, "priority", " priority %u", val); } break; } print_action_control(f, " ", parm->action, ""); - fprintf(f, "\n\t index %u ref %d bind %d", parm->index, parm->refcnt, - parm->bindcnt); + print_uint(PRINT_ANY, "index", "\n\t index %u", parm->index); + print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt); + print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt); if (show_stats) { if (tb[TCA_VLAN_TM]) { @@ -237,7 +235,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg) } } - fprintf(f, "\n "); + print_string(PRINT_FP, NULL, "%s", "\n"); return 0; } -- 2.9.5