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