Commit 649b0755 authored by osdl.net!shemminger's avatar osdl.net!shemminger

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)
parent 4d466e34
......@@ -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");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment