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-next>] [day] [month] [year] [list]
Date:   Fri, 13 Apr 2018 17:40:05 -0400
From:   Roman Mashak <mrv@...atatu.com>
To:     dsahern@...il.com
Cc:     stephen@...workplumber.org, netdev@...r.kernel.org,
        kernel@...atatu.com, jhs@...atatu.com, xiyou.wangcong@...il.com,
        jiri@...nulli.us, Roman Mashak <mrv@...atatu.com>
Subject: [PATCH iproute2-next 1/1] tc: jsonify ife action

Signed-off-by: Roman Mashak <mrv@...atatu.com>
---
 tc/m_ife.c | 54 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/tc/m_ife.c b/tc/m_ife.c
index d7e61703f666..15d09a167450 100644
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -240,22 +240,24 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
 	parse_rtattr_nested(tb, TCA_IFE_MAX, arg);
 
 	if (tb[TCA_IFE_PARMS] == NULL) {
-		fprintf(f, "[NULL ife parameters]");
+		print_string(PRINT_FP, NULL, "%s", "[NULL ife parameters]");
 		return -1;
 	}
 	p = RTA_DATA(tb[TCA_IFE_PARMS]);
 
-	fprintf(f, "ife %s ", p->flags & IFE_ENCODE ? "encode" : "decode");
+	print_string(PRINT_ANY, "kind", "%s ", "ife");
+	print_string(PRINT_ANY, "mode", "%s",
+		     p->flags & IFE_ENCODE ? "encode" : "decode");
 	print_action_control(f, "action ", p->action, " ");
 
 	if (tb[TCA_IFE_TYPE]) {
 		ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
 		has_optional = 1;
-		fprintf(f, "type 0x%X ", ife_type);
+		print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
 	}
 
 	if (has_optional)
-		fprintf(f, "\n\t ");
+		print_string(PRINT_FP, NULL, "%s\t", _SL_);
 
 	if (tb[TCA_IFE_METALST]) {
 		struct rtattr *metalist[IFE_META_MAX + 1];
@@ -268,9 +270,11 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
 			len = RTA_PAYLOAD(metalist[IFE_META_SKBMARK]);
 			if (len) {
 				mmark = rta_getattr_u32(metalist[IFE_META_SKBMARK]);
-				fprintf(f, "use mark %u ", mmark);
+				print_uint(PRINT_ANY, "mark", "use mark %u ",
+					   mmark);
 			} else
-				fprintf(f, "allow mark ");
+				print_string(PRINT_ANY, "mark", "%s mark ",
+					     "allow");
 		}
 
 		if (metalist[IFE_META_TCINDEX]) {
@@ -278,41 +282,47 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
 			if (len) {
 				mtcindex =
 					rta_getattr_u16(metalist[IFE_META_TCINDEX]);
-				fprintf(f, "use tcindex %d ", mtcindex);
+				print_uint(PRINT_ANY, "tcindex",
+					   "use tcindex %u ", mtcindex);
 			} else
-				fprintf(f, "allow tcindex ");
+				print_string(PRINT_ANY, "tcindex",
+					     "%s tcindex ", "allow");
 		}
 
 		if (metalist[IFE_META_PRIO]) {
 			len = RTA_PAYLOAD(metalist[IFE_META_PRIO]);
 			if (len) {
 				mprio = rta_getattr_u32(metalist[IFE_META_PRIO]);
-				fprintf(f, "use prio %u ", mprio);
+				print_uint(PRINT_ANY, "prio", "use prio %u ",
+					   mprio);
 			} else
-				fprintf(f, "allow prio ");
+				print_string(PRINT_ANY, "prio", "%s prio ",
+					     "allow");
 		}
 
 	}
 
 	if (tb[TCA_IFE_DMAC]) {
 		has_optional = 1;
-		fprintf(f, "dst %s ",
-			ll_addr_n2a(RTA_DATA(tb[TCA_IFE_DMAC]),
-				    RTA_PAYLOAD(tb[TCA_IFE_DMAC]), 0, b2,
-				    sizeof(b2)));
-
+		print_string(PRINT_ANY, "dst", "dst %s ",
+			     ll_addr_n2a(RTA_DATA(tb[TCA_IFE_DMAC]),
+					 RTA_PAYLOAD(tb[TCA_IFE_DMAC]), 0, b2,
+					 sizeof(b2)));
 	}
 
 	if (tb[TCA_IFE_SMAC]) {
 		has_optional = 1;
-		fprintf(f, "src %s ",
-			ll_addr_n2a(RTA_DATA(tb[TCA_IFE_SMAC]),
-				    RTA_PAYLOAD(tb[TCA_IFE_SMAC]), 0, b2,
-				    sizeof(b2)));
+		print_string(PRINT_ANY, "src", "src %s ",
+			     ll_addr_n2a(RTA_DATA(tb[TCA_IFE_SMAC]),
+					 RTA_PAYLOAD(tb[TCA_IFE_SMAC]), 0, b2,
+					 sizeof(b2)));
 	}
 
-	fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt,
-		p->bindcnt);
+	print_string(PRINT_FP, NULL, "%s", _SL_);
+	print_uint(PRINT_ANY, "index", "\t index %u", p->index);
+	print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
+	print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
+
 	if (show_stats) {
 		if (tb[TCA_IFE_TM]) {
 			struct tcf_t *tm = RTA_DATA(tb[TCA_IFE_TM]);
@@ -321,7 +331,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
 		}
 	}
 
-	fprintf(f, "\n");
+	print_string(PRINT_FP, NULL, "%s", _SL_);
 
 	return 0;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ