On 7/6/20 11:40 AM, Stephen Hemminger wrote: > On Tue, 07 Jul 2020 02:08:21 +0800 > "YU, Xiangning" <xiangning...@alibaba-inc.com> wrote: > >> +static int ltb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) >> +{ >> + struct rtattr *tb[TCA_LTB_MAX + 1]; >> + struct tc_ltb_opt *lopt; >> + struct tc_ltb_glob *gopt; >> + __u64 rate64, ceil64; >> + >> + SPRINT_BUF(b1); >> + if (opt == NULL) >> + return 0; >> + >> + parse_rtattr_nested(tb, TCA_LTB_MAX, opt); >> + >> + if (tb[TCA_LTB_PARMS]) { >> + lopt = RTA_DATA(tb[TCA_LTB_PARMS]); >> + if (RTA_PAYLOAD(tb[TCA_LTB_PARMS]) < sizeof(*lopt)) >> + return -1; >> + >> + fprintf(f, "prio %d ", (int)lopt->prio); >> + >> + rate64 = lopt->rate.rate; >> + if (tb[TCA_LTB_RATE64] && >> + RTA_PAYLOAD(tb[TCA_LTB_RATE64]) >= sizeof(rate64)) { >> + rate64 = *(__u64 *)RTA_DATA(tb[TCA_LTB_RATE64]); >> + } >> + >> + ceil64 = lopt->ceil.rate; >> + if (tb[TCA_LTB_CEIL64] && >> + RTA_PAYLOAD(tb[TCA_LTB_CEIL64]) >= sizeof(ceil64)) >> + ceil64 = *(__u64 *)RTA_DATA(tb[TCA_LTB_CEIL64]); >> + >> + fprintf(f, "rate %s ", sprint_rate(rate64, b1)); >> + fprintf(f, "ceil %s ", sprint_rate(ceil64, b1)); > > The print function needs to support JSON output like the rest > of the qdisc in current iproute2. > Hi Stephen,
Thank you for pointing this out! While I'm a bit confused about the JSON output. This is a sample output of `tc -j class show` command. Looks like it doesn't display JSON output even for HTB. Am I missing anything? # ./tc -s -j -p class show dev enp7s0f0 class htb 1:1 root rate 10Gbit ceil 10Gbit burst 13750b cburst 0b Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 lended: 0 borrowed: 0 giants: 0 tokens: 187 ctokens: 15 class htb 1:10 parent 1:1 prio 1 rate 10Gbit ceil 10Gbit burst 13750b cburst 13750b Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 lended: 0 borrowed: 0 giants: 0 tokens: 187 ctokens: 187 Thanks, - Xiangning