tc: sfq: add support for JSON output
Enable proper JSON output for the SFQ Qdisc. Use the long double format specifier to print the value of "probability". Also, fix the indentation in the online output of the contents in the tc_sfqred_stats structure. Signed-off-by: Leslie Monis <lesliemonis@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
46d032d002
commit
85fdef052b
70
tc/q_sfq.c
70
tc/q_sfq.c
|
|
@ -217,35 +217,53 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
if (RTA_PAYLOAD(opt) >= sizeof(*qopt_ext))
|
if (RTA_PAYLOAD(opt) >= sizeof(*qopt_ext))
|
||||||
qopt_ext = RTA_DATA(opt);
|
qopt_ext = RTA_DATA(opt);
|
||||||
qopt = RTA_DATA(opt);
|
qopt = RTA_DATA(opt);
|
||||||
fprintf(f, "limit %up ", qopt->limit);
|
|
||||||
fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
|
|
||||||
if (qopt_ext && qopt_ext->depth)
|
|
||||||
fprintf(f, "depth %u ", qopt_ext->depth);
|
|
||||||
if (qopt_ext && qopt_ext->headdrop)
|
|
||||||
fprintf(f, "headdrop ");
|
|
||||||
|
|
||||||
if (show_details) {
|
print_uint(PRINT_ANY, "limit", "limit %up ", qopt->limit);
|
||||||
fprintf(f, "flows %u/%u ", qopt->flows, qopt->divisor);
|
print_uint(PRINT_JSON, "quantum", NULL, qopt->quantum);
|
||||||
}
|
print_string(PRINT_FP, NULL, "quantum %s ",
|
||||||
fprintf(f, "divisor %u ", qopt->divisor);
|
sprint_size(qopt->quantum, b1));
|
||||||
|
|
||||||
|
if (qopt_ext && qopt_ext->depth)
|
||||||
|
print_uint(PRINT_ANY, "depth", "depth %u ", qopt_ext->depth);
|
||||||
|
if (qopt_ext && qopt_ext->headdrop)
|
||||||
|
print_bool(PRINT_ANY, "headdrop", "headdrop ", true);
|
||||||
|
if (show_details)
|
||||||
|
print_uint(PRINT_ANY, "flows", "flows %u ", qopt->flows);
|
||||||
|
|
||||||
|
print_uint(PRINT_ANY, "divisor", "divisor %u ", qopt->divisor);
|
||||||
|
|
||||||
if (qopt->perturb_period)
|
if (qopt->perturb_period)
|
||||||
fprintf(f, "perturb %dsec ", qopt->perturb_period);
|
print_int(PRINT_ANY, "perturb", "perturb %dsec ",
|
||||||
|
qopt->perturb_period);
|
||||||
if (qopt_ext && qopt_ext->qth_min) {
|
if (qopt_ext && qopt_ext->qth_min) {
|
||||||
fprintf(f, "\n ewma %u ", qopt_ext->Wlog);
|
print_uint(PRINT_ANY, "ewma", "ewma %u ", qopt_ext->Wlog);
|
||||||
fprintf(f, "min %s max %s probability %g ",
|
print_uint(PRINT_JSON, "min", NULL, qopt_ext->qth_min);
|
||||||
sprint_size(qopt_ext->qth_min, b2),
|
print_string(PRINT_FP, NULL, "min %s ",
|
||||||
sprint_size(qopt_ext->qth_max, b3),
|
sprint_size(qopt_ext->qth_min, b2));
|
||||||
qopt_ext->max_P / pow(2, 32));
|
print_uint(PRINT_JSON, "max", NULL, qopt_ext->qth_max);
|
||||||
|
print_string(PRINT_FP, NULL, "max %s ",
|
||||||
|
sprint_size(qopt_ext->qth_max, b3));
|
||||||
|
print_float(PRINT_ANY, "probability", "probability %lg ",
|
||||||
|
qopt_ext->max_P / pow(2, 32));
|
||||||
tc_red_print_flags(qopt_ext->flags);
|
tc_red_print_flags(qopt_ext->flags);
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
fprintf(f, "\n prob_mark %u prob_mark_head %u prob_drop %u",
|
print_nl();
|
||||||
qopt_ext->stats.prob_mark,
|
print_uint(PRINT_ANY, "prob_mark", " prob_mark %u",
|
||||||
qopt_ext->stats.prob_mark_head,
|
qopt_ext->stats.prob_mark);
|
||||||
qopt_ext->stats.prob_drop);
|
print_uint(PRINT_ANY, "prob_mark_head",
|
||||||
fprintf(f, "\n forced_mark %u forced_mark_head %u forced_drop %u",
|
" prob_mark_head %u",
|
||||||
qopt_ext->stats.forced_mark,
|
qopt_ext->stats.prob_mark_head);
|
||||||
qopt_ext->stats.forced_mark_head,
|
print_uint(PRINT_ANY, "prob_drop", " prob_drop %u",
|
||||||
qopt_ext->stats.forced_drop);
|
qopt_ext->stats.prob_drop);
|
||||||
|
print_nl();
|
||||||
|
print_uint(PRINT_ANY, "forced_mark",
|
||||||
|
" forced_mark %u",
|
||||||
|
qopt_ext->stats.forced_mark);
|
||||||
|
print_uint(PRINT_ANY, "forced_mark_head",
|
||||||
|
" forced_mark_head %u",
|
||||||
|
qopt_ext->stats.forced_mark_head);
|
||||||
|
print_uint(PRINT_ANY, "forced_drop", " forced_drop %u",
|
||||||
|
qopt_ext->stats.forced_drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -262,8 +280,8 @@ static int sfq_print_xstats(struct qdisc_util *qu, FILE *f,
|
||||||
return -1;
|
return -1;
|
||||||
st = RTA_DATA(xstats);
|
st = RTA_DATA(xstats);
|
||||||
|
|
||||||
fprintf(f, " allot %d ", st->allot);
|
print_int(PRINT_ANY, "allot", " allot %d", st->allot);
|
||||||
fprintf(f, "\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue