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]
Message-ID: <20240312225456.87937-4-stephen@networkplumber.org>
Date: Tue, 12 Mar 2024 15:53:30 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2 3/5] skbmod: support json in print

This tc action never got jsonized.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/m_skbmod.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/tc/m_skbmod.c b/tc/m_skbmod.c
index b1c8d00dfe47..87de59cf60bb 100644
--- a/tc/m_skbmod.c
+++ b/tc/m_skbmod.c
@@ -177,43 +177,48 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)
 
 	p = RTA_DATA(tb[TCA_SKBMOD_PARMS]);
 
-	fprintf(f, "skbmod ");
+	print_string(PRINT_FP, NULL, "skbmod ", NULL);
 	print_action_control(f, "", p->action, " ");
 
 	if (tb[TCA_SKBMOD_ETYPE]) {
 		skbmod_etype = rta_getattr_u16(tb[TCA_SKBMOD_ETYPE]);
 		has_optional = 1;
-		fprintf(f, "set etype 0x%X ", skbmod_etype);
+		print_0xhex(PRINT_ANY, "etype", "set etype 0x%X ", skbmod_etype);
 	}
 
 	if (has_optional)
-		fprintf(f, "\n\t ");
+		print_string(PRINT_FP, NULL, "%s\t ", _SL_);
 
 	if (tb[TCA_SKBMOD_DMAC]) {
 		has_optional = 1;
-		fprintf(f, "set dmac %s ",
-			ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]),
-				    RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1,
-				    sizeof(b1)));
+		print_color_string(PRINT_ANY, COLOR_MAC, "dmac",
+				   "set dmac %s ",
+				   ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]),
+					       RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1,
+					       sizeof(b1)));
 
 	}
 
 	if (tb[TCA_SKBMOD_SMAC]) {
 		has_optional = 1;
-		fprintf(f, "set smac %s ",
-			ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]),
-				    RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2,
-				    sizeof(b2)));
+		print_color_string(PRINT_ANY, COLOR_MAC, "smac",
+				   "set smac %s ",
+				   ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]),
+					       RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2,
+					       sizeof(b2)));
 	}
 
 	if (p->flags & SKBMOD_F_SWAPMAC)
-		fprintf(f, "swap mac ");
+		print_null(PRINT_ANY, "swapmac", "swap mac ", NULL);
 
 	if (p->flags & SKBMOD_F_ECN)
-		fprintf(f, "ecn ");
+		print_null(PRINT_ANY, "ecn", "ecn ", NULL);
+
+	print_nl();
+	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);
 
-	fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt,
-		p->bindcnt);
 	if (show_stats) {
 		if (tb[TCA_SKBMOD_TM]) {
 			struct tcf_t *tm = RTA_DATA(tb[TCA_SKBMOD_TM]);
@@ -222,7 +227,7 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)
 		}
 	}
 
-	fprintf(f, "\n");
+	print_string(PRINT_FP, NULL, "\n", NULL);
 
 	return 0;
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ