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