4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 static void explain(void)
28 fprintf(stderr, "Usage: ... sfq [ limit NUMBER ] [ perturb SECS ] [ quantum BYTES ]\n");
31 static int sfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
34 struct tc_sfq_qopt opt;
36 memset(&opt, 0, sizeof(opt));
39 if (strcmp(*argv, "quantum") == 0) {
41 if (get_size(&opt.quantum, *argv)) {
42 fprintf(stderr, "Illegal \"limit\"\n");
46 } else if (strcmp(*argv, "perturb") == 0) {
48 if (get_integer(&opt.perturb_period, *argv, 0)) {
49 fprintf(stderr, "Illegal \"perturb\"\n");
53 } else if (strcmp(*argv, "limit") == 0) {
55 if (get_u32(&opt.limit, *argv, 0)) {
56 fprintf(stderr, "Illegal \"limit\"\n");
60 fprintf(stderr, "Illegal \"limit\", must be > 1\n");
64 } else if (strcmp(*argv, "help") == 0) {
68 fprintf(stderr, "What is \"%s\"?\n", *argv);
76 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
80 static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
82 struct tc_sfq_qopt *qopt;
88 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
91 fprintf(f, "limit %up ", qopt->limit);
92 fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
94 fprintf(f, "flows %u/%u ", qopt->flows, qopt->divisor);
96 if (qopt->perturb_period)
97 fprintf(f, "perturb %dsec ", qopt->perturb_period);
101 static int sfq_print_xstats(struct qdisc_util *qu, FILE *f,
102 struct rtattr *xstats)
104 struct tc_sfq_xstats *st;
108 if (RTA_PAYLOAD(xstats) < sizeof(*st))
110 st = RTA_DATA(xstats);
112 fprintf(f, " allot %d ", st->allot);
117 struct qdisc_util sfq_qdisc_util = {
119 .parse_qopt = sfq_parse_opt,
120 .print_qopt = sfq_print_opt,
121 .print_xstats = sfq_print_xstats,