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