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