refresh all package patches in the buildroot using quilt
[openwrt/openwrt.git] / package / iproute2 / patches / 000-debian_patches_3.patch
1 Index: iproute2-2.6.15-060110/doc/ip-cref.tex
2 ===================================================================
3 --- iproute2-2.6.15-060110.orig/doc/ip-cref.tex 2007-06-04 13:22:33.437771968 +0200
4 +++ iproute2-2.6.15-060110/doc/ip-cref.tex 2007-06-04 13:22:33.577750688 +0200
5 @@ -1322,6 +1322,19 @@
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 @@ -2651,6 +2664,9 @@
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.15-060110/doc/Makefile
36 ===================================================================
37 --- iproute2-2.6.15-060110.orig/doc/Makefile 2007-06-04 13:22:33.444770904 +0200
38 +++ iproute2-2.6.15-060110/doc/Makefile 2007-06-04 13:22:33.577750688 +0200
39 @@ -14,6 +14,7 @@
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 @@
48
49 html: $(HTMLFILES)
50
51 +txt: $(TXTFILES)
52 +
53 dvi: $(DVIFILES)
54
55 print: $(PSFILES)
56 @@ -47,9 +50,12 @@
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.15-060110/include/linux/pkt_sched.h
71 ===================================================================
72 --- iproute2-2.6.15-060110.orig/include/linux/pkt_sched.h 2007-06-04 13:22:33.451769840 +0200
73 +++ iproute2-2.6.15-060110/include/linux/pkt_sched.h 2007-06-04 13:22:33.578750536 +0200
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 @@ -466,4 +872,116 @@
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.15-060110/ip/iproute.c
602 ===================================================================
603 --- iproute2-2.6.15-060110.orig/ip/iproute.c 2007-06-04 13:22:33.456769080 +0200
604 +++ iproute2-2.6.15-060110/ip/iproute.c 2007-06-04 13:22:33.578750536 +0200
605 @@ -60,7 +60,7 @@
606 fprintf(stderr, "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ]\n");
607 fprintf(stderr, " [ rtt NUMBER ] [ rttvar NUMBER ]\n");
608 fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ ssthresh NUMBER ]\n");
609 - fprintf(stderr, " [ realms REALM ]\n");
610 + fprintf(stderr, " [ realms REALM ] [ hoplimit NUMBER ] [ initcwnd 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 @@ -497,6 +497,8 @@
615 "cwnd",
616 "advmss",
617 "reordering",
618 + "hoplimit",
619 + "initcwnd",
620 };
621 static int hz;
622 if (mxrta[i] == NULL)
623 @@ -764,6 +766,30 @@
624 invarg("\"reordering\" value is invalid\n", *argv);
625 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_REORDERING, reord);
626 #endif
627 +#ifdef RTAX_HOPLIMIT
628 + } else if (strcmp(*argv, "hoplimit") == 0) {
629 + unsigned hoplim;
630 + NEXT_ARG();
631 + if (strcmp(*argv, "lock") == 0) {
632 + mxlock |= (1<<RTAX_HOPLIMIT);
633 + NEXT_ARG();
634 + }
635 + if (get_unsigned(&hoplim, *argv, 0))
636 + invarg("\"hoplimit\" value is invalid\n", *argv);
637 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplim);
638 +#endif
639 +#ifdef RTAX_INITCWND
640 + } else if (strcmp(*argv, "initcwnd") == 0) {
641 + unsigned initcwnd;
642 + NEXT_ARG();
643 + if (strcmp(*argv, "lock") == 0) {
644 + mxlock |= (1<<RTAX_HOPLIMIT);
645 + NEXT_ARG();
646 + }
647 + if (get_unsigned(&initcwnd, *argv, 0))
648 + invarg("\"initcwnd\" value is invalid\n", *argv);
649 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITCWND, initcwnd);
650 +#endif
651 } else if (strcmp(*argv, "rtt") == 0) {
652 unsigned rtt;
653 NEXT_ARG();
654 Index: iproute2-2.6.15-060110/ip/iptunnel.c
655 ===================================================================
656 --- iproute2-2.6.15-060110.orig/ip/iptunnel.c 2007-06-04 13:22:33.463768016 +0200
657 +++ iproute2-2.6.15-060110/ip/iptunnel.c 2007-06-04 13:22:33.579750384 +0200
658 @@ -225,7 +225,7 @@
659 NEXT_ARG();
660 p->i_flags |= GRE_KEY;
661 if (strchr(*argv, '.'))
662 - p->o_key = get_addr32(*argv);
663 + p->i_key = get_addr32(*argv);
664 else {
665 if (get_unsigned(&uval, *argv, 0)<0) {
666 fprintf(stderr, "invalid value of \"ikey\"\n");
667 Index: iproute2-2.6.15-060110/Makefile
668 ===================================================================
669 --- iproute2-2.6.15-060110.orig/Makefile 2007-06-04 13:22:33.468767256 +0200
670 +++ iproute2-2.6.15-060110/Makefile 2007-06-04 13:22:33.579750384 +0200
671 @@ -32,7 +32,7 @@
672 LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
673
674 all: Config
675 - @for i in $(SUBDIRS); \
676 + @set -e; for i in $(SUBDIRS); \
677 do $(MAKE) $(MFLAGS) -C $$i; done
678
679 Config:
680 @@ -47,7 +47,7 @@
681 $(DESTDIR)$(DOCDIR)/examples
682 install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
683 $(DESTDIR)$(DOCDIR)/examples/diffserv
684 - @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
685 + @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
686 install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
687 install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
688 install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
689 @@ -58,7 +58,7 @@
690
691 clean:
692 rm -f cscope.*
693 - @for i in $(SUBDIRS) doc; \
694 + @set -e; for i in $(SUBDIRS) doc; \
695 do $(MAKE) $(MFLAGS) -C $$i clean; done
696
697 clobber: clean
698 Index: iproute2-2.6.15-060110/man/man8/ip.8
699 ===================================================================
700 --- iproute2-2.6.15-060110.orig/man/man8/ip.8 2007-06-04 13:22:33.473766496 +0200
701 +++ iproute2-2.6.15-060110/man/man8/ip.8 2007-06-04 13:22:33.580750232 +0200
702 @@ -1808,6 +1808,8 @@
703 .RB "IP Command reference " ip-cref.ps
704 .br
705 .RB "IP tunnels " ip-cref.ps
706 +.br
707 +.RB http://lartc.org/
708
709 .SH AUTHOR
710 Original Manpage by Michail Litvak <mci@owl.openwall.com>
711 Index: iproute2-2.6.15-060110/man/man8/tc.8
712 ===================================================================
713 --- iproute2-2.6.15-060110.orig/man/man8/tc.8 2007-06-04 13:22:33.481765280 +0200
714 +++ iproute2-2.6.15-060110/man/man8/tc.8 2007-06-04 13:22:33.580750232 +0200
715 @@ -341,7 +341,7 @@
716 .BR tc-pfifo (8),
717 .BR tc-bfifo (8),
718 .BR tc-pfifo_fast (8),
719 -.BR tc-filters (8)
720 +.BR http://lartc.org/
721
722 .SH AUTHOR
723 Manpage maintained by bert hubert (ahu@ds9a.nl)
724 Index: iproute2-2.6.15-060110/misc/Makefile
725 ===================================================================
726 --- iproute2-2.6.15-060110.orig/misc/Makefile 2007-06-04 13:22:33.486764520 +0200
727 +++ iproute2-2.6.15-060110/misc/Makefile 2007-06-04 13:22:33.580750232 +0200
728 @@ -1,7 +1,8 @@
729 SSOBJ=ss.o ssfilter.o
730 LNSTATOBJ=lnstat.o lnstat_util.o
731
732 -TARGETS=ss nstat ifstat rtacct arpd lnstat
733 +#TARGETS=ss nstat ifstat rtacct arpd lnstat
734 +TARGETS=ss nstat rtacct lnstat
735
736 include ../Config
737
738 Index: iproute2-2.6.15-060110/misc/netbug
739 ===================================================================
740 --- iproute2-2.6.15-060110.orig/misc/netbug 2007-06-04 13:22:33.492763608 +0200
741 +++ iproute2-2.6.15-060110/misc/netbug 2007-06-04 13:22:33.580750232 +0200
742 @@ -1,23 +1,16 @@
743 #! /bin/bash
744
745 +set -e
746 +
747 echo -n "Send network configuration summary to [ENTER means kuznet@ms2.inr.ac.ru] "
748 IFS="" read mail || exit 1
749 [ -z "$mail" ] && mail=kuznet@ms2.inr.ac.ru
750
751 +netbug=`mktemp -d -t netbug.XXXXXX` || {echo "$0: Cannot create temporary directory" >&2; exit 1; }
752 +netbugtar=`tempfile -d $netbug --suffix=tar.gz` || {echo "$0: Cannot create temporary file" >&2; exit 1; }
753 +tmppath=$netbug
754 +trap "/bin/rm -rf $netbug $netbugtar" 0 1 2 3 13 15
755
756 -netbug=""
757 -while [ "$netbug" = "" ]; do
758 - netbug=`echo netbug.$$.$RANDOM`
759 - if [ -e /tmp/$netbug ]; then
760 - netbug=""
761 - fi
762 -done
763 -
764 -tmppath=/tmp/$netbug
765 -
766 -trap "rm -rf $tmppath $tmppath.tar.gz" 0 SIGINT
767 -
768 -mkdir $tmppath
769 mkdir $tmppath/net
770
771 cat /proc/slabinfo > $tmppath/slabinfo
772 @@ -44,9 +37,8 @@
773 fi
774
775 cd /tmp
776 -tar c $netbug | gzip -9c > $netbug.tar.gz
777 -
778 -uuencode $netbug.tar.gz $netbug.tar.gz | mail -s $netbug "$mail"
779 +tar c $tmppath | gzip -9c > $netbugtar
780 +uuencode $netbugtar $netbugtar | mail -s $netbug "$mail"
781
782 echo "Sending to <$mail>; subject is $netbug"
783
784 Index: iproute2-2.6.15-060110/tc/Makefile
785 ===================================================================
786 --- iproute2-2.6.15-060110.orig/tc/Makefile 2007-06-04 13:22:33.498762696 +0200
787 +++ iproute2-2.6.15-060110/tc/Makefile 2007-06-04 13:22:33.581750080 +0200
788 @@ -11,6 +11,7 @@
789 TCMODULES += q_prio.o
790 TCMODULES += q_tbf.o
791 TCMODULES += q_cbq.o
792 +TCMODULES += q_wrr.o
793 TCMODULES += f_rsvp.o
794 TCMODULES += f_u32.o
795 TCMODULES += f_route.o
796 Index: iproute2-2.6.15-060110/tc/q_htb.c
797 ===================================================================
798 --- iproute2-2.6.15-060110.orig/tc/q_htb.c 2007-06-04 13:22:33.503761936 +0200
799 +++ iproute2-2.6.15-060110/tc/q_htb.c 2007-06-04 13:22:33.581750080 +0200
800 @@ -1,3 +1,311 @@
801 +#if 0
802 +/*
803 + * q_htb.c HTB.
804 + *
805 + * This program is free software; you can redistribute it and/or
806 + * modify it under the terms of the GNU General Public License
807 + * as published by the Free Software Foundation; either version
808 + * 2 of the License, or (at your option) any later version.
809 + *
810 + * Authors: Martin Devera, devik@cdi.cz
811 + *
812 + */
813 +
814 +#include <stdio.h>
815 +#include <stdlib.h>
816 +#include <unistd.h>
817 +#include <syslog.h>
818 +#include <fcntl.h>
819 +#include <sys/socket.h>
820 +#include <netinet/in.h>
821 +#include <arpa/inet.h>
822 +#include <string.h>
823 +
824 +#include "utils.h"
825 +#include "tc_util.h"
826 +
827 +#define HTB_TC_VER 0x30003
828 +#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
829 +#error "Different kernel and TC HTB versions"
830 +#endif
831 +
832 +static void explain(void)
833 +{
834 + fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
835 + " default minor id of class to which unclassified packets are sent {0}\n"
836 + " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
837 + " debug string of 16 numbers each 0-3 {0}\n\n"
838 + "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
839 + " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
840 + " rate rate allocated to this class (class can still borrow)\n"
841 + " burst max bytes burst which can be accumulated during idle period {computed}\n"
842 + " ceil definite upper class rate (no borrows) {rate}\n"
843 + " cburst burst but for ceil {computed}\n"
844 + " mtu max packet size we create rate map for {1600}\n"
845 + " prio priority of leaf; lower are served first {0}\n"
846 + " quantum how much bytes to serve from leaf at once {use r2q}\n"
847 + "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
848 + );
849 +}
850 +
851 +static void explain1(char *arg)
852 +{
853 + fprintf(stderr, "Illegal \"%s\"\n", arg);
854 + explain();
855 +}
856 +
857 +
858 +#define usage() return(-1)
859 +
860 +static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
861 +{
862 + struct tc_htb_glob opt;
863 + struct rtattr *tail;
864 + unsigned i; char *p;
865 + memset(&opt,0,sizeof(opt));
866 + opt.rate2quantum = 10;
867 + opt.version = 3;
868 +
869 + while (argc > 0) {
870 + if (matches(*argv, "r2q") == 0) {
871 + NEXT_ARG();
872 + if (get_u32(&opt.rate2quantum, *argv, 10)) {
873 + explain1("r2q"); return -1;
874 + }
875 + } else if (matches(*argv, "default") == 0) {
876 + NEXT_ARG();
877 + if (get_u32(&opt.defcls, *argv, 16)) {
878 + explain1("default"); return -1;
879 + }
880 + } else if (matches(*argv, "debug") == 0) {
881 + NEXT_ARG(); p = *argv;
882 + for (i=0; i<16; i++,p++) {
883 + if (*p<'0' || *p>'3') break;
884 + opt.debug |= (*p-'0')<<(2*i);
885 + }
886 + } else {
887 + fprintf(stderr, "What is \"%s\"?\n", *argv);
888 + explain();
889 + return -1;
890 + }
891 + argc--; argv++;
892 + }
893 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
894 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
895 + addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
896 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
897 + return 0;
898 +}
899 +
900 +static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
901 +{
902 + int ok=0;
903 + struct tc_htb_opt opt;
904 + __u32 rtab[256],ctab[256];
905 + unsigned buffer=0,cbuffer=0;
906 + int cell_log=-1,ccell_log = -1,mtu;
907 + struct rtattr *tail;
908 +
909 + memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
910 +
911 + while (argc > 0) {
912 + if (matches(*argv, "prio") == 0) {
913 + NEXT_ARG();
914 + if (get_u32(&opt.prio, *argv, 10)) {
915 + explain1("prio"); return -1;
916 + }
917 + ok++;
918 + } else if (matches(*argv, "mtu") == 0) {
919 + NEXT_ARG();
920 + if (get_u32(&mtu, *argv, 10)) {
921 + explain1("mtu"); return -1;
922 + }
923 + } else if (matches(*argv, "quantum") == 0) {
924 + NEXT_ARG();
925 + if (get_u32(&opt.quantum, *argv, 10)) {
926 + explain1("quantum"); return -1;
927 + }
928 + } else if (matches(*argv, "burst") == 0 ||
929 + strcmp(*argv, "buffer") == 0 ||
930 + strcmp(*argv, "maxburst") == 0) {
931 + NEXT_ARG();
932 + if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
933 + explain1("buffer");
934 + return -1;
935 + }
936 + ok++;
937 + } else if (matches(*argv, "cburst") == 0 ||
938 + strcmp(*argv, "cbuffer") == 0 ||
939 + strcmp(*argv, "cmaxburst") == 0) {
940 + NEXT_ARG();
941 + if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
942 + explain1("cbuffer");
943 + return -1;
944 + }
945 + ok++;
946 + } else if (strcmp(*argv, "ceil") == 0) {
947 + NEXT_ARG();
948 + if (opt.ceil.rate) {
949 + fprintf(stderr, "Double \"ceil\" spec\n");
950 + return -1;
951 + }
952 + if (get_rate(&opt.ceil.rate, *argv)) {
953 + explain1("ceil");
954 + return -1;
955 + }
956 + ok++;
957 + } else if (strcmp(*argv, "rate") == 0) {
958 + NEXT_ARG();
959 + if (opt.rate.rate) {
960 + fprintf(stderr, "Double \"rate\" spec\n");
961 + return -1;
962 + }
963 + if (get_rate(&opt.rate.rate, *argv)) {
964 + explain1("rate");
965 + return -1;
966 + }
967 + ok++;
968 + } else if (strcmp(*argv, "help") == 0) {
969 + explain();
970 + return -1;
971 + } else {
972 + fprintf(stderr, "What is \"%s\"?\n", *argv);
973 + explain();
974 + return -1;
975 + }
976 + argc--; argv++;
977 + }
978 +
979 +/* if (!ok)
980 + return 0;*/
981 +
982 + if (opt.rate.rate == 0) {
983 + fprintf(stderr, "\"rate\" is required.\n");
984 + return -1;
985 + }
986 + /* if ceil params are missing, use the same as rate */
987 + if (!opt.ceil.rate) opt.ceil = opt.rate;
988 +
989 + /* compute minimal allowed burst from rate; mtu is added here to make
990 + sute that buffer is larger than mtu and to have some safeguard space */
991 + if (!buffer) buffer = opt.rate.rate / HZ + mtu;
992 + if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
993 +
994 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
995 + fprintf(stderr, "htb: failed to calculate rate table.\n");
996 + return -1;
997 + }
998 + opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
999 + opt.rate.cell_log = cell_log;
1000 +
1001 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
1002 + fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
1003 + return -1;
1004 + }
1005 + opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
1006 + opt.ceil.cell_log = ccell_log;
1007 +
1008 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
1009 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
1010 + addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
1011 + addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
1012 + addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
1013 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
1014 + return 0;
1015 +}
1016 +
1017 +static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1018 +{
1019 + struct rtattr *tb[TCA_HTB_RTAB+1];
1020 + struct tc_htb_opt *hopt;
1021 + struct tc_htb_glob *gopt;
1022 + double buffer,cbuffer;
1023 + SPRINT_BUF(b1);
1024 + SPRINT_BUF(b2);
1025 +
1026 + if (opt == NULL)
1027 + return 0;
1028 +
1029 + memset(tb, 0, sizeof(tb));
1030 + parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
1031 +
1032 + if (tb[TCA_HTB_PARMS]) {
1033 +
1034 + hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
1035 + if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
1036 +
1037 + if (!hopt->level) {
1038 + fprintf(f, "prio %d ", (int)hopt->prio);
1039 + if (show_details)
1040 + fprintf(f, "quantum %d ", (int)hopt->quantum);
1041 + }
1042 + fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
1043 + buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
1044 + fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
1045 + cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
1046 + if (show_details) {
1047 + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
1048 + 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
1049 + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
1050 + 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
1051 + fprintf(f, "level %d ", (int)hopt->level);
1052 + } else {
1053 + fprintf(f, "burst %s ", sprint_size(buffer, b1));
1054 + fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
1055 + }
1056 + if (show_raw)
1057 + fprintf(f, "buffer [%08x] cbuffer [%08x] ",
1058 + hopt->buffer,hopt->cbuffer);
1059 + }
1060 + if (tb[TCA_HTB_INIT]) {
1061 + gopt = RTA_DATA(tb[TCA_HTB_INIT]);
1062 + if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
1063 +
1064 + fprintf(f, "r2q %d default %x direct_packets_stat %u",
1065 + gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
1066 + if (show_details)
1067 + fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
1068 + }
1069 + return 0;
1070 +}
1071 +
1072 +static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1073 +{
1074 + struct tc_htb_xstats *st;
1075 + if (xstats == NULL)
1076 + return 0;
1077 +
1078 + if (RTA_PAYLOAD(xstats) < sizeof(*st))
1079 + return -1;
1080 +
1081 + st = RTA_DATA(xstats);
1082 + fprintf(f, " lended: %u borrowed: %u giants: %u\n",
1083 + st->lends,st->borrows,st->giants);
1084 + fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
1085 + return 0;
1086 +}
1087 +
1088 +struct qdisc_util htb_util = {
1089 + NULL,
1090 + "htb",
1091 + htb_parse_opt,
1092 + htb_print_opt,
1093 + htb_print_xstats,
1094 + htb_parse_class_opt,
1095 + htb_print_opt,
1096 +};
1097 +
1098 +/* for testing of old one */
1099 +struct qdisc_util htb2_util = {
1100 + NULL,
1101 + "htb2",
1102 + htb_parse_opt,
1103 + htb_print_opt,
1104 + htb_print_xstats,
1105 + htb_parse_class_opt,
1106 + htb_print_opt,
1107 +};
1108 +#endif
1109 /*
1110 * q_htb.c HTB.
1111 *
1112 Index: iproute2-2.6.15-060110/tc/q_wrr.c
1113 ===================================================================
1114 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1115 +++ iproute2-2.6.15-060110/tc/q_wrr.c 2007-06-04 13:22:33.582749928 +0200
1116 @@ -0,0 +1,322 @@
1117 +#include <stdio.h>
1118 +#include <stdlib.h>
1119 +#include <unistd.h>
1120 +#include <syslog.h>
1121 +#include <fcntl.h>
1122 +#include <sys/socket.h>
1123 +#include <netinet/in.h>
1124 +#include <arpa/inet.h>
1125 +#include <string.h>
1126 +#include <math.h>
1127 +
1128 +#include "utils.h"
1129 +#include "tc_util.h"
1130 +
1131 +#define usage() return(-1)
1132 +
1133 +// Returns -1 on error
1134 +static int wrr_parse_qdisc_weight(int argc, char** argv,
1135 + struct tc_wrr_qdisc_modf* opt) {
1136 + int i;
1137 +
1138 + opt->weight1.weight_mode=-1;
1139 + opt->weight2.weight_mode=-1;
1140 +
1141 + for(i=0; i<argc; i++) {
1142 + if(!memcmp(argv[i],"wmode1=",7)) {
1143 + opt->weight1.weight_mode=atoi(argv[i]+7);
1144 + } else if(!memcmp(argv[i],"wmode2=",7)) {
1145 + opt->weight2.weight_mode=atoi(argv[i]+7);
1146 + } else {
1147 + printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
1148 + return -1;
1149 + }
1150 + }
1151 + return 0;
1152 +}
1153 +
1154 +static int wrr_parse_class_modf(int argc, char** argv,
1155 + struct tc_wrr_class_modf* modf) {
1156 + int i;
1157 +
1158 + if(argc<1) {
1159 + fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
1160 + fprintf(stderr, " The values can be floating point like 0.42 or divisions like 42/100\n");
1161 + return -1;
1162 + }
1163 +
1164 + // Set meaningless values:
1165 + modf->weight1.val=0;
1166 + modf->weight1.decr=(__u64)-1;
1167 + modf->weight1.incr=(__u64)-1;
1168 + modf->weight1.min=0;
1169 + modf->weight1.max=0;
1170 + modf->weight2.val=0;
1171 + modf->weight2.decr=(__u64)-1;
1172 + modf->weight2.incr=(__u64)-1;
1173 + modf->weight2.min=0;
1174 + modf->weight2.max=0;
1175 +
1176 + // And read values:
1177 + for(i=0; i<argc; i++) {
1178 + char arg[80];
1179 + char* name,*value1=0,*value2=0;
1180 + long double f_val1,f_val2=1,value;
1181 + if(strlen(argv[i])>=sizeof(arg)) {
1182 + fprintf(stderr,"Argument too long: %s\n",argv[i]);
1183 + return -1;
1184 + }
1185 + strcpy(arg,argv[i]);
1186 +
1187 + name=strtok(arg,"=");
1188 + if(name) value1=strtok(0,"/");
1189 + if(value1) value2=strtok(0,"");
1190 +
1191 + if(!value1) {
1192 + fprintf(stderr,"No = found in argument: %s\n",argv[i]);
1193 + return -1;
1194 + }
1195 +
1196 + f_val1=atof(value1);
1197 + if(value2) f_val2=atof(value2);
1198 +
1199 + if(f_val2==0) {
1200 + fprintf(stderr,"Division by 0\n");
1201 + return -1;
1202 + }
1203 +
1204 + value=f_val1/f_val2;
1205 + if(value>1) value=1;
1206 + if(value<0) value=0;
1207 + value*=((__u64)-1);
1208 +
1209 + // And find the value set
1210 + if(!strcmp(name,"weight1")) modf->weight1.val=value;
1211 + else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
1212 + else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
1213 + else if(!strcmp(name,"min1")) modf->weight1.min=value;
1214 + else if(!strcmp(name,"max1")) modf->weight1.max=value;
1215 + else if(!strcmp(name,"weight2")) modf->weight2.val=value;
1216 + else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
1217 + else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
1218 + else if(!strcmp(name,"min2")) modf->weight2.min=value;
1219 + else if(!strcmp(name,"max2")) modf->weight2.max=value;
1220 + else {
1221 + fprintf(stderr,"illegal value: %s\n",name);
1222 + return -1;
1223 + }
1224 + }
1225 +
1226 + return 0;
1227 +}
1228 +
1229 +static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
1230 +{
1231 + if(n->nlmsg_flags & NLM_F_CREATE) {
1232 + // This is a create request:
1233 + struct tc_wrr_qdisc_crt opt;
1234 +
1235 + int sour,dest,ip,mac,masq;
1236 +
1237 + if(argc<4) {
1238 + fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
1239 + return -1;
1240 + }
1241 +
1242 + // Read sour/dest:
1243 + memset(&opt,0,sizeof(opt));
1244 + sour=!strcmp(argv[0],"sour");
1245 + dest=!strcmp(argv[0],"dest");
1246 +
1247 + if(!sour && !dest) {
1248 + fprintf(stderr,"sour or dest must be specified\n");
1249 + return -1;
1250 + }
1251 +
1252 + // Read ip/mac
1253 + ip=!strcmp(argv[1],"ip");
1254 + mac=!strcmp(argv[1],"mac");
1255 + masq=!strcmp(argv[1],"masq");
1256 +
1257 + if(!ip && !mac && !masq) {
1258 + fprintf(stderr,"ip, masq or mac must be specified\n");
1259 + return -1;
1260 + }
1261 +
1262 + opt.srcaddr=sour;
1263 + opt.usemac=mac;
1264 + opt.usemasq=masq;
1265 + opt.bands_max=atoi(argv[2]);
1266 +
1267 + opt.proxy_maxconn=atoi(argv[3]);
1268 +
1269 + // Read weights:
1270 + if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
1271 + if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
1272 + if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
1273 +
1274 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1275 + } else {
1276 + struct tc_wrr_qdisc_modf_std opt;
1277 + char qdisc,class;
1278 +
1279 + // This is a modify request:
1280 + if(argc<1) {
1281 + fprintf(stderr,"... qdisc ... or ... class ...\n");
1282 + return -1;
1283 + }
1284 +
1285 + qdisc=!strcmp(argv[0],"qdisc");
1286 + class=!strcmp(argv[0],"class");
1287 +
1288 + if(!qdisc && !class) {
1289 + fprintf(stderr,"qdisc or class must be specified\n");
1290 + return -1;
1291 + }
1292 +
1293 + argc--;
1294 + argv++;
1295 +
1296 + opt.proxy=0;
1297 +
1298 + if(qdisc) {
1299 + opt.change_class=0;
1300 + if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
1301 + } else {
1302 + int a0,a1,a2,a3,a4=0,a5=0;
1303 +
1304 + opt.change_class=1;
1305 +
1306 + if(argc<1) {
1307 + fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
1308 + return -1;
1309 + }
1310 + memset(opt.addr,0,sizeof(opt.addr));
1311 +
1312 + if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
1313 + (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
1314 + fprintf(stderr,"Wrong format of mac or ip address\n");
1315 + return -1;
1316 + }
1317 +
1318 + opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
1319 + opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
1320 +
1321 + if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
1322 + }
1323 +
1324 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1325 + }
1326 + return 0;
1327 +}
1328 +
1329 +static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
1330 + struct tc_wrr_class_modf opt;
1331 +
1332 + memset(&opt,0,sizeof(opt));
1333 + if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
1334 +
1335 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1336 + return 0;
1337 +}
1338 +
1339 +static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1340 +{
1341 + struct tc_wrr_qdisc_stats *qopt;
1342 +
1343 + if (opt == NULL)
1344 + return 0;
1345 +
1346 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
1347 + return -1;
1348 + qopt = RTA_DATA(opt);
1349 +
1350 + fprintf(f,"\n (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
1351 + qopt->qdisc_crt.srcaddr ? "sour" : "dest",
1352 + qopt->qdisc_crt.usemac ? "mac" : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),
1353 + qopt->qdisc_crt.bands_max,
1354 + qopt->bands_cur,
1355 + qopt->bands_reused
1356 + );
1357 +
1358 + if(qopt->qdisc_crt.proxy_maxconn) {
1359 + fprintf(f," (proxy maxcon %i) (proxy curcon %i)\n",
1360 + qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
1361 + }
1362 +
1363 + fprintf(f," (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
1364 + qopt->nodes_in_heap,
1365 + qopt->packets_requed,
1366 + qopt->priosum/((long double)((__u32)-1))
1367 + );
1368 +
1369 + fprintf(f," (wmode1 %i) (wmode2 %i) \n",
1370 + qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
1371 + qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
1372 +
1373 + return 0;
1374 +}
1375 +
1376 +static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
1377 + struct tc_wrr_class_stats *copt;
1378 + long double d=(__u64)-1;
1379 +
1380 + if (opt == NULL) return 0;
1381 +
1382 + if (RTA_PAYLOAD(opt) < sizeof(*copt))
1383 + return -1;
1384 + copt = RTA_DATA(opt);
1385 +
1386 + if(!copt->used) {
1387 + fprintf(f,"(unused)");
1388 + return 0;
1389 + }
1390 +
1391 + if(copt->usemac) {
1392 + fprintf(f,"\n (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
1393 + copt->addr[0],copt->addr[1],copt->addr[2],
1394 + copt->addr[3],copt->addr[4],copt->addr[5]);
1395 + } else {
1396 + fprintf(f,"\n (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
1397 + }
1398 +
1399 + fprintf(f," (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
1400 + (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
1401 + copt->heappos,
1402 + (unsigned)(copt->penal_ms>>32),
1403 + (unsigned)(copt->penal_ms & 0xffffffffU),
1404 + (unsigned)(copt->penal_ls>>32),
1405 + (unsigned)(copt->penal_ls & 0xffffffffU)
1406 + );
1407 +
1408 + fprintf(f," Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
1409 + copt->class_modf.weight1.val/d,
1410 + copt->class_modf.weight1.decr/d,
1411 + copt->class_modf.weight1.incr/d,
1412 + copt->class_modf.weight1.min/d,
1413 + copt->class_modf.weight1.max/d);
1414 +
1415 + fprintf(f," Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
1416 + copt->class_modf.weight2.val/d,
1417 + copt->class_modf.weight2.decr/d,
1418 + copt->class_modf.weight2.incr/d,
1419 + copt->class_modf.weight2.min/d,
1420 + copt->class_modf.weight2.max/d);
1421 +
1422 + return 0;
1423 +}
1424 +
1425 +static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1426 +{
1427 + return 0;
1428 +}
1429 +
1430 +
1431 +struct qdisc_util wrr_qdisc_util = {
1432 + .id = "wrr",
1433 + .parse_qopt = wrr_parse_opt,
1434 + .print_qopt = wrr_print_opt,
1435 + .print_xstats = wrr_print_xstats,
1436 + .parse_copt = wrr_parse_copt,
1437 + .print_copt = wrr_print_copt
1438 +};