2004-06-08 06:04:51 +08:00
|
|
|
/*
|
|
|
|
* q_htb.c HTB.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Authors: Martin Devera, devik@cdi.cz
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "tc_util.h"
|
|
|
|
|
|
|
|
#define HTB_TC_VER 0x30003
|
|
|
|
#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
|
|
|
|
#error "Different kernel and TC HTB versions"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void explain(void)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
|
2013-09-14 00:10:01 +08:00
|
|
|
" [direct_qlen P]\n"
|
2004-06-08 06:04:51 +08:00
|
|
|
" default minor id of class to which unclassified packets are sent {0}\n"
|
|
|
|
" r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
|
|
|
|
" debug string of 16 numbers each 0-3 {0}\n\n"
|
2013-09-14 00:10:01 +08:00
|
|
|
" direct_qlen Limit of the direct queue {in packets}\n"
|
2004-07-31 04:26:15 +08:00
|
|
|
"... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]\n"
|
|
|
|
" [prio P] [slot S] [pslot PS]\n"
|
2004-06-08 06:04:51 +08:00
|
|
|
" [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
|
|
|
|
" rate rate allocated to this class (class can still borrow)\n"
|
|
|
|
" burst max bytes burst which can be accumulated during idle period {computed}\n"
|
2004-07-31 04:26:15 +08:00
|
|
|
" mpu minimum packet size used in rate computations\n"
|
|
|
|
" overhead per-packet size overhead used in rate computations\n"
|
2008-04-10 05:01:01 +08:00
|
|
|
" linklay adapting to a linklayer e.g. atm\n"
|
2004-06-08 06:04:51 +08:00
|
|
|
" ceil definite upper class rate (no borrows) {rate}\n"
|
|
|
|
" cburst burst but for ceil {computed}\n"
|
|
|
|
" mtu max packet size we create rate map for {1600}\n"
|
|
|
|
" prio priority of leaf; lower are served first {0}\n"
|
|
|
|
" quantum how much bytes to serve from leaf at once {use r2q}\n"
|
2016-03-22 02:48:36 +08:00
|
|
|
"\nTC HTB version %d.%d\n", HTB_TC_VER>>16, HTB_TC_VER&0xffff
|
2004-06-08 06:04:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void explain1(char *arg)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Illegal \"%s\"\n", arg);
|
|
|
|
explain();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
|
|
|
|
{
|
2014-03-08 21:10:03 +08:00
|
|
|
unsigned int direct_qlen = ~0U;
|
2016-07-18 22:48:42 +08:00
|
|
|
struct tc_htb_glob opt = {
|
|
|
|
.rate2quantum = 10,
|
|
|
|
.version = 3,
|
|
|
|
};
|
2004-06-08 06:04:51 +08:00
|
|
|
struct rtattr *tail;
|
2016-03-22 02:48:36 +08:00
|
|
|
unsigned int i; char *p;
|
|
|
|
|
2004-06-08 06:04:51 +08:00
|
|
|
while (argc > 0) {
|
|
|
|
if (matches(*argv, "r2q") == 0) {
|
2013-06-07 23:54:45 +08:00
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&opt.rate2quantum, *argv, 10)) {
|
|
|
|
explain1("r2q"); return -1;
|
|
|
|
}
|
2004-06-08 06:04:51 +08:00
|
|
|
} else if (matches(*argv, "default") == 0) {
|
2013-06-07 23:54:45 +08:00
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&opt.defcls, *argv, 16)) {
|
|
|
|
explain1("default"); return -1;
|
|
|
|
}
|
2004-06-08 06:04:51 +08:00
|
|
|
} else if (matches(*argv, "debug") == 0) {
|
2013-06-07 23:54:45 +08:00
|
|
|
NEXT_ARG(); p = *argv;
|
2016-03-22 02:48:36 +08:00
|
|
|
for (i = 0; i < 16; i++, p++) {
|
|
|
|
if (*p < '0' || *p > '3') break;
|
2013-06-07 23:54:45 +08:00
|
|
|
opt.debug |= (*p-'0')<<(2*i);
|
|
|
|
}
|
2014-03-08 21:10:03 +08:00
|
|
|
} else if (matches(*argv, "direct_qlen") == 0) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&direct_qlen, *argv, 10)) {
|
|
|
|
explain1("direct_qlen"); return -1;
|
|
|
|
}
|
2004-06-08 06:04:51 +08:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
|
|
|
explain();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
argc--; argv++;
|
|
|
|
}
|
2005-01-18 09:24:18 +08:00
|
|
|
tail = NLMSG_TAIL(n);
|
2004-06-08 06:04:51 +08:00
|
|
|
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
|
|
|
|
addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
|
2014-03-08 21:10:03 +08:00
|
|
|
if (direct_qlen != ~0U)
|
|
|
|
addattr_l(n, 2024, TCA_HTB_DIRECT_QLEN,
|
|
|
|
&direct_qlen, sizeof(direct_qlen));
|
2005-01-18 09:24:18 +08:00
|
|
|
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
2004-06-08 06:04:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
|
|
|
|
{
|
2016-03-22 02:48:36 +08:00
|
|
|
int ok = 0;
|
2016-07-18 22:48:42 +08:00
|
|
|
struct tc_htb_opt opt = {};
|
2016-03-22 02:48:36 +08:00
|
|
|
__u32 rtab[256], ctab[256];
|
|
|
|
unsigned buffer = 0, cbuffer = 0;
|
|
|
|
int cell_log = -1, ccell_log = -1;
|
2016-07-18 22:48:42 +08:00
|
|
|
unsigned int mtu = 1600; /* eth packet len */
|
2007-09-11 22:59:58 +08:00
|
|
|
unsigned short mpu = 0;
|
|
|
|
unsigned short overhead = 0;
|
2008-04-10 05:01:01 +08:00
|
|
|
unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
|
2004-06-08 06:04:51 +08:00
|
|
|
struct rtattr *tail;
|
2013-11-13 06:34:07 +08:00
|
|
|
__u64 ceil64 = 0, rate64 = 0;
|
2004-06-08 06:04:51 +08:00
|
|
|
|
|
|
|
while (argc > 0) {
|
|
|
|
if (matches(*argv, "prio") == 0) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&opt.prio, *argv, 10)) {
|
|
|
|
explain1("prio"); return -1;
|
|
|
|
}
|
|
|
|
ok++;
|
|
|
|
} else if (matches(*argv, "mtu") == 0) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&mtu, *argv, 10)) {
|
|
|
|
explain1("mtu"); return -1;
|
|
|
|
}
|
2004-07-31 04:26:15 +08:00
|
|
|
} else if (matches(*argv, "mpu") == 0) {
|
|
|
|
NEXT_ARG();
|
2007-09-11 22:59:58 +08:00
|
|
|
if (get_u16(&mpu, *argv, 10)) {
|
2004-07-31 04:26:15 +08:00
|
|
|
explain1("mpu"); return -1;
|
|
|
|
}
|
|
|
|
} else if (matches(*argv, "overhead") == 0) {
|
|
|
|
NEXT_ARG();
|
2007-09-11 22:59:58 +08:00
|
|
|
if (get_u16(&overhead, *argv, 10)) {
|
2004-07-31 04:26:15 +08:00
|
|
|
explain1("overhead"); return -1;
|
|
|
|
}
|
2008-04-10 05:01:01 +08:00
|
|
|
} else if (matches(*argv, "linklayer") == 0) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (get_linklayer(&linklayer, *argv)) {
|
|
|
|
explain1("linklayer"); return -1;
|
|
|
|
}
|
2004-06-08 06:04:51 +08:00
|
|
|
} else if (matches(*argv, "quantum") == 0) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (get_u32(&opt.quantum, *argv, 10)) {
|
|
|
|
explain1("quantum"); return -1;
|
|
|
|
}
|
|
|
|
} else if (matches(*argv, "burst") == 0 ||
|
2013-06-07 23:54:45 +08:00
|
|
|
strcmp(*argv, "buffer") == 0 ||
|
|
|
|
strcmp(*argv, "maxburst") == 0) {
|
2004-06-08 06:04:51 +08:00
|
|
|
NEXT_ARG();
|
|
|
|
if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
|
|
|
|
explain1("buffer");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ok++;
|
|
|
|
} else if (matches(*argv, "cburst") == 0 ||
|
2013-06-07 23:54:45 +08:00
|
|
|
strcmp(*argv, "cbuffer") == 0 ||
|
|
|
|
strcmp(*argv, "cmaxburst") == 0) {
|
2004-06-08 06:04:51 +08:00
|
|
|
NEXT_ARG();
|
|
|
|
if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
|
|
|
|
explain1("cbuffer");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ok++;
|
|
|
|
} else if (strcmp(*argv, "ceil") == 0) {
|
|
|
|
NEXT_ARG();
|
2013-11-13 06:34:07 +08:00
|
|
|
if (ceil64) {
|
2004-06-08 06:04:51 +08:00
|
|
|
fprintf(stderr, "Double \"ceil\" spec\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-11-13 06:34:07 +08:00
|
|
|
if (get_rate64(&ceil64, *argv)) {
|
2004-06-08 06:04:51 +08:00
|
|
|
explain1("ceil");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ok++;
|
|
|
|
} else if (strcmp(*argv, "rate") == 0) {
|
|
|
|
NEXT_ARG();
|
2013-11-13 06:34:07 +08:00
|
|
|
if (rate64) {
|
2004-06-08 06:04:51 +08:00
|
|
|
fprintf(stderr, "Double \"rate\" spec\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-11-13 06:34:07 +08:00
|
|
|
if (get_rate64(&rate64, *argv)) {
|
2004-06-08 06:04:51 +08:00
|
|
|
explain1("rate");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ok++;
|
|
|
|
} else if (strcmp(*argv, "help") == 0) {
|
|
|
|
explain();
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
|
|
|
explain();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
argc--; argv++;
|
|
|
|
}
|
|
|
|
|
2013-06-07 23:54:45 +08:00
|
|
|
/* if (!ok)
|
2004-06-08 06:04:51 +08:00
|
|
|
return 0;*/
|
|
|
|
|
2013-11-13 06:34:07 +08:00
|
|
|
if (!rate64) {
|
2004-06-08 06:04:51 +08:00
|
|
|
fprintf(stderr, "\"rate\" is required.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* if ceil params are missing, use the same as rate */
|
2013-11-13 06:34:07 +08:00
|
|
|
if (!ceil64)
|
|
|
|
ceil64 = rate64;
|
|
|
|
|
|
|
|
opt.rate.rate = (rate64 >= (1ULL << 32)) ? ~0U : rate64;
|
|
|
|
opt.ceil.rate = (ceil64 >= (1ULL << 32)) ? ~0U : ceil64;
|
2004-06-08 06:04:51 +08:00
|
|
|
|
|
|
|
/* compute minimal allowed burst from rate; mtu is added here to make
|
|
|
|
sute that buffer is larger than mtu and to have some safeguard space */
|
2013-11-13 06:34:07 +08:00
|
|
|
if (!buffer)
|
|
|
|
buffer = rate64 / get_hz() + mtu;
|
|
|
|
if (!cbuffer)
|
|
|
|
cbuffer = ceil64 / get_hz() + mtu;
|
2004-06-08 06:04:51 +08:00
|
|
|
|
2007-09-11 22:59:58 +08:00
|
|
|
opt.ceil.overhead = overhead;
|
|
|
|
opt.rate.overhead = overhead;
|
|
|
|
|
|
|
|
opt.ceil.mpu = mpu;
|
|
|
|
opt.rate.mpu = mpu;
|
2004-07-31 04:26:15 +08:00
|
|
|
|
2008-04-10 05:01:01 +08:00
|
|
|
if (tc_calc_rtable(&opt.rate, rtab, cell_log, mtu, linklayer) < 0) {
|
2004-06-08 06:04:51 +08:00
|
|
|
fprintf(stderr, "htb: failed to calculate rate table.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-11-13 06:34:07 +08:00
|
|
|
opt.buffer = tc_calc_xmittime(rate64, buffer);
|
2006-12-06 02:10:22 +08:00
|
|
|
|
2008-04-10 05:01:01 +08:00
|
|
|
if (tc_calc_rtable(&opt.ceil, ctab, ccell_log, mtu, linklayer) < 0) {
|
2004-06-08 06:04:51 +08:00
|
|
|
fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-11-13 06:34:07 +08:00
|
|
|
opt.cbuffer = tc_calc_xmittime(ceil64, cbuffer);
|
2004-06-08 06:04:51 +08:00
|
|
|
|
2005-01-18 09:24:18 +08:00
|
|
|
tail = NLMSG_TAIL(n);
|
2004-06-08 06:04:51 +08:00
|
|
|
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
|
2013-11-13 06:34:07 +08:00
|
|
|
|
|
|
|
if (rate64 >= (1ULL << 32))
|
|
|
|
addattr_l(n, 1124, TCA_HTB_RATE64, &rate64, sizeof(rate64));
|
|
|
|
|
|
|
|
if (ceil64 >= (1ULL << 32))
|
|
|
|
addattr_l(n, 1224, TCA_HTB_CEIL64, &ceil64, sizeof(ceil64));
|
|
|
|
|
2004-06-08 06:04:51 +08:00
|
|
|
addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
|
|
|
|
addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
|
|
|
|
addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
|
2005-01-18 09:24:18 +08:00
|
|
|
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
2004-06-08 06:04:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
|
|
|
{
|
2013-09-14 00:10:01 +08:00
|
|
|
struct rtattr *tb[TCA_HTB_MAX + 1];
|
2004-06-08 06:04:51 +08:00
|
|
|
struct tc_htb_opt *hopt;
|
|
|
|
struct tc_htb_glob *gopt;
|
2016-03-22 02:48:36 +08:00
|
|
|
double buffer, cbuffer;
|
2013-08-30 20:02:10 +08:00
|
|
|
unsigned int linklayer;
|
2013-11-13 06:34:07 +08:00
|
|
|
__u64 rate64, ceil64;
|
2016-03-22 02:48:36 +08:00
|
|
|
|
2004-06-08 06:04:51 +08:00
|
|
|
SPRINT_BUF(b1);
|
|
|
|
SPRINT_BUF(b2);
|
2015-12-19 23:26:03 +08:00
|
|
|
SPRINT_BUF(b3);
|
2004-06-08 06:04:51 +08:00
|
|
|
|
|
|
|
if (opt == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2013-09-14 00:10:01 +08:00
|
|
|
parse_rtattr_nested(tb, TCA_HTB_MAX, opt);
|
2004-06-08 06:04:51 +08:00
|
|
|
|
|
|
|
if (tb[TCA_HTB_PARMS]) {
|
2013-06-07 23:54:45 +08:00
|
|
|
hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
|
|
|
|
if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
|
2004-06-08 06:04:51 +08:00
|
|
|
|
|
|
|
if (!hopt->level) {
|
|
|
|
fprintf(f, "prio %d ", (int)hopt->prio);
|
|
|
|
if (show_details)
|
|
|
|
fprintf(f, "quantum %d ", (int)hopt->quantum);
|
|
|
|
}
|
2013-11-13 06:34:07 +08:00
|
|
|
|
|
|
|
rate64 = hopt->rate.rate;
|
|
|
|
if (tb[TCA_HTB_RATE64] &&
|
|
|
|
RTA_PAYLOAD(tb[TCA_HTB_RATE64]) >= sizeof(rate64)) {
|
|
|
|
rate64 = rta_getattr_u64(tb[TCA_HTB_RATE64]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ceil64 = hopt->ceil.rate;
|
|
|
|
if (tb[TCA_HTB_CEIL64] &&
|
|
|
|
RTA_PAYLOAD(tb[TCA_HTB_CEIL64]) >= sizeof(ceil64))
|
|
|
|
ceil64 = rta_getattr_u64(tb[TCA_HTB_CEIL64]);
|
|
|
|
|
|
|
|
fprintf(f, "rate %s ", sprint_rate(rate64, b1));
|
2013-06-07 23:54:45 +08:00
|
|
|
if (hopt->rate.overhead)
|
|
|
|
fprintf(f, "overhead %u ", hopt->rate.overhead);
|
2013-11-13 06:34:07 +08:00
|
|
|
buffer = tc_calc_xmitsize(rate64, hopt->buffer);
|
|
|
|
|
|
|
|
fprintf(f, "ceil %s ", sprint_rate(ceil64, b1));
|
|
|
|
cbuffer = tc_calc_xmitsize(ceil64, hopt->cbuffer);
|
2013-08-30 20:02:10 +08:00
|
|
|
linklayer = (hopt->rate.linklayer & TC_LINKLAYER_MASK);
|
|
|
|
if (linklayer > TC_LINKLAYER_ETHERNET || show_details)
|
2015-12-19 23:26:03 +08:00
|
|
|
fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, b3));
|
2013-06-07 23:54:45 +08:00
|
|
|
if (show_details) {
|
2015-12-19 23:25:52 +08:00
|
|
|
fprintf(f, "burst %s/%u mpu %s ",
|
2013-06-07 23:54:45 +08:00
|
|
|
sprint_size(buffer, b1),
|
|
|
|
1<<hopt->rate.cell_log,
|
2015-12-19 23:25:52 +08:00
|
|
|
sprint_size(hopt->rate.mpu, b2));
|
|
|
|
fprintf(f, "cburst %s/%u mpu %s ",
|
2013-06-07 23:54:45 +08:00
|
|
|
sprint_size(cbuffer, b1),
|
|
|
|
1<<hopt->ceil.cell_log,
|
2015-12-19 23:25:52 +08:00
|
|
|
sprint_size(hopt->ceil.mpu, b2));
|
2013-06-07 23:54:45 +08:00
|
|
|
fprintf(f, "level %d ", (int)hopt->level);
|
|
|
|
} else {
|
|
|
|
fprintf(f, "burst %s ", sprint_size(buffer, b1));
|
|
|
|
fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
|
|
|
|
}
|
|
|
|
if (show_raw)
|
|
|
|
fprintf(f, "buffer [%08x] cbuffer [%08x] ",
|
2016-03-22 02:48:36 +08:00
|
|
|
hopt->buffer, hopt->cbuffer);
|
2004-06-08 06:04:51 +08:00
|
|
|
}
|
|
|
|
if (tb[TCA_HTB_INIT]) {
|
2013-06-07 23:54:45 +08:00
|
|
|
gopt = RTA_DATA(tb[TCA_HTB_INIT]);
|
|
|
|
if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
|
2004-06-08 06:04:51 +08:00
|
|
|
|
2013-06-07 23:54:45 +08:00
|
|
|
fprintf(f, "r2q %d default %x direct_packets_stat %u",
|
2016-03-22 02:48:36 +08:00
|
|
|
gopt->rate2quantum, gopt->defcls, gopt->direct_pkts);
|
2004-06-08 06:04:51 +08:00
|
|
|
if (show_details)
|
2016-03-22 02:48:36 +08:00
|
|
|
fprintf(f, " ver %d.%d", gopt->version >> 16, gopt->version & 0xffff);
|
2004-06-08 06:04:51 +08:00
|
|
|
}
|
2013-09-14 00:10:01 +08:00
|
|
|
if (tb[TCA_HTB_DIRECT_QLEN] &&
|
|
|
|
RTA_PAYLOAD(tb[TCA_HTB_DIRECT_QLEN]) >= sizeof(__u32)) {
|
|
|
|
__u32 direct_qlen = rta_getattr_u32(tb[TCA_HTB_DIRECT_QLEN]);
|
|
|
|
|
|
|
|
fprintf(f, " direct_qlen %u", direct_qlen);
|
|
|
|
}
|
2004-06-08 06:04:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
|
|
|
|
{
|
|
|
|
struct tc_htb_xstats *st;
|
2016-03-22 02:48:36 +08:00
|
|
|
|
2004-06-08 06:04:51 +08:00
|
|
|
if (xstats == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (RTA_PAYLOAD(xstats) < sizeof(*st))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
st = RTA_DATA(xstats);
|
2006-12-06 02:10:22 +08:00
|
|
|
fprintf(f, " lended: %u borrowed: %u giants: %u\n",
|
2016-03-22 02:48:36 +08:00
|
|
|
st->lends, st->borrows, st->giants);
|
|
|
|
fprintf(f, " tokens: %d ctokens: %d\n", st->tokens, st->ctokens);
|
2004-06-08 06:04:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-29 02:35:49 +08:00
|
|
|
struct qdisc_util htb_qdisc_util = {
|
2016-03-22 02:48:36 +08:00
|
|
|
.id = "htb",
|
2004-09-01 01:45:21 +08:00
|
|
|
.parse_qopt = htb_parse_opt,
|
|
|
|
.print_qopt = htb_print_opt,
|
2016-03-22 02:48:36 +08:00
|
|
|
.print_xstats = htb_print_xstats,
|
2004-09-01 01:45:21 +08:00
|
|
|
.parse_copt = htb_parse_class_opt,
|
|
|
|
.print_copt = htb_print_opt,
|
2004-06-08 06:04:51 +08:00
|
|
|
};
|