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)
This commit is contained in:
parent
4d466e34d4
commit
649b0755cc
|
|
@ -167,34 +167,44 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
return 0;
|
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);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
fprintf(fp, " Sent %llu bytes %u pkts (dropped %u, overlimits %u ) ",
|
/* handle case where kernel returns more/less than we know about */
|
||||||
(unsigned long long)st->bytes, st->packets, st->drops, st->overlimits);
|
memset(&st, 0, sizeof(st));
|
||||||
if (st->bps || st->pps || st->qlen || st->backlog) {
|
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 ");
|
fprintf(fp, "\n ");
|
||||||
if (st->bps || st->pps) {
|
if (st.bps || st.pps) {
|
||||||
fprintf(fp, "rate ");
|
fprintf(fp, "rate ");
|
||||||
if (st->bps)
|
if (st.bps)
|
||||||
fprintf(fp, "%s ", sprint_rate(st->bps, b1));
|
fprintf(fp, "%s ", sprint_rate(st.bps, b1));
|
||||||
if (st->pps)
|
if (st.pps)
|
||||||
fprintf(fp, "%upps ", st->pps);
|
fprintf(fp, "%upps ", st.pps);
|
||||||
}
|
}
|
||||||
if (st->qlen || st->backlog) {
|
if (st.qlen || st.backlog) {
|
||||||
fprintf(fp, "backlog ");
|
fprintf(fp, "backlog ");
|
||||||
if (st->backlog)
|
if (st.backlog)
|
||||||
fprintf(fp, "%s ", sprint_size(st->backlog, b1));
|
fprintf(fp, "%s ", sprint_size(st.backlog, b1));
|
||||||
if (st->qlen)
|
if (st.qlen)
|
||||||
fprintf(fp, "%up ", st->qlen);
|
fprintf(fp, "%up ", st.qlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_ifindex;
|
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;
|
FILE *fp = (FILE*)arg;
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
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");
|
fprintf(fp, "\n");
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_STATS]) {
|
if (tb[TCA_STATS]) {
|
||||||
if (RTA_PAYLOAD(tb[TCA_STATS]) < sizeof(struct tc_stats))
|
print_tcstats_attr(fp, tb[TCA_STATS]);
|
||||||
fprintf(fp, "statistics truncated");
|
fprintf(fp, "\n");
|
||||||
else {
|
|
||||||
struct tc_stats st;
|
|
||||||
memcpy(&st, RTA_DATA(tb[TCA_STATS]), sizeof(st));
|
|
||||||
print_tcstats(fp, &st);
|
|
||||||
fprintf(fp, "\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (q && tb[TCA_XSTATS]) {
|
|
||||||
|
if (q && tb[TCA_XSTATS] && q->print_xstats) {
|
||||||
q->print_xstats(q, fp, tb[TCA_XSTATS]);
|
q->print_xstats(q, fp, tb[TCA_XSTATS]);
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue