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");
29 fprintf(stderr, " [ divisor NUMBER ]\n");
32 static int sfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
35 struct tc_sfq_qopt opt;
37 memset(&opt, 0, sizeof(opt));
40 if (strcmp(*argv, "quantum") == 0) {
42 if (get_size(&opt.quantum, *argv)) {
43 fprintf(stderr, "Illegal \"limit\"\n");
47 } else if (strcmp(*argv, "perturb") == 0) {
49 if (get_integer(&opt.perturb_period, *argv, 0)) {
50 fprintf(stderr, "Illegal \"perturb\"\n");
54 } else if (strcmp(*argv, "limit") == 0) {
56 if (get_u32(&opt.limit, *argv, 0)) {
57 fprintf(stderr, "Illegal \"limit\"\n");
61 fprintf(stderr, "Illegal \"limit\", must be > 1\n");
65 } else if (strcmp(*argv, "divisor") == 0) {
67 if (get_u32(&opt.divisor, *argv, 0)) {
68 fprintf(stderr, "Illegal \"divisor\"\n");
72 } else if (strcmp(*argv, "help") == 0) {
76 fprintf(stderr, "What is \"%s\"?\n", *argv);
84 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
88 static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
90 struct tc_sfq_qopt *qopt;
96 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
99 fprintf(f, "limit %up ", qopt->limit);
100 fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
102 fprintf(f, "flows %u/%u ", qopt->flows, qopt->divisor);
104 fprintf(f, "divisor %u ", qopt->divisor);
105 if (qopt->perturb_period)
106 fprintf(f, "perturb %dsec ", qopt->perturb_period);
110 static int sfq_print_xstats(struct qdisc_util *qu, FILE *f,
111 struct rtattr *xstats)
113 struct tc_sfq_xstats *st;
117 if (RTA_PAYLOAD(xstats) < sizeof(*st))
119 st = RTA_DATA(xstats);
121 fprintf(f, " allot %d ", st->allot);
126 struct qdisc_util sfq_qdisc_util = {
128 .parse_qopt = sfq_parse_opt,
129 .print_qopt = sfq_print_opt,
130 .print_xstats = sfq_print_xstats,