public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs
@ 2026-02-11 17:07 Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Victor Nogueira @ 2026-02-11 17:07 UTC (permalink / raw)
  To: dsahern, stephen; +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.

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   | 29 ++++++++++++++++++-----------
 tc/q_multiq.c |  4 +++-
 tc/q_qfq.c    |  8 ++++----
 3 files changed, 25 insertions(+), 16 deletions(-)

-- 
2.52.0


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

* [PATCH iproute2 1/3] tc: Add JSON output support to HFSC
  2026-02-11 17:07 [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
@ 2026-02-11 17:07 ` Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Victor Nogueira @ 2026-02-11 17:07 UTC (permalink / raw)
  To: dsahern, stephen; +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 | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index aed7130c..7340f607 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->period);
+	print_string(PRINT_FP, NULL, "%s", _SL_);
 
 	return 0;
 }
@@ -212,11 +215,16 @@ static void
 hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc)
 {
 	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);
+	SPRINT_BUF(b2);
+
+	print_string(PRINT_FP, NULL, "%s ", name);
+	sprintf(b1, "%s m1", name);
+	tc_print_rate(PRINT_ANY, b1, "m1 %s ", sc->m1);
+	sprintf(b1, "%s d", name);
+	print_string(PRINT_ANY, b1, "d %s ",
+		     sprint_time(tc_core_ktime2time(sc->d), b2));
+	sprintf(b1, "%s m2", name);
+	tc_print_rate(PRINT_ANY, b1, "m2 %s ", sc->m2);
 }
 
 static int
-- 
2.52.0


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

* [PATCH iproute2 2/3] tc: Add JSON output support to QFQ
  2026-02-11 17:07 [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
@ 2026-02-11 17:07 ` Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 3/3] tc: Add JSON output support to multiq Victor Nogueira
  2026-02-25 21:26 ` [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Stephen Hemminger
  3 siblings, 0 replies; 6+ messages in thread
From: Victor Nogueira @ 2026-02-11 17:07 UTC (permalink / raw)
  To: dsahern, stephen; +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.52.0


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

* [PATCH iproute2 3/3] tc: Add JSON output support to multiq
  2026-02-11 17:07 [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
  2026-02-11 17:07 ` [PATCH iproute2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
@ 2026-02-11 17:07 ` Victor Nogueira
  2026-02-25 21:26 ` [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Stephen Hemminger
  3 siblings, 0 replies; 6+ messages in thread
From: Victor Nogueira @ 2026-02-11 17:07 UTC (permalink / raw)
  To: dsahern, stephen; +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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tc/q_multiq.c b/tc/q_multiq.c
index 63fffed4..08a2a3b0 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,8 @@ 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_ANY, "bands", "bands %s ", b1);
 
 	return 0;
 }
-- 
2.52.0


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

* Re: [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs
  2026-02-11 17:07 [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
                   ` (2 preceding siblings ...)
  2026-02-11 17:07 ` [PATCH iproute2 3/3] tc: Add JSON output support to multiq Victor Nogueira
@ 2026-02-25 21:26 ` Stephen Hemminger
  2026-03-03 13:08   ` Victor Nogueira
  3 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2026-02-25 21:26 UTC (permalink / raw)
  To: Victor Nogueira; +Cc: dsahern, jhs, deren.teo, andrew, netdev

On Wed, 11 Feb 2026 14:07:22 -0300
Victor Nogueira <victor@mojatatu.com> 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.
> 
> 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   | 29 ++++++++++++++++++-----------
>  tc/q_multiq.c |  4 +++-
>  tc/q_qfq.c    |  8 ++++----
>  3 files changed, 25 insertions(+), 16 deletions(-)
> 

Good start but some minor issues found by AI patch review 

Must-fix bug in patch 1/3 (HFSC): Copy-paste error on line printing
level — it uses st->period instead of st->level, silently emitting
wrong data in both text and JSON modes.

Design concerns worth discussing:

HFSC d (delay) field is emitted as a human-readable string in JSON
("5ms") rather than a raw numeric value (microseconds), which goes
against the iproute2 JSON convention that JSON should carry raw values
for script consumption

HFSC service curve keys use flat compound names with spaces ("rt m1")
rather than nested JSON objects — functional but awkward for consumers

multiq bands emits a compound string ("3/16") rather than separate
numeric fields — once this JSON format ships it becomes API

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

* Re: [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs
  2026-02-25 21:26 ` [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Stephen Hemminger
@ 2026-03-03 13:08   ` Victor Nogueira
  0 siblings, 0 replies; 6+ messages in thread
From: Victor Nogueira @ 2026-03-03 13:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dsahern, jhs, deren.teo, andrew, netdev

On Wed, Feb 25, 2026 at 6:26 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Wed, 11 Feb 2026 14:07:22 -0300
> Victor Nogueira <victor@mojatatu.com> 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.
> >
> > 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   | 29 ++++++++++++++++++-----------
> >  tc/q_multiq.c |  4 +++-
> >  tc/q_qfq.c    |  8 ++++----
> >  3 files changed, 25 insertions(+), 16 deletions(-)
> >
>
> Good start but some minor issues found by AI patch review
>
> Must-fix bug in patch 1/3 (HFSC): Copy-paste error on line printing
> level — it uses st->period instead of st->level, silently emitting
> wrong data in both text and JSON modes.
>
> Design concerns worth discussing:
>
> HFSC d (delay) field is emitted as a human-readable string in JSON
> ("5ms") rather than a raw numeric value (microseconds), which goes
> against the iproute2 JSON convention that JSON should carry raw values
> for script consumption
>
> HFSC service curve keys use flat compound names with spaces ("rt m1")
> rather than nested JSON objects — functional but awkward for consumers
>
> multiq bands emits a compound string ("3/16") rather than separate
> numeric fields — once this JSON format ships it becomes API

Thank you for reviewing.
I sent a v2 with the fixes you suggested.

cheers,
Victor

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

end of thread, other threads:[~2026-03-03 13:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 17:07 [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Victor Nogueira
2026-02-11 17:07 ` [PATCH iproute2 1/3] tc: Add JSON output support to HFSC Victor Nogueira
2026-02-11 17:07 ` [PATCH iproute2 2/3] tc: Add JSON output support to QFQ Victor Nogueira
2026-02-11 17:07 ` [PATCH iproute2 3/3] tc: Add JSON output support to multiq Victor Nogueira
2026-02-25 21:26 ` [PATCH iproute2 0/3] Add JSON output support to the remaining qdiscs Stephen Hemminger
2026-03-03 13:08   ` Victor Nogueira

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