updated iproute2 to 2.6.23 + latest debian patches + latest esfq. deleted patches...
[openwrt/svn-archive/archive.git] / package / iproute2 / patches / 006-iproute2-tc_esfq.patch
1 diff -Naur iproute-2.6.20-070313.orig/include/linux/pkt_sched.h iproute-2.6.20-070313/include/linux/pkt_sched.h
2 --- iproute-2.6.20-070313.orig/include/linux/pkt_sched.h 2007-03-13 14:50:56.000000000 -0700
3 +++ iproute-2.6.20-070313/include/linux/pkt_sched.h 2007-06-09 11:32:22.000000000 -0700
4 @@ -146,8 +146,37 @@
5 *
6 * The only reason for this is efficiency, it is possible
7 * to change these parameters in compile time.
8 + *
9 + * If you need to play with these values, use esfq instead.
10 */
11
12 +/* ESFQ section */
13 +
14 +enum
15 +{
16 + /* traditional */
17 + TCA_SFQ_HASH_CLASSIC,
18 + TCA_SFQ_HASH_DST,
19 + TCA_SFQ_HASH_SRC,
20 + TCA_SFQ_HASH_FWMARK,
21 + /* conntrack */
22 + TCA_SFQ_HASH_CTORIGDST,
23 + TCA_SFQ_HASH_CTORIGSRC,
24 + TCA_SFQ_HASH_CTREPLDST,
25 + TCA_SFQ_HASH_CTREPLSRC,
26 + TCA_SFQ_HASH_CTNATCHG,
27 +};
28 +
29 +struct tc_esfq_qopt
30 +{
31 + unsigned quantum; /* Bytes per round allocated to flow */
32 + int perturb_period; /* Period of hash perturbation */
33 + __u32 limit; /* Maximal packets in queue */
34 + unsigned divisor; /* Hash divisor */
35 + unsigned flows; /* Maximal number of flows */
36 + unsigned hash_kind; /* Hash function to use for flow identification */
37 +};
38 +
39 /* RED section */
40
41 enum
42 diff -Naur iproute-2.6.20-070313.orig/tc/Makefile iproute-2.6.20-070313/tc/Makefile
43 --- iproute-2.6.20-070313.orig/tc/Makefile 2007-03-13 14:50:56.000000000 -0700
44 +++ iproute-2.6.20-070313/tc/Makefile 2007-06-09 00:39:44.000000000 -0700
45 @@ -7,6 +7,7 @@
46 TCMODULES :=
47 TCMODULES += q_fifo.o
48 TCMODULES += q_sfq.o
49 +TCMODULES += q_esfq.o
50 TCMODULES += q_red.o
51 TCMODULES += q_prio.o
52 TCMODULES += q_tbf.o
53 diff -Naur iproute-2.6.20-070313.orig/tc/q_esfq.c iproute-2.6.20-070313/tc/q_esfq.c
54 --- iproute-2.6.20-070313.orig/tc/q_esfq.c 1969-12-31 16:00:00.000000000 -0800
55 +++ iproute-2.6.20-070313/tc/q_esfq.c 2007-06-09 11:38:59.000000000 -0700
56 @@ -0,0 +1,198 @@
57 +/*
58 + * q_esfq.c ESFQ.
59 + *
60 + * This program is free software; you can redistribute it and/or
61 + * modify it under the terms of the GNU General Public License
62 + * as published by the Free Software Foundation; either version
63 + * 2 of the License, or (at your option) any later version.
64 + *
65 + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
66 + *
67 + * Changes: Alexander Atanasov, <alex@ssi.bg>
68 + * Alexander Clouter, <alex@digriz.org.uk>
69 + * Corey Hickey, <bugfood-c@fatooh.org>
70 + *
71 + */
72 +
73 +#include <stdio.h>
74 +#include <stdlib.h>
75 +#include <unistd.h>
76 +#include <syslog.h>
77 +#include <fcntl.h>
78 +#include <math.h>
79 +#include <sys/socket.h>
80 +#include <netinet/in.h>
81 +#include <arpa/inet.h>
82 +#include <string.h>
83 +
84 +#include "utils.h"
85 +#include "tc_util.h"
86 +
87 +static void explain(void)
88 +{
89 + fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
90 + fprintf(stderr,"Where: \n");
91 + fprintf(stderr,"HASHTYPE := { classic | src | dst | fwmark | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg}\n");
92 +}
93 +
94 +#define usage() return(-1)
95 +
96 +static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
97 +{
98 + int ok=0;
99 + struct tc_esfq_qopt opt;
100 +
101 + memset(&opt, 0, sizeof(opt));
102 +
103 + opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
104 +
105 + while (argc > 0) {
106 + if (strcmp(*argv, "quantum") == 0) {
107 + NEXT_ARG();
108 + if (get_size(&opt.quantum, *argv)) {
109 + fprintf(stderr, "Illegal \"quantum\"\n");
110 + return -1;
111 + }
112 + ok++;
113 + } else if (strcmp(*argv, "perturb") == 0) {
114 + NEXT_ARG();
115 + if (get_integer(&opt.perturb_period, *argv, 0)) {
116 + fprintf(stderr, "Illegal \"perturb\"\n");
117 + return -1;
118 + }
119 + ok++;
120 + } else if (strcmp(*argv, "depth") == 0) {
121 + NEXT_ARG();
122 + if (get_integer((int *) &opt.flows, *argv, 0)) {
123 + fprintf(stderr, "Illegal \"depth\"\n");
124 + return -1;
125 + }
126 + ok++;
127 + } else if (strcmp(*argv, "divisor") == 0) {
128 + NEXT_ARG();
129 + if (get_integer((int *) &opt.divisor, *argv, 0)) {
130 + fprintf(stderr, "Illegal \"divisor\"\n");
131 + return -1;
132 + }
133 + if(opt.divisor >= 15) {
134 + fprintf(stderr, "Illegal \"divisor\": must be < 15\n");
135 + return -1;
136 + }
137 + opt.divisor=pow(2,opt.divisor);
138 + ok++;
139 + } else if (strcmp(*argv, "limit") == 0) {
140 + NEXT_ARG();
141 + if (get_integer((int *) &opt.limit, *argv, 0)) {
142 + fprintf(stderr, "Illegal \"limit\"\n");
143 + return -1;
144 + }
145 + ok++;
146 + } else if (strcmp(*argv, "hash") == 0) {
147 + NEXT_ARG();
148 + if (strcmp(*argv, "classic") == 0) {
149 + opt.hash_kind = TCA_SFQ_HASH_CLASSIC;
150 + } else if (strcmp(*argv, "dst") == 0) {
151 + opt.hash_kind = TCA_SFQ_HASH_DST;
152 + } else if (strcmp(*argv, "src") == 0) {
153 + opt.hash_kind = TCA_SFQ_HASH_SRC;
154 + } else if (strcmp(*argv, "fwmark") == 0) {
155 + opt.hash_kind = TCA_SFQ_HASH_FWMARK;
156 + } else if (strcmp(*argv, "ctorigsrc") == 0) {
157 + opt.hash_kind = TCA_SFQ_HASH_CTORIGSRC;
158 + } else if (strcmp(*argv, "ctorigdst") == 0) {
159 + opt.hash_kind = TCA_SFQ_HASH_CTORIGDST;
160 + } else if (strcmp(*argv, "ctreplsrc") == 0) {
161 + opt.hash_kind = TCA_SFQ_HASH_CTREPLSRC;
162 + } else if (strcmp(*argv, "ctrepldst") == 0) {
163 + opt.hash_kind = TCA_SFQ_HASH_CTREPLDST;
164 + } else if (strcmp(*argv, "ctnatchg") == 0) {
165 + opt.hash_kind = TCA_SFQ_HASH_CTNATCHG;
166 + } else {
167 + fprintf(stderr, "Illegal \"hash\"\n");
168 + explain();
169 + return -1;
170 + }
171 + ok++;
172 + } else if (strcmp(*argv, "help") == 0) {
173 + explain();
174 + return -1;
175 + } else {
176 + fprintf(stderr, "What is \"%s\"?\n", *argv);
177 + explain();
178 + return -1;
179 + }
180 + argc--; argv++;
181 + }
182 +
183 + if (ok)
184 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
185 + return 0;
186 +}
187 +
188 +static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
189 +{
190 + struct tc_esfq_qopt *qopt;
191 + SPRINT_BUF(b1);
192 +
193 + if (opt == NULL)
194 + return 0;
195 +
196 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
197 + return -1;
198 + qopt = RTA_DATA(opt);
199 + fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
200 + if (show_details) {
201 + fprintf(f, "limit %up flows %u/%u ",
202 + qopt->limit, qopt->flows, qopt->divisor);
203 + }
204 + if (qopt->perturb_period)
205 + fprintf(f, "perturb %dsec ", qopt->perturb_period);
206 +
207 + fprintf(f,"hash: ");
208 + switch(qopt->hash_kind)
209 + {
210 + case TCA_SFQ_HASH_CLASSIC:
211 + fprintf(f,"classic");
212 + break;
213 + case TCA_SFQ_HASH_DST:
214 + fprintf(f,"dst");
215 + break;
216 + case TCA_SFQ_HASH_SRC:
217 + fprintf(f,"src");
218 + break;
219 + case TCA_SFQ_HASH_FWMARK:
220 + fprintf(f,"fwmark");
221 + break;
222 + case TCA_SFQ_HASH_CTORIGSRC:
223 + fprintf(f,"ctorigsrc");
224 + break;
225 + case TCA_SFQ_HASH_CTORIGDST:
226 + fprintf(f,"ctorigdst");
227 + break;
228 + case TCA_SFQ_HASH_CTREPLSRC:
229 + fprintf(f,"ctreplsrc");
230 + break;
231 + case TCA_SFQ_HASH_CTREPLDST:
232 + fprintf(f,"ctrepldst");
233 + break;
234 + case TCA_SFQ_HASH_CTNATCHG:
235 + fprintf(f,"ctnatchg");
236 + break;
237 + default:
238 + fprintf(f,"Unknown");
239 + }
240 + return 0;
241 +}
242 +
243 +static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
244 +{
245 + return 0;
246 +}
247 +
248 +
249 +struct qdisc_util esfq_qdisc_util = {
250 + .id = "esfq",
251 + .parse_qopt = esfq_parse_opt,
252 + .print_qopt = esfq_print_opt,
253 + .print_xstats = esfq_print_xstats,
254 +};