3 @@ -13,6 +13,7 @@ SHARED_LIBS ?= y
11 --- a/include/linux/pkt_sched.h
12 +++ b/include/linux/pkt_sched.h
13 @@ -226,6 +226,33 @@ struct tc_sfq_xstats {
22 + TCA_SFQ_HASH_CLASSIC,
25 + TCA_SFQ_HASH_FWMARK,
27 + TCA_SFQ_HASH_CTORIGDST,
28 + TCA_SFQ_HASH_CTORIGSRC,
29 + TCA_SFQ_HASH_CTREPLDST,
30 + TCA_SFQ_HASH_CTREPLSRC,
31 + TCA_SFQ_HASH_CTNATCHG,
36 + unsigned quantum; /* Bytes per round allocated to flow */
37 + int perturb_period; /* Period of hash perturbation */
38 + __u32 limit; /* Maximal packets in queue */
39 + unsigned divisor; /* Hash divisor */
40 + unsigned flows; /* Maximal number of flows */
41 + unsigned hash_kind; /* Hash function to use for flow identification */
53 + * This program is free software; you can redistribute it and/or
54 + * modify it under the terms of the GNU General Public License
55 + * as published by the Free Software Foundation; either version
56 + * 2 of the License, or (at your option) any later version.
58 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
60 + * Changes: Alexander Atanasov, <alex@ssi.bg>
61 + * Alexander Clouter, <alex@digriz.org.uk>
62 + * Corey Hickey, <bugfood-c@fatooh.org>
72 +#include <sys/socket.h>
73 +#include <netinet/in.h>
74 +#include <arpa/inet.h>
80 +static void explain(void)
82 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
83 + fprintf(stderr,"Where: \n");
84 + fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
87 +#define usage() return(-1)
89 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
92 + struct tc_esfq_qopt opt;
94 + memset(&opt, 0, sizeof(opt));
96 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
99 + if (strcmp(*argv, "quantum") == 0) {
101 + if (get_size(&opt.quantum, *argv)) {
102 + fprintf(stderr, "Illegal \"quantum\"\n");
106 + } else if (strcmp(*argv, "perturb") == 0) {
108 + if (get_integer(&opt.perturb_period, *argv, 0)) {
109 + fprintf(stderr, "Illegal \"perturb\"\n");
113 + } else if (strcmp(*argv, "depth") == 0) {
115 + if (get_integer((int *) &opt.flows, *argv, 0)) {
116 + fprintf(stderr, "Illegal \"depth\"\n");
120 + } else if (strcmp(*argv, "divisor") == 0) {
122 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
123 + fprintf(stderr, "Illegal \"divisor\"\n");
126 + if(opt.divisor >= 14) {
127 + fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
130 + opt.divisor=pow(2,opt.divisor);
132 + } else if (strcmp(*argv, "limit") == 0) {
134 + if (get_integer((int *) &opt.limit, *argv, 0)) {
135 + fprintf(stderr, "Illegal \"limit\"\n");
139 + } else if (strcmp(*argv, "hash") == 0) {
141 + if(strcmp(*argv, "classic") == 0) {
142 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
144 + if(strcmp(*argv, "dst") == 0) {
145 + opt.hash_kind= TCA_SFQ_HASH_DST;
147 + if(strcmp(*argv, "src") == 0) {
148 + opt.hash_kind= TCA_SFQ_HASH_SRC;
150 + if(strcmp(*argv, "ctorigsrc") == 0) {
151 + opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
153 + if(strcmp(*argv, "ctorigdst") == 0) {
154 + opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
156 + if(strcmp(*argv, "ctreplsrc") == 0) {
157 + opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
159 + if(strcmp(*argv, "ctrepldst") == 0) {
160 + opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
162 + if(strcmp(*argv, "ctnatchg") == 0) {
163 + opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
165 + fprintf(stderr, "Illegal \"hash\"\n");
170 + } else if (strcmp(*argv, "help") == 0) {
174 + fprintf(stderr, "What is \"%s\"?\n", *argv);
182 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
186 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
188 + struct tc_esfq_qopt *qopt;
194 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
196 + qopt = RTA_DATA(opt);
197 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
198 + if (show_details) {
199 + fprintf(f, "limit %up flows %u/%u ",
200 + qopt->limit, qopt->flows, qopt->divisor);
202 + if (qopt->perturb_period)
203 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
205 + fprintf(f,"hash: ");
206 + switch(qopt->hash_kind)
208 + case TCA_SFQ_HASH_CLASSIC:
209 + fprintf(f,"classic");
211 + case TCA_SFQ_HASH_DST:
214 + case TCA_SFQ_HASH_SRC:
217 + case TCA_SFQ_HASH_CTORIGSRC:
218 + fprintf(f,"ctorigsrc");
220 + case TCA_SFQ_HASH_CTORIGDST:
221 + fprintf(f,"ctorigdst");
223 + case TCA_SFQ_HASH_CTREPLSRC:
224 + fprintf(f,"ctreplsrc");
226 + case TCA_SFQ_HASH_CTREPLDST:
227 + fprintf(f,"ctrepldst");
229 + case TCA_SFQ_HASH_CTNATCHG:
230 + fprintf(f,"ctnatchg");
233 + fprintf(f,"Unknown");
238 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
244 +struct qdisc_util esfq_qdisc_util = {
246 + .parse_qopt = esfq_parse_opt,
247 + .print_qopt = esfq_print_opt,
248 + .print_xstats = esfq_print_xstats,