2 include/linux/pkt_sched.h | 59 +++++++++++++
4 tc/q_esfq.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
5 3 files changed, 260 insertions(+)
9 @@ -8,6 +8,7 @@ SHARED_LIBS ?= y
13 +TCMODULES += q_esfq.o
23 + * This program is free software; you can redistribute it and/or
24 + * modify it under the terms of the GNU General Public License
25 + * as published by the Free Software Foundation; either version
26 + * 2 of the License, or (at your option) any later version.
28 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
30 + * Changes: Alexander Atanasov, <alex@ssi.bg>
31 + * Alexander Clouter, <alex@digriz.org.uk>
32 + * Corey Hickey, <bugfood-c@fatooh.org>
42 +#include <sys/socket.h>
43 +#include <netinet/in.h>
44 +#include <arpa/inet.h>
50 +static void explain(void)
52 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
53 + fprintf(stderr,"Where: \n");
54 + fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
57 +#define usage() return(-1)
59 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
62 + struct tc_esfq_qopt opt;
64 + memset(&opt, 0, sizeof(opt));
66 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
69 + if (strcmp(*argv, "quantum") == 0) {
71 + if (get_size(&opt.quantum, *argv)) {
72 + fprintf(stderr, "Illegal \"quantum\"\n");
76 + } else if (strcmp(*argv, "perturb") == 0) {
78 + if (get_integer(&opt.perturb_period, *argv, 0)) {
79 + fprintf(stderr, "Illegal \"perturb\"\n");
83 + } else if (strcmp(*argv, "depth") == 0) {
85 + if (get_integer((int *) &opt.flows, *argv, 0)) {
86 + fprintf(stderr, "Illegal \"depth\"\n");
90 + } else if (strcmp(*argv, "divisor") == 0) {
92 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
93 + fprintf(stderr, "Illegal \"divisor\"\n");
96 + if(opt.divisor >= 14) {
97 + fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
100 + opt.divisor=pow(2,opt.divisor);
102 + } else if (strcmp(*argv, "limit") == 0) {
104 + if (get_integer((int *) &opt.limit, *argv, 0)) {
105 + fprintf(stderr, "Illegal \"limit\"\n");
109 + } else if (strcmp(*argv, "hash") == 0) {
111 + if(strcmp(*argv, "classic") == 0) {
112 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
114 + if(strcmp(*argv, "dst") == 0) {
115 + opt.hash_kind= TCA_SFQ_HASH_DST;
117 + if(strcmp(*argv, "src") == 0) {
118 + opt.hash_kind= TCA_SFQ_HASH_SRC;
120 + if(strcmp(*argv, "ctorigsrc") == 0) {
121 + opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
123 + if(strcmp(*argv, "ctorigdst") == 0) {
124 + opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
126 + if(strcmp(*argv, "ctreplsrc") == 0) {
127 + opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
129 + if(strcmp(*argv, "ctrepldst") == 0) {
130 + opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
132 + if(strcmp(*argv, "ctnatchg") == 0) {
133 + opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
135 + fprintf(stderr, "Illegal \"hash\"\n");
140 + } else if (strcmp(*argv, "help") == 0) {
144 + fprintf(stderr, "What is \"%s\"?\n", *argv);
152 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
156 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
158 + struct tc_esfq_qopt *qopt;
164 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
166 + qopt = RTA_DATA(opt);
167 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
168 + if (show_details) {
169 + fprintf(f, "limit %up flows %u/%u ",
170 + qopt->limit, qopt->flows, qopt->divisor);
172 + if (qopt->perturb_period)
173 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
175 + fprintf(f,"hash: ");
176 + switch(qopt->hash_kind)
178 + case TCA_SFQ_HASH_CLASSIC:
179 + fprintf(f,"classic");
181 + case TCA_SFQ_HASH_DST:
184 + case TCA_SFQ_HASH_SRC:
187 + case TCA_SFQ_HASH_CTORIGSRC:
188 + fprintf(f,"ctorigsrc");
190 + case TCA_SFQ_HASH_CTORIGDST:
191 + fprintf(f,"ctorigdst");
193 + case TCA_SFQ_HASH_CTREPLSRC:
194 + fprintf(f,"ctreplsrc");
196 + case TCA_SFQ_HASH_CTREPLDST:
197 + fprintf(f,"ctrepldst");
199 + case TCA_SFQ_HASH_CTNATCHG:
200 + fprintf(f,"ctnatchg");
203 + fprintf(f,"Unknown");
208 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
214 +struct qdisc_util esfq_qdisc_util = {
216 + .parse_qopt = esfq_parse_opt,
217 + .print_qopt = esfq_print_opt,
218 + .print_xstats = esfq_print_xstats,