]>
Commit | Line | Data |
---|---|---|
cab29381 | 1 | diff -ruN iproute-20041019/include/linux/pkt_sched.h iproute-20041019.srr.patched.v0.4/include/linux/pkt_sched.h |
2 | --- iproute-20041019/include/linux/pkt_sched.h 2006-07-27 13:04:00.000000000 +0300 | |
3 | +++ iproute-20041019.srr.patched.v0.4/include/linux/pkt_sched.h 2006-07-27 13:11:36.000000000 +0300 | |
4 | @@ -550,6 +550,14 @@ | |
5 | * to change these parameters in compile time. | |
6 | */ | |
7 | ||
8 | +/* SRR section */ | |
9 | +struct tc_srr_qopt { | |
10 | + __u32 slots; | |
11 | + __u32 used_slots; | |
12 | + __u32 slot_limit; | |
13 | + __u32 slot_classify; | |
14 | +}; | |
15 | + | |
16 | /* RED section */ | |
17 | ||
18 | enum | |
19 | diff -ruN iproute-20041019/tc/q_srr.c iproute-20041019.srr.patched.v0.4/tc/q_srr.c | |
20 | --- iproute-20041019/tc/q_srr.c 1970-01-01 03:00:00.000000000 +0300 | |
21 | +++ iproute-20041019.srr.patched.v0.4/tc/q_srr.c 2006-07-27 12:59:27.000000000 +0300 | |
22 | @@ -0,0 +1,118 @@ | |
23 | +#include <unistd.h> | |
24 | +#include <syslog.h> | |
25 | +#include <fcntl.h> | |
26 | +#include <sys/socket.h> | |
27 | +#include <netinet/in.h> | |
28 | +#include <arpa/inet.h> | |
29 | +#include <string.h> | |
30 | + | |
31 | +#include "utils.h" | |
32 | +#include "tc_util.h" | |
33 | + | |
34 | +#define SRR_CL_SRC 0 | |
35 | +#define SRR_CL_DST 1 | |
36 | +#define SRR_CL_FWM 2 | |
37 | + | |
38 | +static void explain(void) | |
39 | +{ | |
40 | + fprintf(stderr, "Usage: ... srr [ slots NUMBER ] [ limit NUMBER ] [ classify src/dst/fw ]\n"); | |
41 | +} | |
42 | + | |
43 | +#define usage() return(-1) | |
44 | + | |
45 | +static int srr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) | |
46 | +{ | |
47 | + int ok=0; | |
48 | + struct tc_srr_qopt opt; | |
49 | + | |
50 | + memset(&opt, 0, sizeof(opt)); | |
51 | + | |
52 | + while ( argc > 0 ) { | |
53 | + if ( strcmp(*argv, "slots") == 0 ) { | |
54 | + NEXT_ARG(); | |
55 | + if ( get_u32(&opt.slots, *argv, 0) ) { | |
56 | + fprintf(stderr, "Illegal \"slot\"\n"); | |
57 | + return -1; | |
58 | + } | |
59 | + ok++; | |
60 | + } | |
61 | + else if ( strcmp(*argv, "limit") == 0 ) { | |
62 | + NEXT_ARG(); | |
63 | + if ( get_u32(&opt.slot_limit, *argv, 0) ) { | |
64 | + fprintf(stderr, "Illegal \"limit\"\n"); | |
65 | + } | |
66 | + ok++; | |
67 | + } | |
68 | + else if ( strcmp(*argv, "classify") == 0 ) { | |
69 | + NEXT_ARG(); | |
70 | + if ( strcmp(*argv, "src") == 0 ) { | |
71 | + opt.slot_classify = SRR_CL_SRC; | |
72 | + goto cl_ok; | |
73 | + } | |
74 | + if ( strcmp(*argv, "dst") == 0 ) { | |
75 | + opt.slot_classify = SRR_CL_DST; | |
76 | + goto cl_ok; | |
77 | + } | |
78 | + if ( strcmp(*argv, "fw") == 0 ) { | |
79 | + opt.slot_classify = SRR_CL_FWM; | |
80 | + goto cl_ok; | |
81 | + } | |
82 | + fprintf(stderr, "Illegal \"classify\"\n"); | |
83 | + return -1; | |
84 | + | |
85 | + cl_ok: ok++; | |
86 | + } | |
87 | + else if ( strcmp(*argv, "help") == 0 ) { | |
88 | + explain(); | |
89 | + return -1; | |
90 | + } | |
91 | + else { | |
92 | + fprintf(stderr, "What is \"%s\"?\n", *argv); | |
93 | + explain(); | |
94 | + return -1; | |
95 | + } | |
96 | + argc--; argv++; | |
97 | + } | |
98 | + | |
99 | + if ( ok ) | |
100 | + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); | |
101 | + return 0; | |
102 | +} | |
103 | + | |
104 | +static int srr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) | |
105 | +{ | |
106 | + struct tc_srr_qopt *qopt; | |
107 | + | |
108 | + if ( opt == NULL ) | |
109 | + return 0; | |
110 | + | |
111 | + if (RTA_PAYLOAD(opt) < sizeof(*qopt)) | |
112 | + return -1; | |
113 | + | |
114 | + qopt = RTA_DATA(opt); | |
115 | + fprintf(f, "slots %u ", qopt->slots); | |
116 | + fprintf(f, "used %u/%u ", qopt->used_slots, qopt->slots); | |
117 | + fprintf(f, "qlimit %u ", qopt->slot_limit); | |
118 | + switch (qopt->slot_classify) { | |
119 | + case SRR_CL_SRC: | |
120 | + fprintf(f, "classify IP_SRC"); | |
121 | + break; | |
122 | + case SRR_CL_DST: | |
123 | + fprintf(f, "classify IP_DST"); | |
124 | + break; | |
125 | + case SRR_CL_FWM: | |
126 | + fprintf(f, "classify FW"); | |
127 | + break; | |
128 | + default: | |
129 | + fprintf(f, "classify UNKNOW!!!"); | |
130 | + } | |
131 | + | |
132 | + return 0; | |
133 | +} | |
134 | + | |
135 | + | |
136 | +struct qdisc_util srr_qdisc_util = { | |
137 | + .id = "srr", | |
138 | + .parse_qopt = srr_parse_opt, | |
139 | + .print_qopt = srr_print_opt, | |
140 | +}; | |
141 | --- iproute-2.6.22-070710/tc/Makefile.orig 2007-07-18 18:15:46.749073720 +0200 | |
142 | +++ iproute-2.6.22-070710/tc/Makefile 2007-07-18 18:17:19.296663578 +0200 | |
143 | @@ -8,6 +8,7 @@ | |
144 | TCMODULES += q_fifo.o | |
145 | TCMODULES += q_sfq.o | |
146 | TCMODULES += q_esfq.o | |
147 | +TCMODULES += q_srr.o | |
148 | TCMODULES += q_red.o | |
149 | TCMODULES += q_prio.o | |
150 | TCMODULES += q_tbf.o |