1 diff -Nur iproute2-2.6.15-060110/doc/ip-cref.tex iproute2-2.6.15-060110-owrt/doc/ip-cref.tex
2 --- iproute2-2.6.15-060110/doc/ip-cref.tex 2004-04-15 22:56:59.000000000 +0200
3 +++ iproute2-2.6.15-060110-owrt/doc/ip-cref.tex 2006-03-22 12:49:35.000000000 +0100
5 If it is not given, Linux uses the value selected with \verb|sysctl|
6 variable \verb|net/ipv4/tcp_reordering|.
8 +\item \verb|hoplimit NUMBER|
10 +--- [2.5.74+ only] Hop limit on the path to this destination. If it is not
11 + given, Linux uses the value selected with \verb|sysctl| variable
12 + \verb|net/ipv4/ip_default_ttl|.
14 +\item \verb|initcwnd NUMBER|
16 +--- [2.5.70+ only] Initial congestion window size when establishing
17 + connections to this destination. This value is multiplied with the
18 + MSS (``Maximal Segment Size'') for the connection to get the actual
19 + window size. If it is not given (or set to zero), Linux uses the
20 + values specified in~\cite{RFC2414}.
23 \item \verb|nexthop NEXTHOP|
25 \bibitem{RFC-DHCP} R.~Droms.
26 ``Dynamic Host Configuration Protocol.'', RFC-2131
28 +\bibitem{RFC2414} M.~Allman, S.~Floyd, C.~Partridge.
29 +``Increasing TCP's Initial Window'', RFC-2414.
34 diff -Nur iproute2-2.6.15-060110/doc/Makefile iproute2-2.6.15-060110-owrt/doc/Makefile
35 --- iproute2-2.6.15-060110/doc/Makefile 2005-03-10 20:01:36.000000000 +0100
36 +++ iproute2-2.6.15-060110-owrt/doc/Makefile 2006-03-22 12:49:35.000000000 +0100
40 HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
41 +TXTFILES=$(subst .sgml,.txt,$(shell echo *.sgml))
42 DVIFILES=$(subst .ps,.dvi,$(PSFILES))
59 + lynx -nolist -dump $< > $@
62 install -m 0644 $(shell echo *.tex) $(DESTDIR)$(DOCDIR)
63 install -m 0644 $(shell echo *.sgml) $(DESTDIR)$(DOCDIR)
66 - rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html
67 + rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html $(TXTFILES)
68 diff -Nur iproute2-2.6.15-060110/include/linux/pkt_sched.h iproute2-2.6.15-060110-owrt/include/linux/pkt_sched.h
69 --- iproute2-2.6.15-060110/include/linux/pkt_sched.h 2005-12-10 00:27:44.000000000 +0100
70 +++ iproute2-2.6.15-060110-owrt/include/linux/pkt_sched.h 2006-03-22 12:49:35.000000000 +0100
73 +#ifndef __LINUX_PKT_SCHED_H
74 +#define __LINUX_PKT_SCHED_H
76 +/* Logical priority bands not depending on specific packet scheduler.
77 + Every scheduler will map them to real traffic classes, if it has
78 + no more precise mechanism to classify packets.
80 + These numbers have no special meaning, though their coincidence
81 + with obsolete IPv6 values is not occasional :-). New IPv6 drafts
82 + preferred full anarchy inspired by diffserv group.
84 + Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
85 + class, actually, as rule it will be handled with more care than
86 + filler or even bulk.
89 +#define TC_PRIO_BESTEFFORT 0
90 +#define TC_PRIO_FILLER 1
91 +#define TC_PRIO_BULK 2
92 +#define TC_PRIO_INTERACTIVE_BULK 4
93 +#define TC_PRIO_INTERACTIVE 6
94 +#define TC_PRIO_CONTROL 7
96 +#define TC_PRIO_MAX 15
98 +/* Generic queue statistics, available for all the elements.
99 + Particular schedulers may have also their private records.
104 + __u64 bytes; /* NUmber of enqueues bytes */
105 + __u32 packets; /* Number of enqueued packets */
106 + __u32 drops; /* Packets dropped because of lack of resources */
107 + __u32 overlimits; /* Number of throttle events when this
108 + * flow goes out of allocated bandwidth */
109 + __u32 bps; /* Current flow byte rate */
110 + __u32 pps; /* Current flow packet rate */
121 + unsigned char ewma_log;
127 + All the traffic control objects have 32bit identifiers, or "handles".
129 + They can be considered as opaque numbers from user API viewpoint,
130 + but actually they always consist of two fields: major and
131 + minor numbers, which are interpreted by kernel specially,
132 + that may be used by applications, though not recommended.
134 + F.e. qdisc handles always have minor number equal to zero,
135 + classes (or flows) have major equal to parent qdisc major, and
136 + minor uniquely identifying class inside qdisc.
138 + Macros to manipulate handles:
141 +#define TC_H_MAJ_MASK (0xFFFF0000U)
142 +#define TC_H_MIN_MASK (0x0000FFFFU)
143 +#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
144 +#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
145 +#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
147 +#define TC_H_UNSPEC (0U)
148 +#define TC_H_ROOT (0xFFFFFFFFU)
149 +#define TC_H_INGRESS (0xFFFFFFF1U)
153 + unsigned char cell_log;
154 + unsigned char __reserved;
155 + unsigned short feature;
157 + unsigned short mpu;
165 + __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
170 +#define TCQ_PRIO_BANDS 16
174 + int bands; /* Number of bands */
175 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
182 + int flows; /* Maximal number of guaranteed flows */
183 + unsigned char R_log; /* Fixed point position for round number */
184 + unsigned char delta_log; /* Log of maximal managed time interval */
185 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> CSZ band */
190 + struct tc_ratespec slice;
191 + struct tc_ratespec rate;
192 + struct tc_ratespec peakrate;
210 + struct tc_ratespec rate;
211 + struct tc_ratespec peakrate;
228 +/* TEQL does not require any parameters */
234 + unsigned quantum; /* Bytes per round allocated to flow */
235 + int perturb_period; /* Period of hash perturbation */
236 + __u32 limit; /* Maximal packets in queue */
237 + unsigned divisor; /* Hash divisor */
238 + unsigned flows; /* Maximal number of flows */
242 + * NOTE: limit, divisor and flows are hardwired to code at the moment.
244 + * limit=flows=128, divisor=1024;
246 + * The only reason for this is efficiency, it is possible
247 + * to change these parameters in compile time.
261 + __u32 limit; /* HARD maximal queue length (bytes) */
262 + __u32 qth_min; /* Min average length threshold (bytes) */
263 + __u32 qth_max; /* Max average length threshold (bytes) */
264 + unsigned char Wlog; /* log(W) */
265 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
266 + unsigned char Scell_log; /* cell size for idle damping */
267 + unsigned char flags;
268 +#define TC_RED_ECN 1
271 +struct tc_red_xstats
273 + __u32 early; /* Early drops */
274 + __u32 pdrop; /* Drops due to queue limits */
275 + __u32 other; /* Drops due to drop() calls */
276 + __u32 marked; /* Marked packets */
291 +#define TCA_SET_OFF TCA_GRED_PARMS
294 + __u32 limit; /* HARD maximal queue length (bytes)
296 + __u32 qth_min; /* Min average length threshold (bytes)
298 + __u32 qth_max; /* Max average length threshold (bytes)
300 + __u32 DP; /* upto 2^32 DPs */
308 + unsigned char Wlog; /* log(W) */
309 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
310 + unsigned char Scell_log; /* cell size for idle damping */
311 + __u8 prio; /* prio of this VQ */
324 +#define TC_HTB_NUMPRIO 8
325 +#define TC_HTB_MAXDEPTH 8
326 +#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */
330 + struct tc_ratespec rate;
331 + struct tc_ratespec ceil;
335 + __u32 level; /* out only */
340 + __u32 version; /* to match HTB/TC */
341 + __u32 rate2quantum; /* bps->quantum divisor */
342 + __u32 defcls; /* default class number */
343 + __u32 debug; /* debug flags */
346 + __u32 direct_pkts; /* count of non shapped packets */
356 +struct tc_htb_xstats
360 + __u32 giants; /* too big packets (rate will not be accurate) */
367 +#define TC_CBQ_MAXPRIO 8
368 +#define TC_CBQ_MAXLEVEL 8
369 +#define TC_CBQ_DEF_EWMA 5
371 +struct tc_cbq_lssopt
373 + unsigned char change;
374 + unsigned char flags;
375 +#define TCF_CBQ_LSS_BOUNDED 1
376 +#define TCF_CBQ_LSS_ISOLATED 2
377 + unsigned char ewma_log;
378 + unsigned char level;
379 +#define TCF_CBQ_LSS_FLAGS 1
380 +#define TCF_CBQ_LSS_EWMA 2
381 +#define TCF_CBQ_LSS_MAXIDLE 4
382 +#define TCF_CBQ_LSS_MINIDLE 8
383 +#define TCF_CBQ_LSS_OFFTIME 0x10
384 +#define TCF_CBQ_LSS_AVPKT 0x20
391 +struct tc_cbq_wrropt
393 + unsigned char flags;
394 + unsigned char priority;
395 + unsigned char cpriority;
396 + unsigned char __reserved;
403 + unsigned char strategy;
404 +#define TC_CBQ_OVL_CLASSIC 0
405 +#define TC_CBQ_OVL_DELAY 1
406 +#define TC_CBQ_OVL_LOWPRIO 2
407 +#define TC_CBQ_OVL_DROP 3
408 +#define TC_CBQ_OVL_RCLASSIC 4
409 + unsigned char priority2;
413 +struct tc_cbq_police
415 + unsigned char police;
416 + unsigned char __res1;
417 + unsigned short __res2;
427 +struct tc_cbq_xstats
441 + TCA_CBQ_OVL_STRATEGY,
447 +#define TCA_CBQ_MAX TCA_CBQ_POLICE
449 +/* dsmark section */
453 + TCA_DSMARK_INDICES,
454 + TCA_DSMARK_DEFAULT_INDEX,
455 + TCA_DSMARK_SET_TC_INDEX,
460 +#define TCA_DSMARK_MAX TCA_DSMARK_VALUE
466 + TCA_ATM_FD, /* file/socket descriptor */
467 + TCA_ATM_PTR, /* pointer to descriptor - later */
468 + TCA_ATM_HDR, /* LL header */
469 + TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
470 + TCA_ATM_ADDR, /* PVC address (for output only) */
471 + TCA_ATM_STATE /* VC state (ATM_VS_*; for output only) */
474 +#define TCA_ATM_MAX TCA_ATM_STATE
478 #ifndef __LINUX_PKT_SCHED_H
479 #define __LINUX_PKT_SCHED_H
481 @@ -466,4 +872,116 @@
483 #define NETEM_DIST_SCALE 8192
487 +/* Other includes */
488 +#include <linux/if_ether.h>
490 +// A sub weight and of a class
491 +// All numbers are represented as parts of (2^64-1).
492 +struct tc_wrr_class_weight {
493 + __u64 val; // Current value (0 is not valid)
494 + __u64 decr; // Value pr bytes (2^64-1 is not valid)
495 + __u64 incr; // Value pr seconds (2^64-1 is not valid)
496 + __u64 min; // Minimal value (0 is not valid)
497 + __u64 max; // Minimal value (0 is not valid)
499 +// The time where the above information was correct:
503 +// Packet send when modifying a class:
504 +struct tc_wrr_class_modf {
505 + // Not-valid values are ignored.
506 + struct tc_wrr_class_weight weight1;
507 + struct tc_wrr_class_weight weight2;
510 +// Packet returned when quering a class:
511 +struct tc_wrr_class_stats {
512 + char used; // If this is false the information below is invalid
514 + struct tc_wrr_class_modf class_modf;
516 + unsigned char addr[ETH_ALEN];
517 + char usemac; // True if addr is a MAC address, else it is an IP address
518 + // (this value is only for convience, it is always the same
519 + // value as in the qdisc)
520 + int heappos; // Current heap position or 0 if not in heap
521 + __u64 penal_ls; // Penalty value in heap (ls)
522 + __u64 penal_ms; // Penalty value in heap (ms)
525 +// Qdisc-wide penalty information (boolean values - 2 not valid)
526 +struct tc_wrr_qdisc_weight {
527 + char weight_mode; // 0=No automatic change to weight
528 + // 1=Decrease normally
529 + // 2=Also multiply with number of machines
530 + // 3=Instead multiply with priority divided
531 + // with priority of the other.
535 +// Packet send when modifing a qdisc:
536 +struct tc_wrr_qdisc_modf {
537 + // Not-valid values are ignored:
538 + struct tc_wrr_qdisc_weight weight1;
539 + struct tc_wrr_qdisc_weight weight2;
542 +// Packet send when creating a qdisc:
543 +struct tc_wrr_qdisc_crt {
544 + struct tc_wrr_qdisc_modf qdisc_modf;
546 + char srcaddr; // 1=lookup source, 0=lookup destination
547 + char usemac; // 1=Classify on MAC addresses, 0=classify on IP
548 + char usemasq; // 1=Classify based on masqgrading - only valid
549 + // if usemac is zero
550 + int bands_max; // Maximal number of bands (i.e.: classes)
551 + int proxy_maxconn;// If differnt from 0 then we support proxy remapping
552 + // of packets. And this is the number of maximal
553 + // concurrent proxy connections.
556 +// Packet returned when quering a qdisc:
557 +struct tc_wrr_qdisc_stats {
558 + struct tc_wrr_qdisc_crt qdisc_crt;
560 + int nodes_in_heap; // Current number of bands wanting to send something
561 + int bands_cur; // Current number of bands used (i.e.: MAC/IP addresses seen)
562 + int bands_reused; // Number of times this band has been reused.
563 + int packets_requed; // Number of times packets have been requeued.
564 + __u64 priosum; // Sum of priorities in heap where 1 is 2^32
567 +struct tc_wrr_qdisc_modf_std {
568 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
569 + char proxy; // 0=This struct
571 + // Should we also change a class?
574 + // Only valid if change_class is false
575 + struct tc_wrr_qdisc_modf qdisc_modf;
577 + // Only valid if change_class is true:
578 + unsigned char addr[ETH_ALEN]; // Class to change (non-used bytes should be 0)
579 + struct tc_wrr_class_modf class_modf; // The change
582 +// Used for proxyrempping:
583 +struct tc_wrr_qdisc_modf_proxy {
584 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
585 + char proxy; // 1=This struct
587 + // This is 1 if the proxyremap information should be reset
590 + // changec is the number of elements in changes.
593 + // This is an array of type ProxyRemapBlock:
598 diff -Nur iproute2-2.6.15-060110/ip/iproute.c iproute2-2.6.15-060110-owrt/ip/iproute.c
599 --- iproute2-2.6.15-060110/ip/iproute.c 2005-10-13 00:49:50.000000000 +0200
600 +++ iproute2-2.6.15-060110-owrt/ip/iproute.c 2006-03-22 12:49:35.000000000 +0100
602 fprintf(stderr, "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ]\n");
603 fprintf(stderr, " [ rtt NUMBER ] [ rttvar NUMBER ]\n");
604 fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ ssthresh NUMBER ]\n");
605 - fprintf(stderr, " [ realms REALM ]\n");
606 + fprintf(stderr, " [ realms REALM ] [ hoplimit NUMBER ] [ initcwnd NUMBER ]\n");
607 fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
608 fprintf(stderr, " unreachable | prohibit | blackhole | nat ]\n");
609 fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
618 if (mxrta[i] == NULL)
620 invarg("\"reordering\" value is invalid\n", *argv);
621 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_REORDERING, reord);
623 +#ifdef RTAX_HOPLIMIT
624 + } else if (strcmp(*argv, "hoplimit") == 0) {
627 + if (strcmp(*argv, "lock") == 0) {
628 + mxlock |= (1<<RTAX_HOPLIMIT);
631 + if (get_unsigned(&hoplim, *argv, 0))
632 + invarg("\"hoplimit\" value is invalid\n", *argv);
633 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplim);
635 +#ifdef RTAX_INITCWND
636 + } else if (strcmp(*argv, "initcwnd") == 0) {
639 + if (strcmp(*argv, "lock") == 0) {
640 + mxlock |= (1<<RTAX_HOPLIMIT);
643 + if (get_unsigned(&initcwnd, *argv, 0))
644 + invarg("\"initcwnd\" value is invalid\n", *argv);
645 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITCWND, initcwnd);
647 } else if (strcmp(*argv, "rtt") == 0) {
650 diff -Nur iproute2-2.6.15-060110/ip/iptunnel.c iproute2-2.6.15-060110-owrt/ip/iptunnel.c
651 --- iproute2-2.6.15-060110/ip/iptunnel.c 2005-02-10 19:31:18.000000000 +0100
652 +++ iproute2-2.6.15-060110-owrt/ip/iptunnel.c 2006-03-22 12:49:35.000000000 +0100
655 p->i_flags |= GRE_KEY;
656 if (strchr(*argv, '.'))
657 - p->o_key = get_addr32(*argv);
658 + p->i_key = get_addr32(*argv);
660 if (get_unsigned(&uval, *argv, 0)<0) {
661 fprintf(stderr, "invalid value of \"ikey\"\n");
662 diff -Nur iproute2-2.6.15-060110/Makefile iproute2-2.6.15-060110-owrt/Makefile
663 --- iproute2-2.6.15-060110/Makefile 2005-07-09 00:08:47.000000000 +0200
664 +++ iproute2-2.6.15-060110-owrt/Makefile 2006-03-22 12:51:29.000000000 +0100
666 LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
669 - @for i in $(SUBDIRS); \
670 + @set -e; for i in $(SUBDIRS); \
671 do $(MAKE) $(MFLAGS) -C $$i; done
675 $(DESTDIR)$(DOCDIR)/examples
676 install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
677 $(DESTDIR)$(DOCDIR)/examples/diffserv
678 - @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
679 + @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
680 install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
681 install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
682 install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
687 - @for i in $(SUBDIRS) doc; \
688 + @set -e; for i in $(SUBDIRS) doc; \
689 do $(MAKE) $(MFLAGS) -C $$i clean; done
692 diff -Nur iproute2-2.6.15-060110/man/man8/ip.8 iproute2-2.6.15-060110-owrt/man/man8/ip.8
693 --- iproute2-2.6.15-060110/man/man8/ip.8 2006-01-03 20:25:29.000000000 +0100
694 +++ iproute2-2.6.15-060110-owrt/man/man8/ip.8 2006-03-22 12:49:35.000000000 +0100
695 @@ -1808,6 +1808,8 @@
696 .RB "IP Command reference " ip-cref.ps
698 .RB "IP tunnels " ip-cref.ps
700 +.RB http://lartc.org/
703 Original Manpage by Michail Litvak <mci@owl.openwall.com>
704 diff -Nur iproute2-2.6.15-060110/man/man8/tc.8 iproute2-2.6.15-060110-owrt/man/man8/tc.8
705 --- iproute2-2.6.15-060110/man/man8/tc.8 2004-06-08 22:34:17.000000000 +0200
706 +++ iproute2-2.6.15-060110-owrt/man/man8/tc.8 2006-03-22 12:49:35.000000000 +0100
710 .BR tc-pfifo_fast (8),
712 +.BR http://lartc.org/
715 Manpage maintained by bert hubert (ahu@ds9a.nl)
716 diff -Nur iproute2-2.6.15-060110/misc/Makefile iproute2-2.6.15-060110-owrt/misc/Makefile
717 --- iproute2-2.6.15-060110/misc/Makefile 2005-06-23 19:39:57.000000000 +0200
718 +++ iproute2-2.6.15-060110-owrt/misc/Makefile 2006-03-22 12:49:35.000000000 +0100
720 SSOBJ=ss.o ssfilter.o
721 LNSTATOBJ=lnstat.o lnstat_util.o
723 -TARGETS=ss nstat ifstat rtacct arpd lnstat
724 +#TARGETS=ss nstat ifstat rtacct arpd lnstat
725 +TARGETS=ss nstat rtacct lnstat
729 diff -Nur iproute2-2.6.15-060110/misc/netbug iproute2-2.6.15-060110-owrt/misc/netbug
730 --- iproute2-2.6.15-060110/misc/netbug 2004-04-15 22:56:59.000000000 +0200
731 +++ iproute2-2.6.15-060110-owrt/misc/netbug 2006-03-22 12:49:35.000000000 +0100
737 echo -n "Send network configuration summary to [ENTER means kuznet@ms2.inr.ac.ru] "
738 IFS="" read mail || exit 1
739 [ -z "$mail" ] && mail=kuznet@ms2.inr.ac.ru
741 +netbug=`mktemp -d -t netbug.XXXXXX` || {echo "$0: Cannot create temporary directory" >&2; exit 1; }
742 +netbugtar=`tempfile -d $netbug --suffix=tar.gz` || {echo "$0: Cannot create temporary file" >&2; exit 1; }
744 +trap "/bin/rm -rf $netbug $netbugtar" 0 1 2 3 13 15
747 -while [ "$netbug" = "" ]; do
748 - netbug=`echo netbug.$$.$RANDOM`
749 - if [ -e /tmp/$netbug ]; then
754 -tmppath=/tmp/$netbug
756 -trap "rm -rf $tmppath $tmppath.tar.gz" 0 SIGINT
761 cat /proc/slabinfo > $tmppath/slabinfo
766 -tar c $netbug | gzip -9c > $netbug.tar.gz
768 -uuencode $netbug.tar.gz $netbug.tar.gz | mail -s $netbug "$mail"
769 +tar c $tmppath | gzip -9c > $netbugtar
770 +uuencode $netbugtar $netbugtar | mail -s $netbug "$mail"
772 echo "Sending to <$mail>; subject is $netbug"
774 diff -Nur iproute2-2.6.15-060110/tc/Makefile iproute2-2.6.15-060110-owrt/tc/Makefile
775 --- iproute2-2.6.15-060110/tc/Makefile 2005-07-06 00:11:37.000000000 +0200
776 +++ iproute2-2.6.15-060110-owrt/tc/Makefile 2006-03-22 12:49:35.000000000 +0100
778 TCMODULES += q_prio.o
781 +TCMODULES += q_wrr.o
782 TCMODULES += f_rsvp.o
784 TCMODULES += f_route.o
785 diff -Nur iproute2-2.6.15-060110/tc/q_htb.c iproute2-2.6.15-060110-owrt/tc/q_htb.c
786 --- iproute2-2.6.15-060110/tc/q_htb.c 2005-01-18 23:11:58.000000000 +0100
787 +++ iproute2-2.6.15-060110-owrt/tc/q_htb.c 2006-03-22 12:49:35.000000000 +0100
793 + * This program is free software; you can redistribute it and/or
794 + * modify it under the terms of the GNU General Public License
795 + * as published by the Free Software Foundation; either version
796 + * 2 of the License, or (at your option) any later version.
798 + * Authors: Martin Devera, devik@cdi.cz
807 +#include <sys/socket.h>
808 +#include <netinet/in.h>
809 +#include <arpa/inet.h>
813 +#include "tc_util.h"
815 +#define HTB_TC_VER 0x30003
816 +#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
817 +#error "Different kernel and TC HTB versions"
820 +static void explain(void)
822 + fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
823 + " default minor id of class to which unclassified packets are sent {0}\n"
824 + " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
825 + " debug string of 16 numbers each 0-3 {0}\n\n"
826 + "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
827 + " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
828 + " rate rate allocated to this class (class can still borrow)\n"
829 + " burst max bytes burst which can be accumulated during idle period {computed}\n"
830 + " ceil definite upper class rate (no borrows) {rate}\n"
831 + " cburst burst but for ceil {computed}\n"
832 + " mtu max packet size we create rate map for {1600}\n"
833 + " prio priority of leaf; lower are served first {0}\n"
834 + " quantum how much bytes to serve from leaf at once {use r2q}\n"
835 + "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
839 +static void explain1(char *arg)
841 + fprintf(stderr, "Illegal \"%s\"\n", arg);
846 +#define usage() return(-1)
848 +static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
850 + struct tc_htb_glob opt;
851 + struct rtattr *tail;
852 + unsigned i; char *p;
853 + memset(&opt,0,sizeof(opt));
854 + opt.rate2quantum = 10;
858 + if (matches(*argv, "r2q") == 0) {
860 + if (get_u32(&opt.rate2quantum, *argv, 10)) {
861 + explain1("r2q"); return -1;
863 + } else if (matches(*argv, "default") == 0) {
865 + if (get_u32(&opt.defcls, *argv, 16)) {
866 + explain1("default"); return -1;
868 + } else if (matches(*argv, "debug") == 0) {
869 + NEXT_ARG(); p = *argv;
870 + for (i=0; i<16; i++,p++) {
871 + if (*p<'0' || *p>'3') break;
872 + opt.debug |= (*p-'0')<<(2*i);
875 + fprintf(stderr, "What is \"%s\"?\n", *argv);
881 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
882 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
883 + addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
884 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
888 +static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
891 + struct tc_htb_opt opt;
892 + __u32 rtab[256],ctab[256];
893 + unsigned buffer=0,cbuffer=0;
894 + int cell_log=-1,ccell_log = -1,mtu;
895 + struct rtattr *tail;
897 + memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
900 + if (matches(*argv, "prio") == 0) {
902 + if (get_u32(&opt.prio, *argv, 10)) {
903 + explain1("prio"); return -1;
906 + } else if (matches(*argv, "mtu") == 0) {
908 + if (get_u32(&mtu, *argv, 10)) {
909 + explain1("mtu"); return -1;
911 + } else if (matches(*argv, "quantum") == 0) {
913 + if (get_u32(&opt.quantum, *argv, 10)) {
914 + explain1("quantum"); return -1;
916 + } else if (matches(*argv, "burst") == 0 ||
917 + strcmp(*argv, "buffer") == 0 ||
918 + strcmp(*argv, "maxburst") == 0) {
920 + if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
921 + explain1("buffer");
925 + } else if (matches(*argv, "cburst") == 0 ||
926 + strcmp(*argv, "cbuffer") == 0 ||
927 + strcmp(*argv, "cmaxburst") == 0) {
929 + if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
930 + explain1("cbuffer");
934 + } else if (strcmp(*argv, "ceil") == 0) {
936 + if (opt.ceil.rate) {
937 + fprintf(stderr, "Double \"ceil\" spec\n");
940 + if (get_rate(&opt.ceil.rate, *argv)) {
945 + } else if (strcmp(*argv, "rate") == 0) {
947 + if (opt.rate.rate) {
948 + fprintf(stderr, "Double \"rate\" spec\n");
951 + if (get_rate(&opt.rate.rate, *argv)) {
956 + } else if (strcmp(*argv, "help") == 0) {
960 + fprintf(stderr, "What is \"%s\"?\n", *argv);
970 + if (opt.rate.rate == 0) {
971 + fprintf(stderr, "\"rate\" is required.\n");
974 + /* if ceil params are missing, use the same as rate */
975 + if (!opt.ceil.rate) opt.ceil = opt.rate;
977 + /* compute minimal allowed burst from rate; mtu is added here to make
978 + sute that buffer is larger than mtu and to have some safeguard space */
979 + if (!buffer) buffer = opt.rate.rate / HZ + mtu;
980 + if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
982 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
983 + fprintf(stderr, "htb: failed to calculate rate table.\n");
986 + opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
987 + opt.rate.cell_log = cell_log;
989 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
990 + fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
993 + opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
994 + opt.ceil.cell_log = ccell_log;
996 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
997 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
998 + addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
999 + addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
1000 + addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
1001 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
1005 +static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1007 + struct rtattr *tb[TCA_HTB_RTAB+1];
1008 + struct tc_htb_opt *hopt;
1009 + struct tc_htb_glob *gopt;
1010 + double buffer,cbuffer;
1017 + memset(tb, 0, sizeof(tb));
1018 + parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
1020 + if (tb[TCA_HTB_PARMS]) {
1022 + hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
1023 + if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
1025 + if (!hopt->level) {
1026 + fprintf(f, "prio %d ", (int)hopt->prio);
1028 + fprintf(f, "quantum %d ", (int)hopt->quantum);
1030 + fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
1031 + buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
1032 + fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
1033 + cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
1034 + if (show_details) {
1035 + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
1036 + 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
1037 + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
1038 + 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
1039 + fprintf(f, "level %d ", (int)hopt->level);
1041 + fprintf(f, "burst %s ", sprint_size(buffer, b1));
1042 + fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
1045 + fprintf(f, "buffer [%08x] cbuffer [%08x] ",
1046 + hopt->buffer,hopt->cbuffer);
1048 + if (tb[TCA_HTB_INIT]) {
1049 + gopt = RTA_DATA(tb[TCA_HTB_INIT]);
1050 + if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
1052 + fprintf(f, "r2q %d default %x direct_packets_stat %u",
1053 + gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
1055 + fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
1060 +static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1062 + struct tc_htb_xstats *st;
1063 + if (xstats == NULL)
1066 + if (RTA_PAYLOAD(xstats) < sizeof(*st))
1069 + st = RTA_DATA(xstats);
1070 + fprintf(f, " lended: %u borrowed: %u giants: %u\n",
1071 + st->lends,st->borrows,st->giants);
1072 + fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
1076 +struct qdisc_util htb_util = {
1082 + htb_parse_class_opt,
1086 +/* for testing of old one */
1087 +struct qdisc_util htb2_util = {
1093 + htb_parse_class_opt,
1100 diff -Nur iproute2-2.6.15-060110/tc/q_wrr.c iproute2-2.6.15-060110-owrt/tc/q_wrr.c
1101 --- iproute2-2.6.15-060110/tc/q_wrr.c 1970-01-01 01:00:00.000000000 +0100
1102 +++ iproute2-2.6.15-060110-owrt/tc/q_wrr.c 2006-03-22 12:49:35.000000000 +0100
1105 +#include <stdlib.h>
1106 +#include <unistd.h>
1107 +#include <syslog.h>
1109 +#include <sys/socket.h>
1110 +#include <netinet/in.h>
1111 +#include <arpa/inet.h>
1112 +#include <string.h>
1116 +#include "tc_util.h"
1118 +#define usage() return(-1)
1120 +// Returns -1 on error
1121 +static int wrr_parse_qdisc_weight(int argc, char** argv,
1122 + struct tc_wrr_qdisc_modf* opt) {
1125 + opt->weight1.weight_mode=-1;
1126 + opt->weight2.weight_mode=-1;
1128 + for(i=0; i<argc; i++) {
1129 + if(!memcmp(argv[i],"wmode1=",7)) {
1130 + opt->weight1.weight_mode=atoi(argv[i]+7);
1131 + } else if(!memcmp(argv[i],"wmode2=",7)) {
1132 + opt->weight2.weight_mode=atoi(argv[i]+7);
1134 + printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
1141 +static int wrr_parse_class_modf(int argc, char** argv,
1142 + struct tc_wrr_class_modf* modf) {
1146 + fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
1147 + fprintf(stderr, " The values can be floating point like 0.42 or divisions like 42/100\n");
1151 + // Set meaningless values:
1152 + modf->weight1.val=0;
1153 + modf->weight1.decr=(__u64)-1;
1154 + modf->weight1.incr=(__u64)-1;
1155 + modf->weight1.min=0;
1156 + modf->weight1.max=0;
1157 + modf->weight2.val=0;
1158 + modf->weight2.decr=(__u64)-1;
1159 + modf->weight2.incr=(__u64)-1;
1160 + modf->weight2.min=0;
1161 + modf->weight2.max=0;
1163 + // And read values:
1164 + for(i=0; i<argc; i++) {
1166 + char* name,*value1=0,*value2=0;
1167 + long double f_val1,f_val2=1,value;
1168 + if(strlen(argv[i])>=sizeof(arg)) {
1169 + fprintf(stderr,"Argument too long: %s\n",argv[i]);
1172 + strcpy(arg,argv[i]);
1174 + name=strtok(arg,"=");
1175 + if(name) value1=strtok(0,"/");
1176 + if(value1) value2=strtok(0,"");
1179 + fprintf(stderr,"No = found in argument: %s\n",argv[i]);
1183 + f_val1=atof(value1);
1184 + if(value2) f_val2=atof(value2);
1187 + fprintf(stderr,"Division by 0\n");
1191 + value=f_val1/f_val2;
1192 + if(value>1) value=1;
1193 + if(value<0) value=0;
1194 + value*=((__u64)-1);
1196 + // And find the value set
1197 + if(!strcmp(name,"weight1")) modf->weight1.val=value;
1198 + else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
1199 + else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
1200 + else if(!strcmp(name,"min1")) modf->weight1.min=value;
1201 + else if(!strcmp(name,"max1")) modf->weight1.max=value;
1202 + else if(!strcmp(name,"weight2")) modf->weight2.val=value;
1203 + else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
1204 + else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
1205 + else if(!strcmp(name,"min2")) modf->weight2.min=value;
1206 + else if(!strcmp(name,"max2")) modf->weight2.max=value;
1208 + fprintf(stderr,"illegal value: %s\n",name);
1216 +static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
1218 + if(n->nlmsg_flags & NLM_F_CREATE) {
1219 + // This is a create request:
1220 + struct tc_wrr_qdisc_crt opt;
1222 + int sour,dest,ip,mac,masq;
1225 + fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
1229 + // Read sour/dest:
1230 + memset(&opt,0,sizeof(opt));
1231 + sour=!strcmp(argv[0],"sour");
1232 + dest=!strcmp(argv[0],"dest");
1234 + if(!sour && !dest) {
1235 + fprintf(stderr,"sour or dest must be specified\n");
1240 + ip=!strcmp(argv[1],"ip");
1241 + mac=!strcmp(argv[1],"mac");
1242 + masq=!strcmp(argv[1],"masq");
1244 + if(!ip && !mac && !masq) {
1245 + fprintf(stderr,"ip, masq or mac must be specified\n");
1252 + opt.bands_max=atoi(argv[2]);
1254 + opt.proxy_maxconn=atoi(argv[3]);
1257 + if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
1258 + if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
1259 + if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
1261 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1263 + struct tc_wrr_qdisc_modf_std opt;
1266 + // This is a modify request:
1268 + fprintf(stderr,"... qdisc ... or ... class ...\n");
1272 + qdisc=!strcmp(argv[0],"qdisc");
1273 + class=!strcmp(argv[0],"class");
1275 + if(!qdisc && !class) {
1276 + fprintf(stderr,"qdisc or class must be specified\n");
1286 + opt.change_class=0;
1287 + if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
1289 + int a0,a1,a2,a3,a4=0,a5=0;
1291 + opt.change_class=1;
1294 + fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
1297 + memset(opt.addr,0,sizeof(opt.addr));
1299 + if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
1300 + (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
1301 + fprintf(stderr,"Wrong format of mac or ip address\n");
1305 + opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
1306 + opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
1308 + if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
1311 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1316 +static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
1317 + struct tc_wrr_class_modf opt;
1319 + memset(&opt,0,sizeof(opt));
1320 + if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
1322 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1326 +static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1328 + struct tc_wrr_qdisc_stats *qopt;
1333 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
1335 + qopt = RTA_DATA(opt);
1337 + fprintf(f,"\n (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
1338 + qopt->qdisc_crt.srcaddr ? "sour" : "dest",
1339 + qopt->qdisc_crt.usemac ? "mac" : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),
1340 + qopt->qdisc_crt.bands_max,
1342 + qopt->bands_reused
1345 + if(qopt->qdisc_crt.proxy_maxconn) {
1346 + fprintf(f," (proxy maxcon %i) (proxy curcon %i)\n",
1347 + qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
1350 + fprintf(f," (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
1351 + qopt->nodes_in_heap,
1352 + qopt->packets_requed,
1353 + qopt->priosum/((long double)((__u32)-1))
1356 + fprintf(f," (wmode1 %i) (wmode2 %i) \n",
1357 + qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
1358 + qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
1363 +static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
1364 + struct tc_wrr_class_stats *copt;
1365 + long double d=(__u64)-1;
1367 + if (opt == NULL) return 0;
1369 + if (RTA_PAYLOAD(opt) < sizeof(*copt))
1371 + copt = RTA_DATA(opt);
1374 + fprintf(f,"(unused)");
1378 + if(copt->usemac) {
1379 + fprintf(f,"\n (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
1380 + copt->addr[0],copt->addr[1],copt->addr[2],
1381 + copt->addr[3],copt->addr[4],copt->addr[5]);
1383 + fprintf(f,"\n (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
1386 + fprintf(f," (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
1387 + (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
1389 + (unsigned)(copt->penal_ms>>32),
1390 + (unsigned)(copt->penal_ms & 0xffffffffU),
1391 + (unsigned)(copt->penal_ls>>32),
1392 + (unsigned)(copt->penal_ls & 0xffffffffU)
1395 + fprintf(f," Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
1396 + copt->class_modf.weight1.val/d,
1397 + copt->class_modf.weight1.decr/d,
1398 + copt->class_modf.weight1.incr/d,
1399 + copt->class_modf.weight1.min/d,
1400 + copt->class_modf.weight1.max/d);
1402 + fprintf(f," Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
1403 + copt->class_modf.weight2.val/d,
1404 + copt->class_modf.weight2.decr/d,
1405 + copt->class_modf.weight2.incr/d,
1406 + copt->class_modf.weight2.min/d,
1407 + copt->class_modf.weight2.max/d);
1412 +static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1418 +struct qdisc_util wrr_qdisc_util = {
1420 + .parse_qopt = wrr_parse_opt,
1421 + .print_qopt = wrr_print_opt,
1422 + .print_xstats = wrr_print_xstats,
1423 + .parse_copt = wrr_parse_copt,
1424 + .print_copt = wrr_print_copt