tc/netem: display per-impairment xstats counters
Subsystems (2)
PATCH 1/1 tc/netem: display per-impairment xstats counters
The kernel now reports struct tc_netem_xstats via TCA_STATS_APP with per-impairment counters: delayed, loss, corrupted, duplicated, reordered, and ecn_marked.
Add netem_print_xstats() following the same pattern as fq_print_xstats()
Example output of tc -s qdisc show dev eth0:
qdisc netem 8001: root refcnt 2 limit 1000 delay 100ms loss 5%
Sent 1234567 bytes 15483 pkt (dropped 774, overlimits 0 requeues 0) delayed 14709 dropped 774 corrupted 154 duplicated 309 reordered 61 ecn_marked 0
--- tc/q_netem.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tc/q_netem.c +26 -0
@@ -870,8 +870,34 @@ static int netem_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *return 0 ; } +static int netem_print_xstats (const struct qdisc_util *qu,FILE *f, +struct rtattr *xstats) +{ +struct tc_netem_xstats *st, _st; + +if (xstats ==NULL ) +return 0 ; + +/* future proof for addition of more stats */ +memset (&_st,0 ,sizeof (_st)); +memcpy (&_st,RTA_DATA (xstats),min (RTA_PAYLOAD (xstats),sizeof (*st))); + st = &_st; + +print_u64 (PRINT_ANY ,"delayed" ," delayed %llu" , st->delayed); +print_u64 (PRINT_ANY ,"dropped" ," dropped %llu" , st->dropped); +print_u64 (PRINT_ANY ,"corrupted" ," corrupted %llu" , st->corrupted); +print_u64 (PRINT_ANY ,"duplicated" ," duplicated %llu" , st->duplicated); +print_u64 (PRINT_ANY ,"reordered" ," reordered %llu" , st->reordered); +print_u64 (PRINT_ANY ,"ecn_marked" ," ecn_marked %llu" , st->ecn_marked); +if (st->allocation_errors) +print_u64 (PRINT_ANY ,"alloc_errors" ," alloc_errors %llu" , st->allocation_errors); + +return 0 ; +} +struct qdisc_util netem_qdisc_util = { .id ="netem" , .parse_qopt = netem_parse_opt, .print_qopt = netem_print_opt, + .print_xstats = netem_print_xstats, };
Signature · 1 line
2.53.0
Quoted 36 lines · Stephen Hemminger
The kernel now reports struct
tc_netem_xstatsviaTCA_STATS_APPwith per-impairment counters: delayed, loss, corrupted, duplicated, reordered, andecn_marked.Add
netem_print_xstats()following the same pattern asfq_print_xstats()Example output of
tc -s qdisc show dev eth0:
qdisc netem 8001: root refcnt 2 limit 1000 delay 100ms loss 5%
Sent 1234567 bytes 15483 pkt (dropped 774, overlimits 0 requeues 0) delayed 14709 dropped 774 corrupted 154 duplicated 309 reordered 61ecn_marked0Signed-off-by Stephen Hemminger <[email protected]>--- tc/q_netem.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)tc/q_netem.c +11
-0@@ -870,8 +870,34 @@ static int netem_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr *return 0 ; } +static int netem_print_xstats (const struct qdisc_util *qu,FILE *f, +struct rtattr *xstats) +{ +struct tc_netem_xstats *st, _st; + +if (xstats ==NULL ) +return 0 ; + +/* future proof for addition of more stats */ +memset (&_st,0 ,sizeof (_st)); +memcpy (&_st,RTA_DATA (xstats),min (RTA_PAYLOAD (xstats),sizeof (*st)));
tc/q_netem.c static int netem_print_opt(const struct qdisc_util *qu, FILE *f, struct rtattr * · line 893
Quoted 10 lines
tc/q_netem.c +10
-0+ st = &_st; + +print_u64 (PRINT_ANY ,"delayed" ," delayed %llu" , st->delayed); +print_u64 (PRINT_ANY ,"dropped" ," dropped %llu" , st->dropped); +print_u64 (PRINT_ANY ,"corrupted" ," corrupted %llu" , st->corrupted); +print_u64 (PRINT_ANY ,"duplicated" ," duplicated %llu" , st->duplicated); +print_u64 (PRINT_ANY ,"reordered" ," reordered %llu" , st->reordered); +print_u64 (PRINT_ANY ,"ecn_marked" ," ecn_marked %llu" , st->ecn_marked); +if (st->allocation_errors) +print_u64 (PRINT_ANY ,"alloc_errors" ," alloc_errors %llu" , st->allocation_errors);
wrapped that line (98 chars is a bit much) and applied to iproute2-next