also ignore env directory
[openwrt.git] / package / iproute2 / patches / 000-debian_patches_3.patch
1 Index: iproute2-2.6.25/doc/ip-cref.tex
2 ===================================================================
3 --- iproute2-2.6.25.orig/doc/ip-cref.tex 2008-05-01 00:17:55.000000000 +0100
4 +++ iproute2-2.6.25/doc/ip-cref.tex 2008-05-01 00:26:48.000000000 +0100
5 @@ -1315,6 +1315,19 @@ peers are allowed to send to us.
6 If it is not given, Linux uses the value selected with \verb|sysctl|
7 variable \verb|net/ipv4/tcp_reordering|.
8
9 +\item \verb|hoplimit NUMBER|
10 +
11 +--- [2.5.74+ only] Hop limit on the path to this destination. If it is not
12 + given, Linux uses the value selected with \verb|sysctl| variable
13 + \verb|net/ipv4/ip_default_ttl|.
14 +
15 +\item \verb|initcwnd NUMBER|
16 +
17 +--- [2.5.70+ only] Initial congestion window size when establishing
18 + connections to this destination. This value is multiplied with the
19 + MSS (``Maximal Segment Size'') for the connection to get the actual
20 + window size. If it is not given (or set to zero), Linux uses the
21 + values specified in~\cite{RFC2414}.
22
23
24 \item \verb|nexthop NEXTHOP|
25 @@ -2644,6 +2657,9 @@ http://www.cisco.com/univercd/cc/td/doc/
26 \bibitem{RFC-DHCP} R.~Droms.
27 ``Dynamic Host Configuration Protocol.'', RFC-2131
28
29 +\bibitem{RFC2414} M.~Allman, S.~Floyd, C.~Partridge.
30 +``Increasing TCP's Initial Window'', RFC-2414.
31 +
32 \end{thebibliography}
33
34
35 Index: iproute2-2.6.25/doc/Makefile
36 ===================================================================
37 --- iproute2-2.6.25.orig/doc/Makefile 2008-05-01 00:17:55.000000000 +0100
38 +++ iproute2-2.6.25/doc/Makefile 2008-05-01 00:26:48.000000000 +0100
39 @@ -14,6 +14,7 @@ PAGESIZE=a4
40 PAGESPERPAGE=2
41
42 HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
43 +TXTFILES=$(subst .sgml,.txt,$(shell echo *.sgml))
44 DVIFILES=$(subst .ps,.dvi,$(PSFILES))
45
46
47 @@ -23,6 +24,8 @@ pstwocol: $(PSFILES)
48
49 html: $(HTMLFILES)
50
51 +txt: $(TXTFILES)
52 +
53 dvi: $(DVIFILES)
54
55 print: $(PSFILES)
56 @@ -47,9 +50,12 @@ print: $(PSFILES)
57 %.html: %.sgml
58 $(SGML2HTML) $<
59
60 +%.txt: %.html
61 + lynx -nolist -dump $< > $@
62 +
63 install:
64 install -m 0644 $(shell echo *.tex) $(DESTDIR)$(DOCDIR)
65 install -m 0644 $(shell echo *.sgml) $(DESTDIR)$(DOCDIR)
66
67 clean:
68 - rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html
69 + rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html $(TXTFILES)
70 Index: iproute2-2.6.25/include/linux/pkt_sched.h
71 ===================================================================
72 --- iproute2-2.6.25.orig/include/linux/pkt_sched.h 2008-05-01 00:17:55.000000000 +0100
73 +++ iproute2-2.6.25/include/linux/pkt_sched.h 2008-05-01 00:37:45.000000000 +0100
74 @@ -1,3 +1,409 @@
75 +#if 0
76 +#ifndef __LINUX_PKT_SCHED_H
77 +#define __LINUX_PKT_SCHED_H
78 +
79 +/* Logical priority bands not depending on specific packet scheduler.
80 + Every scheduler will map them to real traffic classes, if it has
81 + no more precise mechanism to classify packets.
82 +
83 + These numbers have no special meaning, though their coincidence
84 + with obsolete IPv6 values is not occasional :-). New IPv6 drafts
85 + preferred full anarchy inspired by diffserv group.
86 +
87 + Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
88 + class, actually, as rule it will be handled with more care than
89 + filler or even bulk.
90 + */
91 +
92 +#define TC_PRIO_BESTEFFORT 0
93 +#define TC_PRIO_FILLER 1
94 +#define TC_PRIO_BULK 2
95 +#define TC_PRIO_INTERACTIVE_BULK 4
96 +#define TC_PRIO_INTERACTIVE 6
97 +#define TC_PRIO_CONTROL 7
98 +
99 +#define TC_PRIO_MAX 15
100 +
101 +/* Generic queue statistics, available for all the elements.
102 + Particular schedulers may have also their private records.
103 + */
104 +
105 +struct tc_stats
106 +{
107 + __u64 bytes; /* NUmber of enqueues bytes */
108 + __u32 packets; /* Number of enqueued packets */
109 + __u32 drops; /* Packets dropped because of lack of resources */
110 + __u32 overlimits; /* Number of throttle events when this
111 + * flow goes out of allocated bandwidth */
112 + __u32 bps; /* Current flow byte rate */
113 + __u32 pps; /* Current flow packet rate */
114 + __u32 qlen;
115 + __u32 backlog;
116 +#ifdef __KERNEL__
117 + spinlock_t *lock;
118 +#endif
119 +};
120 +
121 +struct tc_estimator
122 +{
123 + char interval;
124 + unsigned char ewma_log;
125 +};
126 +
127 +/* "Handles"
128 + ---------
129 +
130 + All the traffic control objects have 32bit identifiers, or "handles".
131 +
132 + They can be considered as opaque numbers from user API viewpoint,
133 + but actually they always consist of two fields: major and
134 + minor numbers, which are interpreted by kernel specially,
135 + that may be used by applications, though not recommended.
136 +
137 + F.e. qdisc handles always have minor number equal to zero,
138 + classes (or flows) have major equal to parent qdisc major, and
139 + minor uniquely identifying class inside qdisc.
140 +
141 + Macros to manipulate handles:
142 + */
143 +
144 +#define TC_H_MAJ_MASK (0xFFFF0000U)
145 +#define TC_H_MIN_MASK (0x0000FFFFU)
146 +#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
147 +#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
148 +#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
149 +
150 +#define TC_H_UNSPEC (0U)
151 +#define TC_H_ROOT (0xFFFFFFFFU)
152 +#define TC_H_INGRESS (0xFFFFFFF1U)
153 +
154 +struct tc_ratespec
155 +{
156 + unsigned char cell_log;
157 + unsigned char __reserved;
158 + unsigned short feature;
159 + short addend;
160 + unsigned short mpu;
161 + __u32 rate;
162 +};
163 +
164 +/* FIFO section */
165 +
166 +struct tc_fifo_qopt
167 +{
168 + __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
169 +};
170 +
171 +/* PRIO section */
172 +
173 +#define TCQ_PRIO_BANDS 16
174 +
175 +struct tc_prio_qopt
176 +{
177 + int bands; /* Number of bands */
178 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
179 +};
180 +
181 +/* CSZ section */
182 +
183 +struct tc_csz_qopt
184 +{
185 + int flows; /* Maximal number of guaranteed flows */
186 + unsigned char R_log; /* Fixed point position for round number */
187 + unsigned char delta_log; /* Log of maximal managed time interval */
188 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> CSZ band */
189 +};
190 +
191 +struct tc_csz_copt
192 +{
193 + struct tc_ratespec slice;
194 + struct tc_ratespec rate;
195 + struct tc_ratespec peakrate;
196 + __u32 limit;
197 + __u32 buffer;
198 + __u32 mtu;
199 +};
200 +
201 +enum
202 +{
203 + TCA_CSZ_UNSPEC,
204 + TCA_CSZ_PARMS,
205 + TCA_CSZ_RTAB,
206 + TCA_CSZ_PTAB,
207 +};
208 +
209 +/* TBF section */
210 +
211 +struct tc_tbf_qopt
212 +{
213 + struct tc_ratespec rate;
214 + struct tc_ratespec peakrate;
215 + __u32 limit;
216 + __u32 buffer;
217 + __u32 mtu;
218 +};
219 +
220 +enum
221 +{
222 + TCA_TBF_UNSPEC,
223 + TCA_TBF_PARMS,
224 + TCA_TBF_RTAB,
225 + TCA_TBF_PTAB,
226 +};
227 +
228 +
229 +/* TEQL section */
230 +
231 +/* TEQL does not require any parameters */
232 +
233 +/* SFQ section */
234 +
235 +struct tc_sfq_qopt
236 +{
237 + unsigned quantum; /* Bytes per round allocated to flow */
238 + int perturb_period; /* Period of hash perturbation */
239 + __u32 limit; /* Maximal packets in queue */
240 + unsigned divisor; /* Hash divisor */
241 + unsigned flows; /* Maximal number of flows */
242 +};
243 +
244 +/*
245 + * NOTE: limit, divisor and flows are hardwired to code at the moment.
246 + *
247 + * limit=flows=128, divisor=1024;
248 + *
249 + * The only reason for this is efficiency, it is possible
250 + * to change these parameters in compile time.
251 + */
252 +
253 +/* RED section */
254 +
255 +enum
256 +{
257 + TCA_RED_UNSPEC,
258 + TCA_RED_PARMS,
259 + TCA_RED_STAB,
260 +};
261 +
262 +struct tc_red_qopt
263 +{
264 + __u32 limit; /* HARD maximal queue length (bytes) */
265 + __u32 qth_min; /* Min average length threshold (bytes) */
266 + __u32 qth_max; /* Max average length threshold (bytes) */
267 + unsigned char Wlog; /* log(W) */
268 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
269 + unsigned char Scell_log; /* cell size for idle damping */
270 + unsigned char flags;
271 +#define TC_RED_ECN 1
272 +};
273 +
274 +struct tc_red_xstats
275 +{
276 + __u32 early; /* Early drops */
277 + __u32 pdrop; /* Drops due to queue limits */
278 + __u32 other; /* Drops due to drop() calls */
279 + __u32 marked; /* Marked packets */
280 +};
281 +
282 +/* GRED section */
283 +
284 +#define MAX_DPs 16
285 +
286 +enum
287 +{
288 + TCA_GRED_UNSPEC,
289 + TCA_GRED_PARMS,
290 + TCA_GRED_STAB,
291 + TCA_GRED_DPS,
292 +};
293 +
294 +#define TCA_SET_OFF TCA_GRED_PARMS
295 +struct tc_gred_qopt
296 +{
297 + __u32 limit; /* HARD maximal queue length (bytes)
298 +*/
299 + __u32 qth_min; /* Min average length threshold (bytes)
300 +*/
301 + __u32 qth_max; /* Max average length threshold (bytes)
302 +*/
303 + __u32 DP; /* upto 2^32 DPs */
304 + __u32 backlog;
305 + __u32 qave;
306 + __u32 forced;
307 + __u32 early;
308 + __u32 other;
309 + __u32 pdrop;
310 +
311 + unsigned char Wlog; /* log(W) */
312 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
313 + unsigned char Scell_log; /* cell size for idle damping */
314 + __u8 prio; /* prio of this VQ */
315 + __u32 packets;
316 + __u32 bytesin;
317 +};
318 +/* gred setup */
319 +struct tc_gred_sopt
320 +{
321 + __u32 DPs;
322 + __u32 def_DP;
323 + __u8 grio;
324 +};
325 +
326 +/* HTB section */
327 +#define TC_HTB_NUMPRIO 8
328 +#define TC_HTB_MAXDEPTH 8
329 +#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */
330 +
331 +struct tc_htb_opt
332 +{
333 + struct tc_ratespec rate;
334 + struct tc_ratespec ceil;
335 + __u32 buffer;
336 + __u32 cbuffer;
337 + __u32 quantum;
338 + __u32 level; /* out only */
339 + __u32 prio;
340 +};
341 +struct tc_htb_glob
342 +{
343 + __u32 version; /* to match HTB/TC */
344 + __u32 rate2quantum; /* bps->quantum divisor */
345 + __u32 defcls; /* default class number */
346 + __u32 debug; /* debug flags */
347 +
348 + /* stats */
349 + __u32 direct_pkts; /* count of non shapped packets */
350 +};
351 +enum
352 +{
353 + TCA_HTB_UNSPEC,
354 + TCA_HTB_PARMS,
355 + TCA_HTB_INIT,
356 + TCA_HTB_CTAB,
357 + TCA_HTB_RTAB,
358 +};
359 +struct tc_htb_xstats
360 +{
361 + __u32 lends;
362 + __u32 borrows;
363 + __u32 giants; /* too big packets (rate will not be accurate) */
364 + __u32 tokens;
365 + __u32 ctokens;
366 +};
367 +
368 +/* CBQ section */
369 +
370 +#define TC_CBQ_MAXPRIO 8
371 +#define TC_CBQ_MAXLEVEL 8
372 +#define TC_CBQ_DEF_EWMA 5
373 +
374 +struct tc_cbq_lssopt
375 +{
376 + unsigned char change;
377 + unsigned char flags;
378 +#define TCF_CBQ_LSS_BOUNDED 1
379 +#define TCF_CBQ_LSS_ISOLATED 2
380 + unsigned char ewma_log;
381 + unsigned char level;
382 +#define TCF_CBQ_LSS_FLAGS 1
383 +#define TCF_CBQ_LSS_EWMA 2
384 +#define TCF_CBQ_LSS_MAXIDLE 4
385 +#define TCF_CBQ_LSS_MINIDLE 8
386 +#define TCF_CBQ_LSS_OFFTIME 0x10
387 +#define TCF_CBQ_LSS_AVPKT 0x20
388 + __u32 maxidle;
389 + __u32 minidle;
390 + __u32 offtime;
391 + __u32 avpkt;
392 +};
393 +
394 +struct tc_cbq_wrropt
395 +{
396 + unsigned char flags;
397 + unsigned char priority;
398 + unsigned char cpriority;
399 + unsigned char __reserved;
400 + __u32 allot;
401 + __u32 weight;
402 +};
403 +
404 +struct tc_cbq_ovl
405 +{
406 + unsigned char strategy;
407 +#define TC_CBQ_OVL_CLASSIC 0
408 +#define TC_CBQ_OVL_DELAY 1
409 +#define TC_CBQ_OVL_LOWPRIO 2
410 +#define TC_CBQ_OVL_DROP 3
411 +#define TC_CBQ_OVL_RCLASSIC 4
412 + unsigned char priority2;
413 + __u32 penalty;
414 +};
415 +
416 +struct tc_cbq_police
417 +{
418 + unsigned char police;
419 + unsigned char __res1;
420 + unsigned short __res2;
421 +};
422 +
423 +struct tc_cbq_fopt
424 +{
425 + __u32 split;
426 + __u32 defmap;
427 + __u32 defchange;
428 +};
429 +
430 +struct tc_cbq_xstats
431 +{
432 + __u32 borrows;
433 + __u32 overactions;
434 + __s32 avgidle;
435 + __s32 undertime;
436 +};
437 +
438 +enum
439 +{
440 + TCA_CBQ_UNSPEC,
441 + TCA_CBQ_LSSOPT,
442 + TCA_CBQ_WRROPT,
443 + TCA_CBQ_FOPT,
444 + TCA_CBQ_OVL_STRATEGY,
445 + TCA_CBQ_RATE,
446 + TCA_CBQ_RTAB,
447 + TCA_CBQ_POLICE,
448 +};
449 +
450 +#define TCA_CBQ_MAX TCA_CBQ_POLICE
451 +
452 +/* dsmark section */
453 +
454 +enum {
455 + TCA_DSMARK_UNSPEC,
456 + TCA_DSMARK_INDICES,
457 + TCA_DSMARK_DEFAULT_INDEX,
458 + TCA_DSMARK_SET_TC_INDEX,
459 + TCA_DSMARK_MASK,
460 + TCA_DSMARK_VALUE
461 +};
462 +
463 +#define TCA_DSMARK_MAX TCA_DSMARK_VALUE
464 +
465 +/* ATM section */
466 +
467 +enum {
468 + TCA_ATM_UNSPEC,
469 + TCA_ATM_FD, /* file/socket descriptor */
470 + TCA_ATM_PTR, /* pointer to descriptor - later */
471 + TCA_ATM_HDR, /* LL header */
472 + TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
473 + TCA_ATM_ADDR, /* PVC address (for output only) */
474 + TCA_ATM_STATE /* VC state (ATM_VS_*; for output only) */
475 +};
476 +
477 +#define TCA_ATM_MAX TCA_ATM_STATE
478 +
479 +#endif
480 +#endif
481 #ifndef __LINUX_PKT_SCHED_H
482 #define __LINUX_PKT_SCHED_H
483
484 @@ -482,4 +888,116 @@ struct tc_netem_corrupt
485
486 #define NETEM_DIST_SCALE 8192
487
488 +/* WRR section */
489 +
490 +/* Other includes */
491 +#include <linux/if_ether.h>
492 +
493 +// A sub weight and of a class
494 +// All numbers are represented as parts of (2^64-1).
495 +struct tc_wrr_class_weight {
496 + __u64 val; // Current value (0 is not valid)
497 + __u64 decr; // Value pr bytes (2^64-1 is not valid)
498 + __u64 incr; // Value pr seconds (2^64-1 is not valid)
499 + __u64 min; // Minimal value (0 is not valid)
500 + __u64 max; // Minimal value (0 is not valid)
501 +
502 +// The time where the above information was correct:
503 + time_t tim;
504 +};
505 +
506 +// Packet send when modifying a class:
507 +struct tc_wrr_class_modf {
508 + // Not-valid values are ignored.
509 + struct tc_wrr_class_weight weight1;
510 + struct tc_wrr_class_weight weight2;
511 +};
512 +
513 +// Packet returned when quering a class:
514 +struct tc_wrr_class_stats {
515 + char used; // If this is false the information below is invalid
516 +
517 + struct tc_wrr_class_modf class_modf;
518 +
519 + unsigned char addr[ETH_ALEN];
520 + char usemac; // True if addr is a MAC address, else it is an IP address
521 + // (this value is only for convience, it is always the same
522 + // value as in the qdisc)
523 + int heappos; // Current heap position or 0 if not in heap
524 + __u64 penal_ls; // Penalty value in heap (ls)
525 + __u64 penal_ms; // Penalty value in heap (ms)
526 +};
527 +
528 +// Qdisc-wide penalty information (boolean values - 2 not valid)
529 +struct tc_wrr_qdisc_weight {
530 + char weight_mode; // 0=No automatic change to weight
531 + // 1=Decrease normally
532 + // 2=Also multiply with number of machines
533 + // 3=Instead multiply with priority divided
534 + // with priority of the other.
535 + // -1=no change
536 +};
537 +
538 +// Packet send when modifing a qdisc:
539 +struct tc_wrr_qdisc_modf {
540 + // Not-valid values are ignored:
541 + struct tc_wrr_qdisc_weight weight1;
542 + struct tc_wrr_qdisc_weight weight2;
543 +};
544 +
545 +// Packet send when creating a qdisc:
546 +struct tc_wrr_qdisc_crt {
547 + struct tc_wrr_qdisc_modf qdisc_modf;
548 +
549 + char srcaddr; // 1=lookup source, 0=lookup destination
550 + char usemac; // 1=Classify on MAC addresses, 0=classify on IP
551 + char usemasq; // 1=Classify based on masqgrading - only valid
552 + // if usemac is zero
553 + int bands_max; // Maximal number of bands (i.e.: classes)
554 + int proxy_maxconn;// If differnt from 0 then we support proxy remapping
555 + // of packets. And this is the number of maximal
556 + // concurrent proxy connections.
557 +};
558 +
559 +// Packet returned when quering a qdisc:
560 +struct tc_wrr_qdisc_stats {
561 + struct tc_wrr_qdisc_crt qdisc_crt;
562 + int proxy_curconn;
563 + int nodes_in_heap; // Current number of bands wanting to send something
564 + int bands_cur; // Current number of bands used (i.e.: MAC/IP addresses seen)
565 + int bands_reused; // Number of times this band has been reused.
566 + int packets_requed; // Number of times packets have been requeued.
567 + __u64 priosum; // Sum of priorities in heap where 1 is 2^32
568 +};
569 +
570 +struct tc_wrr_qdisc_modf_std {
571 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
572 + char proxy; // 0=This struct
573 +
574 + // Should we also change a class?
575 + char change_class;
576 +
577 + // Only valid if change_class is false
578 + struct tc_wrr_qdisc_modf qdisc_modf;
579 +
580 + // Only valid if change_class is true:
581 + unsigned char addr[ETH_ALEN]; // Class to change (non-used bytes should be 0)
582 + struct tc_wrr_class_modf class_modf; // The change
583 +};
584 +
585 +// Used for proxyrempping:
586 +struct tc_wrr_qdisc_modf_proxy {
587 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
588 + char proxy; // 1=This struct
589 +
590 + // This is 1 if the proxyremap information should be reset
591 + char reset;
592 +
593 + // changec is the number of elements in changes.
594 + int changec;
595 +
596 + // This is an array of type ProxyRemapBlock:
597 + long changes[0];
598 +};
599 +
600 #endif
601 Index: iproute2-2.6.25/ip/iproute.c
602 ===================================================================
603 --- iproute2-2.6.25.orig/ip/iproute.c 2008-05-01 00:17:55.000000000 +0100
604 +++ iproute2-2.6.25/ip/iproute.c 2008-05-01 00:28:02.000000000 +0100
605 @@ -73,7 +73,7 @@ static void usage(void)
606 fprintf(stderr, " [ rtt TIME ] [ rttvar TIME ]\n");
607 fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n");
608 fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n");
609 - fprintf(stderr, " [ rto_min TIME ]\n");
610 + fprintf(stderr, " [ rto_min TIME ] [ hoplimit NUMBER ]\n");
611 fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
612 fprintf(stderr, " unreachable | prohibit | blackhole | nat ]\n");
613 fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
614 @@ -780,6 +780,30 @@ int iproute_modify(int cmd, unsigned fla
615 invarg("\"reordering\" value is invalid\n", *argv);
616 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_REORDERING, reord);
617 #endif
618 +#ifdef RTAX_HOPLIMIT
619 + } else if (strcmp(*argv, "hoplimit") == 0) {
620 + unsigned hoplim;
621 + NEXT_ARG();
622 + if (strcmp(*argv, "lock") == 0) {
623 + mxlock |= (1<<RTAX_HOPLIMIT);
624 + NEXT_ARG();
625 + }
626 + if (get_unsigned(&hoplim, *argv, 0))
627 + invarg("\"hoplimit\" value is invalid\n", *argv);
628 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplim);
629 +#endif
630 +#ifdef RTAX_INITCWND
631 + } else if (strcmp(*argv, "initcwnd") == 0) {
632 + unsigned initcwnd;
633 + NEXT_ARG();
634 + if (strcmp(*argv, "lock") == 0) {
635 + mxlock |= (1<<RTAX_HOPLIMIT);
636 + NEXT_ARG();
637 + }
638 + if (get_unsigned(&initcwnd, *argv, 0))
639 + invarg("\"initcwnd\" value is invalid\n", *argv);
640 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITCWND, initcwnd);
641 +#endif
642 } else if (strcmp(*argv, "rtt") == 0) {
643 unsigned rtt;
644 NEXT_ARG();
645 Index: iproute2-2.6.25/ip/iptunnel.c
646 ===================================================================
647 --- iproute2-2.6.25.orig/ip/iptunnel.c 2008-05-01 00:17:55.000000000 +0100
648 +++ iproute2-2.6.25/ip/iptunnel.c 2008-05-01 00:26:48.000000000 +0100
649 @@ -134,7 +134,7 @@ static int parse_args(int argc, char **a
650 NEXT_ARG();
651 p->o_flags |= GRE_KEY;
652 if (strchr(*argv, '.'))
653 - p->o_key = get_addr32(*argv);
654 + p->i_key = get_addr32(*argv);
655 else {
656 if (get_unsigned(&uval, *argv, 0)<0) {
657 fprintf(stderr, "invalid value of \"okey\"\n");
658 Index: iproute2-2.6.25/Makefile
659 ===================================================================
660 --- iproute2-2.6.25.orig/Makefile 2008-05-01 00:17:55.000000000 +0100
661 +++ iproute2-2.6.25/Makefile 2008-05-01 00:26:48.000000000 +0100
662 @@ -48,7 +48,7 @@ install: all
663 $(DESTDIR)$(DOCDIR)/examples
664 install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
665 $(DESTDIR)$(DOCDIR)/examples/diffserv
666 - @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
667 + @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
668 install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
669 install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
670 install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
671 @@ -65,7 +65,7 @@ snapshot:
672
673 clean:
674 rm -f cscope.*
675 - @for i in $(SUBDIRS) doc; \
676 + @set -e; for i in $(SUBDIRS) doc; \
677 do $(MAKE) $(MFLAGS) -C $$i clean; done
678
679 clobber: clean
680 Index: iproute2-2.6.25/misc/Makefile
681 ===================================================================
682 --- iproute2-2.6.25.orig/misc/Makefile 2008-05-01 00:17:55.000000000 +0100
683 +++ iproute2-2.6.25/misc/Makefile 2008-05-01 00:26:48.000000000 +0100
684 @@ -1,7 +1,8 @@
685 SSOBJ=ss.o ssfilter.o
686 LNSTATOBJ=lnstat.o lnstat_util.o
687
688 -TARGETS=ss nstat ifstat rtacct arpd lnstat
689 +#TARGETS=ss nstat ifstat rtacct arpd lnstat
690 +TARGETS=ss nstat rtacct lnstat
691
692 include ../Config
693
694 Index: iproute2-2.6.25/tc/Makefile
695 ===================================================================
696 --- iproute2-2.6.25.orig/tc/Makefile 2008-05-01 00:17:55.000000000 +0100
697 +++ iproute2-2.6.25/tc/Makefile 2008-05-01 00:30:13.000000000 +0100
698 @@ -13,6 +13,7 @@ TCMODULES += q_tbf.o
699 TCMODULES += q_cbq.o
700 TCMODULES += q_rr.o
701 TCMODULES += q_netem.o
702 +TCMODULES += q_wrr.o
703 TCMODULES += f_rsvp.o
704 TCMODULES += f_u32.o
705 TCMODULES += f_route.o
706 Index: iproute2-2.6.25/tc/q_htb.c
707 ===================================================================
708 --- iproute2-2.6.25.orig/tc/q_htb.c 2008-05-01 00:17:55.000000000 +0100
709 +++ iproute2-2.6.25/tc/q_htb.c 2008-05-01 00:37:50.000000000 +0100
710 @@ -1,3 +1,311 @@
711 +#if 0
712 +/*
713 + * q_htb.c HTB.
714 + *
715 + * This program is free software; you can redistribute it and/or
716 + * modify it under the terms of the GNU General Public License
717 + * as published by the Free Software Foundation; either version
718 + * 2 of the License, or (at your option) any later version.
719 + *
720 + * Authors: Martin Devera, devik@cdi.cz
721 + *
722 + */
723 +
724 +#include <stdio.h>
725 +#include <stdlib.h>
726 +#include <unistd.h>
727 +#include <syslog.h>
728 +#include <fcntl.h>
729 +#include <sys/socket.h>
730 +#include <netinet/in.h>
731 +#include <arpa/inet.h>
732 +#include <string.h>
733 +
734 +#include "utils.h"
735 +#include "tc_util.h"
736 +
737 +#define HTB_TC_VER 0x30003
738 +#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
739 +#error "Different kernel and TC HTB versions"
740 +#endif
741 +
742 +static void explain(void)
743 +{
744 + fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
745 + " default minor id of class to which unclassified packets are sent {0}\n"
746 + " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
747 + " debug string of 16 numbers each 0-3 {0}\n\n"
748 + "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
749 + " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
750 + " rate rate allocated to this class (class can still borrow)\n"
751 + " burst max bytes burst which can be accumulated during idle period {computed}\n"
752 + " ceil definite upper class rate (no borrows) {rate}\n"
753 + " cburst burst but for ceil {computed}\n"
754 + " mtu max packet size we create rate map for {1600}\n"
755 + " prio priority of leaf; lower are served first {0}\n"
756 + " quantum how much bytes to serve from leaf at once {use r2q}\n"
757 + "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
758 + );
759 +}
760 +
761 +static void explain1(char *arg)
762 +{
763 + fprintf(stderr, "Illegal \"%s\"\n", arg);
764 + explain();
765 +}
766 +
767 +
768 +#define usage() return(-1)
769 +
770 +static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
771 +{
772 + struct tc_htb_glob opt;
773 + struct rtattr *tail;
774 + unsigned i; char *p;
775 + memset(&opt,0,sizeof(opt));
776 + opt.rate2quantum = 10;
777 + opt.version = 3;
778 +
779 + while (argc > 0) {
780 + if (matches(*argv, "r2q") == 0) {
781 + NEXT_ARG();
782 + if (get_u32(&opt.rate2quantum, *argv, 10)) {
783 + explain1("r2q"); return -1;
784 + }
785 + } else if (matches(*argv, "default") == 0) {
786 + NEXT_ARG();
787 + if (get_u32(&opt.defcls, *argv, 16)) {
788 + explain1("default"); return -1;
789 + }
790 + } else if (matches(*argv, "debug") == 0) {
791 + NEXT_ARG(); p = *argv;
792 + for (i=0; i<16; i++,p++) {
793 + if (*p<'0' || *p>'3') break;
794 + opt.debug |= (*p-'0')<<(2*i);
795 + }
796 + } else {
797 + fprintf(stderr, "What is \"%s\"?\n", *argv);
798 + explain();
799 + return -1;
800 + }
801 + argc--; argv++;
802 + }
803 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
804 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
805 + addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
806 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
807 + return 0;
808 +}
809 +
810 +static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
811 +{
812 + int ok=0;
813 + struct tc_htb_opt opt;
814 + __u32 rtab[256],ctab[256];
815 + unsigned buffer=0,cbuffer=0;
816 + int cell_log=-1,ccell_log = -1,mtu;
817 + struct rtattr *tail;
818 +
819 + memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
820 +
821 + while (argc > 0) {
822 + if (matches(*argv, "prio") == 0) {
823 + NEXT_ARG();
824 + if (get_u32(&opt.prio, *argv, 10)) {
825 + explain1("prio"); return -1;
826 + }
827 + ok++;
828 + } else if (matches(*argv, "mtu") == 0) {
829 + NEXT_ARG();
830 + if (get_u32(&mtu, *argv, 10)) {
831 + explain1("mtu"); return -1;
832 + }
833 + } else if (matches(*argv, "quantum") == 0) {
834 + NEXT_ARG();
835 + if (get_u32(&opt.quantum, *argv, 10)) {
836 + explain1("quantum"); return -1;
837 + }
838 + } else if (matches(*argv, "burst") == 0 ||
839 + strcmp(*argv, "buffer") == 0 ||
840 + strcmp(*argv, "maxburst") == 0) {
841 + NEXT_ARG();
842 + if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
843 + explain1("buffer");
844 + return -1;
845 + }
846 + ok++;
847 + } else if (matches(*argv, "cburst") == 0 ||
848 + strcmp(*argv, "cbuffer") == 0 ||
849 + strcmp(*argv, "cmaxburst") == 0) {
850 + NEXT_ARG();
851 + if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
852 + explain1("cbuffer");
853 + return -1;
854 + }
855 + ok++;
856 + } else if (strcmp(*argv, "ceil") == 0) {
857 + NEXT_ARG();
858 + if (opt.ceil.rate) {
859 + fprintf(stderr, "Double \"ceil\" spec\n");
860 + return -1;
861 + }
862 + if (get_rate(&opt.ceil.rate, *argv)) {
863 + explain1("ceil");
864 + return -1;
865 + }
866 + ok++;
867 + } else if (strcmp(*argv, "rate") == 0) {
868 + NEXT_ARG();
869 + if (opt.rate.rate) {
870 + fprintf(stderr, "Double \"rate\" spec\n");
871 + return -1;
872 + }
873 + if (get_rate(&opt.rate.rate, *argv)) {
874 + explain1("rate");
875 + return -1;
876 + }
877 + ok++;
878 + } else if (strcmp(*argv, "help") == 0) {
879 + explain();
880 + return -1;
881 + } else {
882 + fprintf(stderr, "What is \"%s\"?\n", *argv);
883 + explain();
884 + return -1;
885 + }
886 + argc--; argv++;
887 + }
888 +
889 +/* if (!ok)
890 + return 0;*/
891 +
892 + if (opt.rate.rate == 0) {
893 + fprintf(stderr, "\"rate\" is required.\n");
894 + return -1;
895 + }
896 + /* if ceil params are missing, use the same as rate */
897 + if (!opt.ceil.rate) opt.ceil = opt.rate;
898 +
899 + /* compute minimal allowed burst from rate; mtu is added here to make
900 + sute that buffer is larger than mtu and to have some safeguard space */
901 + if (!buffer) buffer = opt.rate.rate / HZ + mtu;
902 + if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
903 +
904 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
905 + fprintf(stderr, "htb: failed to calculate rate table.\n");
906 + return -1;
907 + }
908 + opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
909 + opt.rate.cell_log = cell_log;
910 +
911 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
912 + fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
913 + return -1;
914 + }
915 + opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
916 + opt.ceil.cell_log = ccell_log;
917 +
918 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
919 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
920 + addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
921 + addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
922 + addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
923 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
924 + return 0;
925 +}
926 +
927 +static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
928 +{
929 + struct rtattr *tb[TCA_HTB_RTAB+1];
930 + struct tc_htb_opt *hopt;
931 + struct tc_htb_glob *gopt;
932 + double buffer,cbuffer;
933 + SPRINT_BUF(b1);
934 + SPRINT_BUF(b2);
935 +
936 + if (opt == NULL)
937 + return 0;
938 +
939 + memset(tb, 0, sizeof(tb));
940 + parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
941 +
942 + if (tb[TCA_HTB_PARMS]) {
943 +
944 + hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
945 + if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
946 +
947 + if (!hopt->level) {
948 + fprintf(f, "prio %d ", (int)hopt->prio);
949 + if (show_details)
950 + fprintf(f, "quantum %d ", (int)hopt->quantum);
951 + }
952 + fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
953 + buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
954 + fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
955 + cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
956 + if (show_details) {
957 + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
958 + 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
959 + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
960 + 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
961 + fprintf(f, "level %d ", (int)hopt->level);
962 + } else {
963 + fprintf(f, "burst %s ", sprint_size(buffer, b1));
964 + fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
965 + }
966 + if (show_raw)
967 + fprintf(f, "buffer [%08x] cbuffer [%08x] ",
968 + hopt->buffer,hopt->cbuffer);
969 + }
970 + if (tb[TCA_HTB_INIT]) {
971 + gopt = RTA_DATA(tb[TCA_HTB_INIT]);
972 + if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
973 +
974 + fprintf(f, "r2q %d default %x direct_packets_stat %u",
975 + gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
976 + if (show_details)
977 + fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
978 + }
979 + return 0;
980 +}
981 +
982 +static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
983 +{
984 + struct tc_htb_xstats *st;
985 + if (xstats == NULL)
986 + return 0;
987 +
988 + if (RTA_PAYLOAD(xstats) < sizeof(*st))
989 + return -1;
990 +
991 + st = RTA_DATA(xstats);
992 + fprintf(f, " lended: %u borrowed: %u giants: %u\n",
993 + st->lends,st->borrows,st->giants);
994 + fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
995 + return 0;
996 +}
997 +
998 +struct qdisc_util htb_util = {
999 + NULL,
1000 + "htb",
1001 + htb_parse_opt,
1002 + htb_print_opt,
1003 + htb_print_xstats,
1004 + htb_parse_class_opt,
1005 + htb_print_opt,
1006 +};
1007 +
1008 +/* for testing of old one */
1009 +struct qdisc_util htb2_util = {
1010 + NULL,
1011 + "htb2",
1012 + htb_parse_opt,
1013 + htb_print_opt,
1014 + htb_print_xstats,
1015 + htb_parse_class_opt,
1016 + htb_print_opt,
1017 +};
1018 +#endif
1019 /*
1020 * q_htb.c HTB.
1021 *
1022 Index: iproute2-2.6.25/tc/q_wrr.c
1023 ===================================================================
1024 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1025 +++ iproute2-2.6.25/tc/q_wrr.c 2008-05-01 00:37:17.000000000 +0100
1026 @@ -0,0 +1,322 @@
1027 +#include <stdio.h>
1028 +#include <stdlib.h>
1029 +#include <unistd.h>
1030 +#include <syslog.h>
1031 +#include <fcntl.h>
1032 +#include <sys/socket.h>
1033 +#include <netinet/in.h>
1034 +#include <arpa/inet.h>
1035 +#include <string.h>
1036 +#include <math.h>
1037 +
1038 +#include "utils.h"
1039 +#include "tc_util.h"
1040 +
1041 +#define usage() return(-1)
1042 +
1043 +// Returns -1 on error
1044 +static int wrr_parse_qdisc_weight(int argc, char** argv,
1045 + struct tc_wrr_qdisc_modf* opt) {
1046 + int i;
1047 +
1048 + opt->weight1.weight_mode=-1;
1049 + opt->weight2.weight_mode=-1;
1050 +
1051 + for(i=0; i<argc; i++) {
1052 + if(!memcmp(argv[i],"wmode1=",7)) {
1053 + opt->weight1.weight_mode=atoi(argv[i]+7);
1054 + } else if(!memcmp(argv[i],"wmode2=",7)) {
1055 + opt->weight2.weight_mode=atoi(argv[i]+7);
1056 + } else {
1057 + printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
1058 + return -1;
1059 + }
1060 + }
1061 + return 0;
1062 +}
1063 +
1064 +static int wrr_parse_class_modf(int argc, char** argv,
1065 + struct tc_wrr_class_modf* modf) {
1066 + int i;
1067 +
1068 + if(argc<1) {
1069 + fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
1070 + fprintf(stderr, " The values can be floating point like 0.42 or divisions like 42/100\n");
1071 + return -1;
1072 + }
1073 +
1074 + // Set meaningless values:
1075 + modf->weight1.val=0;
1076 + modf->weight1.decr=(__u64)-1;
1077 + modf->weight1.incr=(__u64)-1;
1078 + modf->weight1.min=0;
1079 + modf->weight1.max=0;
1080 + modf->weight2.val=0;
1081 + modf->weight2.decr=(__u64)-1;
1082 + modf->weight2.incr=(__u64)-1;
1083 + modf->weight2.min=0;
1084 + modf->weight2.max=0;
1085 +
1086 + // And read values:
1087 + for(i=0; i<argc; i++) {
1088 + char arg[80];
1089 + char* name,*value1=0,*value2=0;
1090 + long double f_val1,f_val2=1,value;
1091 + if(strlen(argv[i])>=sizeof(arg)) {
1092 + fprintf(stderr,"Argument too long: %s\n",argv[i]);
1093 + return -1;
1094 + }
1095 + strcpy(arg,argv[i]);
1096 +
1097 + name=strtok(arg,"=");
1098 + if(name) value1=strtok(0,"/");
1099 + if(value1) value2=strtok(0,"");
1100 +
1101 + if(!value1) {
1102 + fprintf(stderr,"No = found in argument: %s\n",argv[i]);
1103 + return -1;
1104 + }
1105 +
1106 + f_val1=atof(value1);
1107 + if(value2) f_val2=atof(value2);
1108 +
1109 + if(f_val2==0) {
1110 + fprintf(stderr,"Division by 0\n");
1111 + return -1;
1112 + }
1113 +
1114 + value=f_val1/f_val2;
1115 + if(value>1) value=1;
1116 + if(value<0) value=0;
1117 + value*=((__u64)-1);
1118 +
1119 + // And find the value set
1120 + if(!strcmp(name,"weight1")) modf->weight1.val=value;
1121 + else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
1122 + else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
1123 + else if(!strcmp(name,"min1")) modf->weight1.min=value;
1124 + else if(!strcmp(name,"max1")) modf->weight1.max=value;
1125 + else if(!strcmp(name,"weight2")) modf->weight2.val=value;
1126 + else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
1127 + else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
1128 + else if(!strcmp(name,"min2")) modf->weight2.min=value;
1129 + else if(!strcmp(name,"max2")) modf->weight2.max=value;
1130 + else {
1131 + fprintf(stderr,"illegal value: %s\n",name);
1132 + return -1;
1133 + }
1134 + }
1135 +
1136 + return 0;
1137 +}
1138 +
1139 +static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
1140 +{
1141 + if(n->nlmsg_flags & NLM_F_CREATE) {
1142 + // This is a create request:
1143 + struct tc_wrr_qdisc_crt opt;
1144 +
1145 + int sour,dest,ip,mac,masq;
1146 +
1147 + if(argc<4) {
1148 + fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
1149 + return -1;
1150 + }
1151 +
1152 + // Read sour/dest:
1153 + memset(&opt,0,sizeof(opt));
1154 + sour=!strcmp(argv[0],"sour");
1155 + dest=!strcmp(argv[0],"dest");
1156 +
1157 + if(!sour && !dest) {
1158 + fprintf(stderr,"sour or dest must be specified\n");
1159 + return -1;
1160 + }
1161 +
1162 + // Read ip/mac
1163 + ip=!strcmp(argv[1],"ip");
1164 + mac=!strcmp(argv[1],"mac");
1165 + masq=!strcmp(argv[1],"masq");
1166 +
1167 + if(!ip && !mac && !masq) {
1168 + fprintf(stderr,"ip, masq or mac must be specified\n");
1169 + return -1;
1170 + }
1171 +
1172 + opt.srcaddr=sour;
1173 + opt.usemac=mac;
1174 + opt.usemasq=masq;
1175 + opt.bands_max=atoi(argv[2]);
1176 +
1177 + opt.proxy_maxconn=atoi(argv[3]);
1178 +
1179 + // Read weights:
1180 + if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
1181 + if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
1182 + if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
1183 +
1184 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1185 + } else {
1186 + struct tc_wrr_qdisc_modf_std opt;
1187 + char qdisc,class;
1188 +
1189 + // This is a modify request:
1190 + if(argc<1) {
1191 + fprintf(stderr,"... qdisc ... or ... class ...\n");
1192 + return -1;
1193 + }
1194 +
1195 + qdisc=!strcmp(argv[0],"qdisc");
1196 + class=!strcmp(argv[0],"class");
1197 +
1198 + if(!qdisc && !class) {
1199 + fprintf(stderr,"qdisc or class must be specified\n");
1200 + return -1;
1201 + }
1202 +
1203 + argc--;
1204 + argv++;
1205 +
1206 + opt.proxy=0;
1207 +
1208 + if(qdisc) {
1209 + opt.change_class=0;
1210 + if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
1211 + } else {
1212 + int a0,a1,a2,a3,a4=0,a5=0;
1213 +
1214 + opt.change_class=1;
1215 +
1216 + if(argc<1) {
1217 + fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
1218 + return -1;
1219 + }
1220 + memset(opt.addr,0,sizeof(opt.addr));
1221 +
1222 + if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
1223 + (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
1224 + fprintf(stderr,"Wrong format of mac or ip address\n");
1225 + return -1;
1226 + }
1227 +
1228 + opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
1229 + opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
1230 +
1231 + if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
1232 + }
1233 +
1234 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1235 + }
1236 + return 0;
1237 +}
1238 +
1239 +static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
1240 + struct tc_wrr_class_modf opt;
1241 +
1242 + memset(&opt,0,sizeof(opt));
1243 + if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
1244 +
1245 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1246 + return 0;
1247 +}
1248 +
1249 +static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1250 +{
1251 + struct tc_wrr_qdisc_stats *qopt;
1252 +
1253 + if (opt == NULL)
1254 + return 0;
1255 +
1256 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
1257 + return -1;
1258 + qopt = RTA_DATA(opt);
1259 +
1260 + fprintf(f,"\n (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
1261 + qopt->qdisc_crt.srcaddr ? "sour" : "dest",
1262 + qopt->qdisc_crt.usemac ? "mac" : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),
1263 + qopt->qdisc_crt.bands_max,
1264 + qopt->bands_cur,
1265 + qopt->bands_reused
1266 + );
1267 +
1268 + if(qopt->qdisc_crt.proxy_maxconn) {
1269 + fprintf(f," (proxy maxcon %i) (proxy curcon %i)\n",
1270 + qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
1271 + }
1272 +
1273 + fprintf(f," (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
1274 + qopt->nodes_in_heap,
1275 + qopt->packets_requed,
1276 + qopt->priosum/((long double)((__u32)-1))
1277 + );
1278 +
1279 + fprintf(f," (wmode1 %i) (wmode2 %i) \n",
1280 + qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
1281 + qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
1282 +
1283 + return 0;
1284 +}
1285 +
1286 +static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
1287 + struct tc_wrr_class_stats *copt;
1288 + long double d=(__u64)-1;
1289 +
1290 + if (opt == NULL) return 0;
1291 +
1292 + if (RTA_PAYLOAD(opt) < sizeof(*copt))
1293 + return -1;
1294 + copt = RTA_DATA(opt);
1295 +
1296 + if(!copt->used) {
1297 + fprintf(f,"(unused)");
1298 + return 0;
1299 + }
1300 +
1301 + if(copt->usemac) {
1302 + fprintf(f,"\n (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
1303 + copt->addr[0],copt->addr[1],copt->addr[2],
1304 + copt->addr[3],copt->addr[4],copt->addr[5]);
1305 + } else {
1306 + fprintf(f,"\n (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
1307 + }
1308 +
1309 + fprintf(f," (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
1310 + (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
1311 + copt->heappos,
1312 + (unsigned)(copt->penal_ms>>32),
1313 + (unsigned)(copt->penal_ms & 0xffffffffU),
1314 + (unsigned)(copt->penal_ls>>32),
1315 + (unsigned)(copt->penal_ls & 0xffffffffU)
1316 + );
1317 +
1318 + fprintf(f," Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
1319 + copt->class_modf.weight1.val/d,
1320 + copt->class_modf.weight1.decr/d,
1321 + copt->class_modf.weight1.incr/d,
1322 + copt->class_modf.weight1.min/d,
1323 + copt->class_modf.weight1.max/d);
1324 +
1325 + fprintf(f," Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
1326 + copt->class_modf.weight2.val/d,
1327 + copt->class_modf.weight2.decr/d,
1328 + copt->class_modf.weight2.incr/d,
1329 + copt->class_modf.weight2.min/d,
1330 + copt->class_modf.weight2.max/d);
1331 +
1332 + return 0;
1333 +}
1334 +
1335 +static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1336 +{
1337 + return 0;
1338 +}
1339 +
1340 +
1341 +struct qdisc_util wrr_qdisc_util = {
1342 + .id = "wrr",
1343 + .parse_qopt = wrr_parse_opt,
1344 + .print_qopt = wrr_print_opt,
1345 + .print_xstats = wrr_print_xstats,
1346 + .parse_copt = wrr_parse_copt,
1347 + .print_copt = wrr_print_copt
1348 +};
This page took 0.113913 seconds and 5 git commands to generate.