lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 25 Nov 2017 15:48:35 +0100
From:   Jiri Pirko <jiri@...nulli.us>
To:     netdev@...r.kernel.org
Cc:     stephen@...workplumber.org, jhs@...atatu.com, mlxsw@...lanox.com
Subject: [patch iproute2 11/11] tc: jsonify vlan action

From: Jiri Pirko <jiri@...lanox.com>

Add json output to vlan action.

Signed-off-by: Jiri Pirko <jiri@...lanox.com>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ