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