Root/package/network/utils/iproute2/patches/006-iproute2-tc_esfq.patch

1---
2 include/linux/pkt_sched.h | 59 +++++++++++++
3 tc/Makefile | 1
4 tc/q_esfq.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
5 3 files changed, 260 insertions(+)
6
7--- a/tc/Makefile
8+++ b/tc/Makefile
9@@ -8,6 +8,7 @@ SHARED_LIBS ?= y
10 TCMODULES :=
11 TCMODULES += q_fifo.o
12 TCMODULES += q_sfq.o
13+TCMODULES += q_esfq.o
14 TCMODULES += q_red.o
15 TCMODULES += q_prio.o
16 TCMODULES += q_tbf.o
17--- /dev/null
18+++ b/tc/q_esfq.c
19@@ -0,0 +1,200 @@
20+/*
21+ * q_esfq.c ESFQ.
22+ *
23+ * This program is free software; you can redistribute it and/or
24+ * modify it under the terms of the GNU General Public License
25+ * as published by the Free Software Foundation; either version
26+ * 2 of the License, or (at your option) any later version.
27+ *
28+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
29+ *
30+ * Changes: Alexander Atanasov, <alex@ssi.bg>
31+ * Alexander Clouter, <alex@digriz.org.uk>
32+ * Corey Hickey, <bugfood-c@fatooh.org>
33+ *
34+ */
35+
36+#include <stdio.h>
37+#include <stdlib.h>
38+#include <unistd.h>
39+#include <syslog.h>
40+#include <fcntl.h>
41+#include <math.h>
42+#include <sys/socket.h>
43+#include <netinet/in.h>
44+#include <arpa/inet.h>
45+#include <string.h>
46+
47+#include "utils.h"
48+#include "tc_util.h"
49+
50+static void explain(void)
51+{
52+ fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
53+ fprintf(stderr,"Where: \n");
54+ fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
55+}
56+
57+#define usage() return(-1)
58+
59+static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
60+{
61+ int ok=0;
62+ struct tc_esfq_qopt opt;
63+
64+ memset(&opt, 0, sizeof(opt));
65+
66+ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
67+
68+ while (argc > 0) {
69+ if (strcmp(*argv, "quantum") == 0) {
70+ NEXT_ARG();
71+ if (get_size(&opt.quantum, *argv)) {
72+ fprintf(stderr, "Illegal \"quantum\"\n");
73+ return -1;
74+ }
75+ ok++;
76+ } else if (strcmp(*argv, "perturb") == 0) {
77+ NEXT_ARG();
78+ if (get_integer(&opt.perturb_period, *argv, 0)) {
79+ fprintf(stderr, "Illegal \"perturb\"\n");
80+ return -1;
81+ }
82+ ok++;
83+ } else if (strcmp(*argv, "depth") == 0) {
84+ NEXT_ARG();
85+ if (get_integer((int *) &opt.flows, *argv, 0)) {
86+ fprintf(stderr, "Illegal \"depth\"\n");
87+ return -1;
88+ }
89+ ok++;
90+ } else if (strcmp(*argv, "divisor") == 0) {
91+ NEXT_ARG();
92+ if (get_integer((int *) &opt.divisor, *argv, 0)) {
93+ fprintf(stderr, "Illegal \"divisor\"\n");
94+ return -1;
95+ }
96+ if(opt.divisor >= 14) {
97+ fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
98+ return -1;
99+ }
100+ opt.divisor=pow(2,opt.divisor);
101+ ok++;
102+ } else if (strcmp(*argv, "limit") == 0) {
103+ NEXT_ARG();
104+ if (get_integer((int *) &opt.limit, *argv, 0)) {
105+ fprintf(stderr, "Illegal \"limit\"\n");
106+ return -1;
107+ }
108+ ok++;
109+ } else if (strcmp(*argv, "hash") == 0) {
110+ NEXT_ARG();
111+ if(strcmp(*argv, "classic") == 0) {
112+ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
113+ } else
114+ if(strcmp(*argv, "dst") == 0) {
115+ opt.hash_kind= TCA_SFQ_HASH_DST;
116+ } else
117+ if(strcmp(*argv, "src") == 0) {
118+ opt.hash_kind= TCA_SFQ_HASH_SRC;
119+ } else
120+ if(strcmp(*argv, "ctorigsrc") == 0) {
121+ opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
122+ } else
123+ if(strcmp(*argv, "ctorigdst") == 0) {
124+ opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
125+ } else
126+ if(strcmp(*argv, "ctreplsrc") == 0) {
127+ opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
128+ } else
129+ if(strcmp(*argv, "ctrepldst") == 0) {
130+ opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
131+ } else
132+ if(strcmp(*argv, "ctnatchg") == 0) {
133+ opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
134+ } else {
135+ fprintf(stderr, "Illegal \"hash\"\n");
136+ explain();
137+ return -1;
138+ }
139+ ok++;
140+ } else if (strcmp(*argv, "help") == 0) {
141+ explain();
142+ return -1;
143+ } else {
144+ fprintf(stderr, "What is \"%s\"?\n", *argv);
145+ explain();
146+ return -1;
147+ }
148+ argc--; argv++;
149+ }
150+
151+ if (ok)
152+ addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
153+ return 0;
154+}
155+
156+static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
157+{
158+ struct tc_esfq_qopt *qopt;
159+ SPRINT_BUF(b1);
160+
161+ if (opt == NULL)
162+ return 0;
163+
164+ if (RTA_PAYLOAD(opt) < sizeof(*qopt))
165+ return -1;
166+ qopt = RTA_DATA(opt);
167+ fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
168+ if (show_details) {
169+ fprintf(f, "limit %up flows %u/%u ",
170+ qopt->limit, qopt->flows, qopt->divisor);
171+ }
172+ if (qopt->perturb_period)
173+ fprintf(f, "perturb %dsec ", qopt->perturb_period);
174+
175+ fprintf(f,"hash: ");
176+ switch(qopt->hash_kind)
177+ {
178+ case TCA_SFQ_HASH_CLASSIC:
179+ fprintf(f,"classic");
180+ break;
181+ case TCA_SFQ_HASH_DST:
182+ fprintf(f,"dst");
183+ break;
184+ case TCA_SFQ_HASH_SRC:
185+ fprintf(f,"src");
186+ break;
187+ case TCA_SFQ_HASH_CTORIGSRC:
188+ fprintf(f,"ctorigsrc");
189+ break;
190+ case TCA_SFQ_HASH_CTORIGDST:
191+ fprintf(f,"ctorigdst");
192+ break;
193+ case TCA_SFQ_HASH_CTREPLSRC:
194+ fprintf(f,"ctreplsrc");
195+ break;
196+ case TCA_SFQ_HASH_CTREPLDST:
197+ fprintf(f,"ctrepldst");
198+ break;
199+ case TCA_SFQ_HASH_CTNATCHG:
200+ fprintf(f,"ctnatchg");
201+ break;
202+ default:
203+ fprintf(f,"Unknown");
204+ }
205+ return 0;
206+}
207+
208+static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
209+{
210+ return 0;
211+}
212+
213+
214+struct qdisc_util esfq_qdisc_util = {
215+ .id = "esfq",
216+ .parse_qopt = esfq_parse_opt,
217+ .print_qopt = esfq_print_opt,
218+ .print_xstats = esfq_print_xstats,
219+};
220

Archive Download this file



interactive