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