* [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