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