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