diff options
author | osdl.net!shemminger <osdl.net!shemminger> | 2004-08-31 17:45:21 +0000 |
---|---|---|
committer | osdl.net!shemminger <osdl.net!shemminger> | 2004-08-31 17:45:21 +0000 |
commit | 649b0755ccce0f17a04fdbc37c93166fa6612edb (patch) | |
tree | 73feb9cf5a07f23d46264c7e8acf7ee37235a54f /tc/tc_qdisc.c | |
parent | 4d466e34d471ddcfdd986cd7ab4f4bd26424fd1c (diff) | |
download | platform_external_iproute2-649b0755ccce0f17a04fdbc37c93166fa6612edb.tar.gz platform_external_iproute2-649b0755ccce0f17a04fdbc37c93166fa6612edb.tar.bz2 platform_external_iproute2-649b0755ccce0f17a04fdbc37c93166fa6612edb.zip |
Handle new/old API and new additions to tc_stats.
2004/08/29 10:20:25-07:00 net[shemminger]!shemminger
Import patch reqs-patch-iproute2-2.6.8
(Logical change 1.77)
Diffstat (limited to 'tc/tc_qdisc.c')
-rw-r--r-- | tc/tc_qdisc.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c index eb451a47..8f324895 100644 --- a/tc/tc_qdisc.c +++ b/tc/tc_qdisc.c @@ -167,34 +167,44 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) return 0; } -void print_tcstats(FILE *fp, struct tc_stats *st) + +void print_tcstats_attr(FILE *fp, const struct rtattr *rta) { + struct tc_stats st; SPRINT_BUF(b1); - fprintf(fp, " Sent %llu bytes %u pkts (dropped %u, overlimits %u ) ", - (unsigned long long)st->bytes, st->packets, st->drops, st->overlimits); - if (st->bps || st->pps || st->qlen || st->backlog) { + /* handle case where kernel returns more/less than we know about */ + memset(&st, 0, sizeof(st)); + memcpy(&st, RTA_DATA(rta), MIN(RTA_PAYLOAD(rta), sizeof(st))); + + fprintf(fp, " Sent %llu bytes %u pkts (dropped %u, overlimits %u requeus%u ) ", + (unsigned long long)st.bytes, st.packets, st.drops, + st.overlimits, st.reqs); + + if (st.bps || st.pps || st.qlen || st.backlog) { fprintf(fp, "\n "); - if (st->bps || st->pps) { + if (st.bps || st.pps) { fprintf(fp, "rate "); - if (st->bps) - fprintf(fp, "%s ", sprint_rate(st->bps, b1)); - if (st->pps) - fprintf(fp, "%upps ", st->pps); + if (st.bps) + fprintf(fp, "%s ", sprint_rate(st.bps, b1)); + if (st.pps) + fprintf(fp, "%upps ", st.pps); } - if (st->qlen || st->backlog) { + if (st.qlen || st.backlog) { fprintf(fp, "backlog "); - if (st->backlog) - fprintf(fp, "%s ", sprint_size(st->backlog, b1)); - if (st->qlen) - fprintf(fp, "%up ", st->qlen); + if (st.backlog) + fprintf(fp, "%s ", sprint_size(st.backlog, b1)); + if (st.qlen) + fprintf(fp, "%up ", st.qlen); } } } static int filter_ifindex; -int print_qdisc(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) +static int print_qdisc(const struct sockaddr_nl *who, + const struct nlmsghdr *n, + void *arg) { FILE *fp = (FILE*)arg; struct tcmsg *t = NLMSG_DATA(n); @@ -255,16 +265,11 @@ int print_qdisc(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) fprintf(fp, "\n"); if (show_stats) { if (tb[TCA_STATS]) { - if (RTA_PAYLOAD(tb[TCA_STATS]) < sizeof(struct tc_stats)) - fprintf(fp, "statistics truncated"); - else { - struct tc_stats st; - memcpy(&st, RTA_DATA(tb[TCA_STATS]), sizeof(st)); - print_tcstats(fp, &st); - fprintf(fp, "\n"); - } + print_tcstats_attr(fp, tb[TCA_STATS]); + fprintf(fp, "\n"); } - if (q && tb[TCA_XSTATS]) { + + if (q && tb[TCA_XSTATS] && q->print_xstats) { q->print_xstats(q, fp, tb[TCA_XSTATS]); fprintf(fp, "\n"); } |