public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs
@ 2026-03-03 13:07 Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Victor Nogueira @ 2026-03-03 13:07 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: jhs, deren.teo, andrew, netdev

Since qdisc core already assumes all qdiscs are able to output JSON,
add JSON output support to the remaning qdiscs (HFSC, QFQ, muiltiq)
so that a JSON qdisc dump outputs valid JSON.

v1 -> v2:
- Fix bug on line printing "level" field in HFSC (Pointed out by Stephen)
- Emit HFSC d (delay) as a raw numeric microseconds
  value (Suggested by Stephen)
- Use nested JSON objects instead of flat names with spaces when
  necessary in HFSC (Suggested by Stephen)
- Output bands and max_bands as separate JSON fields for
  multiq (Suggested by Stephen)

Victor Nogueira (3):
  tc: Add JSON output support to HFSC
  tc: Add JSON output support to QFQ
  tc: Add JSON output support to multiq

 tc/q_hfsc.c   | 27 +++++++++++++++++----------
 tc/q_multiq.c |  6 +++++-
 tc/q_qfq.c    |  8 ++++----
 3 files changed, 26 insertions(+), 15 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC
  2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
@ 2026-03-03 13:07 ` Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Nogueira @ 2026-03-03 13:07 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: jhs, deren.teo, andrew, netdev

Since qdisc core already assumes all qdiscs are able to output JSON,
add JSON output support to HFSC.

Fixes: c91d262f414d ("tc: jsonify qdisc core")
Reported-by: Deren Teo <deren.teo@outlook.com>
Closes: https://lore.kernel.org/netdev/SI2PPF4F82E9256898C9826AF17C3AE8AD9F467A@SI2PPF4F82E9256.apcprd04.prod.outlook.com/
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
 tc/q_hfsc.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index aed7130c..f68e8351 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -108,7 +108,8 @@ hfsc_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	qopt = RTA_DATA(opt);
 
 	if (qopt->defcls != 0)
-		fprintf(f, "default %x ", qopt->defcls);
+		print_0xhex(PRINT_ANY, "default", " default %#llx ",
+			    qopt->defcls);
 
 	return 0;
 }
@@ -124,13 +125,15 @@ hfsc_print_xstats(const struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
 		return -1;
 	st = RTA_DATA(xstats);
 
-	fprintf(f, " period %u ", st->period);
+	print_uint(PRINT_ANY, "period", " period %u ", st->period);
 	if (st->work != 0)
-		fprintf(f, "work %llu bytes ", (unsigned long long) st->work);
+		print_lluint(PRINT_ANY, "work", "work %llu bytes ",
+			     (unsigned long long)st->work);
 	if (st->rtwork != 0)
-		fprintf(f, "rtwork %llu bytes ", (unsigned long long) st->rtwork);
-	fprintf(f, "level %u ", st->level);
-	fprintf(f, "\n");
+		print_lluint(PRINT_ANY, "rtwork", "rtwork %llu bytes ",
+			     (unsigned long long)st->rtwork);
+	print_uint(PRINT_ANY, "level", " level %u ", st->level);
+	print_string(PRINT_FP, NULL, "%s", _SL_);
 
 	return 0;
 }
@@ -211,12 +214,16 @@ hfsc_parse_class_opt(const struct qdisc_util *qu, int argc, char **argv,
 static void
 hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc)
 {
+	unsigned int d_time = tc_core_ktime2time(sc->d);
 	SPRINT_BUF(b1);
 
-	fprintf(f, "%s ", name);
-	tc_print_rate(PRINT_FP, NULL, "m1 %s ", sc->m1);
-	fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
-	tc_print_rate(PRINT_FP, NULL, "m2 %s ", sc->m2);
+	open_json_object(name);
+	print_string(PRINT_FP, NULL, "%s ", name);
+	tc_print_rate(PRINT_ANY, "m1", "m1 %s ", sc->m1);
+	print_string(PRINT_FP, NULL, "d %s ", sprint_time(d_time, b1));
+	print_uint(PRINT_JSON, "d", NULL, d_time);
+	tc_print_rate(PRINT_ANY, "m2", "m2 %s ", sc->m2);
+	close_json_object();
 }
 
 static int
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 v2 2/3] tc: Add JSON output support to QFQ
  2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
@ 2026-03-03 13:07 ` Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 3/3] tc: Add JSON output support to multiq Victor Nogueira
  2026-03-07  1:20 ` [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Nogueira @ 2026-03-03 13:07 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: jhs, deren.teo, andrew, netdev

Since qdisc core already assumes all qdiscs are able to output JSON,
add JSON output support to QFQ.

Fixes: c91d262f414d ("tc: jsonify qdisc core")
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
 tc/q_qfq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tc/q_qfq.c b/tc/q_qfq.c
index d4c0a591..04061fcc 100644
--- a/tc/q_qfq.c
+++ b/tc/q_qfq.c
@@ -90,13 +90,13 @@ static int qfq_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *op
 	parse_rtattr_nested(tb, TCA_QFQ_MAX, opt);
 
 	if (tb[TCA_QFQ_WEIGHT]) {
-		fprintf(f, "weight %u ",
-			rta_getattr_u32(tb[TCA_QFQ_WEIGHT]));
+		print_uint(PRINT_ANY, "weight", "weight %u ",
+			   rta_getattr_u32(tb[TCA_QFQ_WEIGHT]));
 	}
 
 	if (tb[TCA_QFQ_LMAX]) {
-		fprintf(f, "maxpkt %u ",
-			rta_getattr_u32(tb[TCA_QFQ_LMAX]));
+		print_uint(PRINT_ANY, "maxpkt", "maxpkt %u ",
+			   rta_getattr_u32(tb[TCA_QFQ_LMAX]));
 	}
 
 	return 0;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 v2 3/3] tc: Add JSON output support to multiq
  2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
  2026-03-03 13:07 ` [PATCH iproute2 v2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
@ 2026-03-03 13:07 ` Victor Nogueira
  2026-03-07  1:20 ` [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Nogueira @ 2026-03-03 13:07 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: jhs, deren.teo, andrew, netdev

Since qdisc core already assumes all qdiscs are able to output JSON,
add JSON output support to multiq.

Fixes: c91d262f414d ("tc: jsonify qdisc core")
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
 tc/q_multiq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tc/q_multiq.c b/tc/q_multiq.c
index 63fffed4..0e8e2f9e 100644
--- a/tc/q_multiq.c
+++ b/tc/q_multiq.c
@@ -51,6 +51,7 @@ static int multiq_parse_opt(const struct qdisc_util *qu, int argc, char **argv,
 static int multiq_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	struct tc_multiq_qopt *qopt;
+	SPRINT_BUF(b1);
 
 	if (opt == NULL)
 		return 0;
@@ -59,7 +60,10 @@ static int multiq_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr
 
 	qopt = RTA_DATA(opt);
 
-	fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
+	snprintf(b1, SPRINT_BSIZE, "%u/%u", qopt->bands, qopt->max_bands);
+	print_string(PRINT_FP, NULL, "bands %s ", b1);
+	print_uint(PRINT_JSON, "bands", NULL, qopt->bands);
+	print_uint(PRINT_JSON, "max_bands", NULL, qopt->max_bands);
 
 	return 0;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs
  2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
                   ` (2 preceding siblings ...)
  2026-03-03 13:07 ` [PATCH iproute2 v2 3/3] tc: Add JSON output support to multiq Victor Nogueira
@ 2026-03-07  1:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-07  1:20 UTC (permalink / raw)
  To: Victor Nogueira; +Cc: stephen, dsahern, jhs, deren.teo, andrew, netdev

Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Tue,  3 Mar 2026 10:07:30 -0300 you wrote:
> Since qdisc core already assumes all qdiscs are able to output JSON,
> add JSON output support to the remaning qdiscs (HFSC, QFQ, muiltiq)
> so that a JSON qdisc dump outputs valid JSON.
> 
> v1 -> v2:
> - Fix bug on line printing "level" field in HFSC (Pointed out by Stephen)
> - Emit HFSC d (delay) as a raw numeric microseconds
>   value (Suggested by Stephen)
> - Use nested JSON objects instead of flat names with spaces when
>   necessary in HFSC (Suggested by Stephen)
> - Output bands and max_bands as separate JSON fields for
>   multiq (Suggested by Stephen)
> 
> [...]

Here is the summary with links:
  - [iproute2,v2,1/3] tc: Add JSON output support to HFSC
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=3ebe6ec196b6
  - [iproute2,v2,2/3] tc: Add JSON output support to QFQ
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=935b2aea0641
  - [iproute2,v2,3/3] tc: Add JSON output support to multiq
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=4ac8d234f736

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-07  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 13:07 [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
2026-03-03 13:07 ` [PATCH iproute2 v2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
2026-03-03 13:07 ` [PATCH iproute2 v2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
2026-03-03 13:07 ` [PATCH iproute2 v2 3/3] tc: Add JSON output support to multiq Victor Nogueira
2026-03-07  1:20 ` [PATCH iproute2 v2 0/3] Add JSON output support to the remaining qdiscs patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox