[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260211170725.1514427-2-victor@mojatatu.com>
Date: Wed, 11 Feb 2026 14:07:23 -0300
From: Victor Nogueira <victor@...atatu.com>
To: dsahern@...nel.org,
stephen@...workplumber.org
Cc: jhs@...atatu.com,
deren.teo@...look.com,
andrew@...n.ch,
netdev@...r.kernel.org
Subject: [PATCH iproute2 1/3] tc: Add JSON output support to HFSC
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@...look.com>
Closes: https://lore.kernel.org/netdev/SI2PPF4F82E9256898C9826AF17C3AE8AD9F467A@SI2PPF4F82E9256.apcprd04.prod.outlook.com/
Signed-off-by: Victor Nogueira <victor@...atatu.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
Powered by blists - more mailing lists