1 Index: iproute-2.6.20-070313/doc/ip-cref.tex
2 ===================================================================
3 --- iproute-2.6.20-070313.orig/doc/ip-cref.tex 2007-06-09 13:53:56.000000000 +0100
4 +++ iproute-2.6.20-070313/doc/ip-cref.tex 2007-06-09 13:53:57.000000000 +0100
6 If it is not given, Linux uses the value selected with \verb|sysctl|
7 variable \verb|net/ipv4/tcp_reordering|.
9 +\item \verb|hoplimit NUMBER|
11 +--- [2.5.74+ only] Hop limit on the path to this destination. If it is not
12 + given, Linux uses the value selected with \verb|sysctl| variable
13 + \verb|net/ipv4/ip_default_ttl|.
15 +\item \verb|initcwnd NUMBER|
17 +--- [2.5.70+ only] Initial congestion window size when establishing
18 + connections to this destination. This value is multiplied with the
19 + MSS (``Maximal Segment Size'') for the connection to get the actual
20 + window size. If it is not given (or set to zero), Linux uses the
21 + values specified in~\cite{RFC2414}.
24 \item \verb|nexthop NEXTHOP|
26 \bibitem{RFC-DHCP} R.~Droms.
27 ``Dynamic Host Configuration Protocol.'', RFC-2131
29 +\bibitem{RFC2414} M.~Allman, S.~Floyd, C.~Partridge.
30 +``Increasing TCP's Initial Window'', RFC-2414.
35 Index: iproute-2.6.20-070313/doc/Makefile
36 ===================================================================
37 --- iproute-2.6.20-070313.orig/doc/Makefile 2007-06-09 13:53:56.000000000 +0100
38 +++ iproute-2.6.20-070313/doc/Makefile 2007-06-09 13:53:57.000000000 +0100
42 HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
43 +TXTFILES=$(subst .sgml,.txt,$(shell echo *.sgml))
44 DVIFILES=$(subst .ps,.dvi,$(PSFILES))
61 + lynx -nolist -dump $< > $@
64 install -m 0644 $(shell echo *.tex) $(DESTDIR)$(DOCDIR)
65 install -m 0644 $(shell echo *.sgml) $(DESTDIR)$(DOCDIR)
68 - rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html
69 + rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html $(TXTFILES)
70 Index: iproute-2.6.20-070313/include/linux/pkt_sched.h
71 ===================================================================
72 --- iproute-2.6.20-070313.orig/include/linux/pkt_sched.h 2007-06-09 13:53:56.000000000 +0100
73 +++ iproute-2.6.20-070313/include/linux/pkt_sched.h 2007-06-09 13:53:57.000000000 +0100
76 +#ifndef __LINUX_PKT_SCHED_H
77 +#define __LINUX_PKT_SCHED_H
79 +/* Logical priority bands not depending on specific packet scheduler.
80 + Every scheduler will map them to real traffic classes, if it has
81 + no more precise mechanism to classify packets.
83 + These numbers have no special meaning, though their coincidence
84 + with obsolete IPv6 values is not occasional :-). New IPv6 drafts
85 + preferred full anarchy inspired by diffserv group.
87 + Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
88 + class, actually, as rule it will be handled with more care than
89 + filler or even bulk.
92 +#define TC_PRIO_BESTEFFORT 0
93 +#define TC_PRIO_FILLER 1
94 +#define TC_PRIO_BULK 2
95 +#define TC_PRIO_INTERACTIVE_BULK 4
96 +#define TC_PRIO_INTERACTIVE 6
97 +#define TC_PRIO_CONTROL 7
99 +#define TC_PRIO_MAX 15
101 +/* Generic queue statistics, available for all the elements.
102 + Particular schedulers may have also their private records.
107 + __u64 bytes; /* NUmber of enqueues bytes */
108 + __u32 packets; /* Number of enqueued packets */
109 + __u32 drops; /* Packets dropped because of lack of resources */
110 + __u32 overlimits; /* Number of throttle events when this
111 + * flow goes out of allocated bandwidth */
112 + __u32 bps; /* Current flow byte rate */
113 + __u32 pps; /* Current flow packet rate */
124 + unsigned char ewma_log;
130 + All the traffic control objects have 32bit identifiers, or "handles".
132 + They can be considered as opaque numbers from user API viewpoint,
133 + but actually they always consist of two fields: major and
134 + minor numbers, which are interpreted by kernel specially,
135 + that may be used by applications, though not recommended.
137 + F.e. qdisc handles always have minor number equal to zero,
138 + classes (or flows) have major equal to parent qdisc major, and
139 + minor uniquely identifying class inside qdisc.
141 + Macros to manipulate handles:
144 +#define TC_H_MAJ_MASK (0xFFFF0000U)
145 +#define TC_H_MIN_MASK (0x0000FFFFU)
146 +#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
147 +#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
148 +#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
150 +#define TC_H_UNSPEC (0U)
151 +#define TC_H_ROOT (0xFFFFFFFFU)
152 +#define TC_H_INGRESS (0xFFFFFFF1U)
156 + unsigned char cell_log;
157 + unsigned char __reserved;
158 + unsigned short feature;
160 + unsigned short mpu;
168 + __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
173 +#define TCQ_PRIO_BANDS 16
177 + int bands; /* Number of bands */
178 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
185 + int flows; /* Maximal number of guaranteed flows */
186 + unsigned char R_log; /* Fixed point position for round number */
187 + unsigned char delta_log; /* Log of maximal managed time interval */
188 + __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> CSZ band */
193 + struct tc_ratespec slice;
194 + struct tc_ratespec rate;
195 + struct tc_ratespec peakrate;
213 + struct tc_ratespec rate;
214 + struct tc_ratespec peakrate;
231 +/* TEQL does not require any parameters */
237 + unsigned quantum; /* Bytes per round allocated to flow */
238 + int perturb_period; /* Period of hash perturbation */
239 + __u32 limit; /* Maximal packets in queue */
240 + unsigned divisor; /* Hash divisor */
241 + unsigned flows; /* Maximal number of flows */
245 + * NOTE: limit, divisor and flows are hardwired to code at the moment.
247 + * limit=flows=128, divisor=1024;
249 + * The only reason for this is efficiency, it is possible
250 + * to change these parameters in compile time.
264 + __u32 limit; /* HARD maximal queue length (bytes) */
265 + __u32 qth_min; /* Min average length threshold (bytes) */
266 + __u32 qth_max; /* Max average length threshold (bytes) */
267 + unsigned char Wlog; /* log(W) */
268 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
269 + unsigned char Scell_log; /* cell size for idle damping */
270 + unsigned char flags;
271 +#define TC_RED_ECN 1
274 +struct tc_red_xstats
276 + __u32 early; /* Early drops */
277 + __u32 pdrop; /* Drops due to queue limits */
278 + __u32 other; /* Drops due to drop() calls */
279 + __u32 marked; /* Marked packets */
294 +#define TCA_SET_OFF TCA_GRED_PARMS
297 + __u32 limit; /* HARD maximal queue length (bytes)
299 + __u32 qth_min; /* Min average length threshold (bytes)
301 + __u32 qth_max; /* Max average length threshold (bytes)
303 + __u32 DP; /* upto 2^32 DPs */
311 + unsigned char Wlog; /* log(W) */
312 + unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
313 + unsigned char Scell_log; /* cell size for idle damping */
314 + __u8 prio; /* prio of this VQ */
327 +#define TC_HTB_NUMPRIO 8
328 +#define TC_HTB_MAXDEPTH 8
329 +#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */
333 + struct tc_ratespec rate;
334 + struct tc_ratespec ceil;
338 + __u32 level; /* out only */
343 + __u32 version; /* to match HTB/TC */
344 + __u32 rate2quantum; /* bps->quantum divisor */
345 + __u32 defcls; /* default class number */
346 + __u32 debug; /* debug flags */
349 + __u32 direct_pkts; /* count of non shapped packets */
359 +struct tc_htb_xstats
363 + __u32 giants; /* too big packets (rate will not be accurate) */
370 +#define TC_CBQ_MAXPRIO 8
371 +#define TC_CBQ_MAXLEVEL 8
372 +#define TC_CBQ_DEF_EWMA 5
374 +struct tc_cbq_lssopt
376 + unsigned char change;
377 + unsigned char flags;
378 +#define TCF_CBQ_LSS_BOUNDED 1
379 +#define TCF_CBQ_LSS_ISOLATED 2
380 + unsigned char ewma_log;
381 + unsigned char level;
382 +#define TCF_CBQ_LSS_FLAGS 1
383 +#define TCF_CBQ_LSS_EWMA 2
384 +#define TCF_CBQ_LSS_MAXIDLE 4
385 +#define TCF_CBQ_LSS_MINIDLE 8
386 +#define TCF_CBQ_LSS_OFFTIME 0x10
387 +#define TCF_CBQ_LSS_AVPKT 0x20
394 +struct tc_cbq_wrropt
396 + unsigned char flags;
397 + unsigned char priority;
398 + unsigned char cpriority;
399 + unsigned char __reserved;
406 + unsigned char strategy;
407 +#define TC_CBQ_OVL_CLASSIC 0
408 +#define TC_CBQ_OVL_DELAY 1
409 +#define TC_CBQ_OVL_LOWPRIO 2
410 +#define TC_CBQ_OVL_DROP 3
411 +#define TC_CBQ_OVL_RCLASSIC 4
412 + unsigned char priority2;
416 +struct tc_cbq_police
418 + unsigned char police;
419 + unsigned char __res1;
420 + unsigned short __res2;
430 +struct tc_cbq_xstats
444 + TCA_CBQ_OVL_STRATEGY,
450 +#define TCA_CBQ_MAX TCA_CBQ_POLICE
452 +/* dsmark section */
456 + TCA_DSMARK_INDICES,
457 + TCA_DSMARK_DEFAULT_INDEX,
458 + TCA_DSMARK_SET_TC_INDEX,
463 +#define TCA_DSMARK_MAX TCA_DSMARK_VALUE
469 + TCA_ATM_FD, /* file/socket descriptor */
470 + TCA_ATM_PTR, /* pointer to descriptor - later */
471 + TCA_ATM_HDR, /* LL header */
472 + TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
473 + TCA_ATM_ADDR, /* PVC address (for output only) */
474 + TCA_ATM_STATE /* VC state (ATM_VS_*; for output only) */
477 +#define TCA_ATM_MAX TCA_ATM_STATE
481 #ifndef __LINUX_PKT_SCHED_H
482 #define __LINUX_PKT_SCHED_H
484 @@ -466,4 +872,116 @@
486 #define NETEM_DIST_SCALE 8192
490 +/* Other includes */
491 +#include <linux/if_ether.h>
493 +// A sub weight and of a class
494 +// All numbers are represented as parts of (2^64-1).
495 +struct tc_wrr_class_weight {
496 + __u64 val; // Current value (0 is not valid)
497 + __u64 decr; // Value pr bytes (2^64-1 is not valid)
498 + __u64 incr; // Value pr seconds (2^64-1 is not valid)
499 + __u64 min; // Minimal value (0 is not valid)
500 + __u64 max; // Minimal value (0 is not valid)
502 +// The time where the above information was correct:
506 +// Packet send when modifying a class:
507 +struct tc_wrr_class_modf {
508 + // Not-valid values are ignored.
509 + struct tc_wrr_class_weight weight1;
510 + struct tc_wrr_class_weight weight2;
513 +// Packet returned when quering a class:
514 +struct tc_wrr_class_stats {
515 + char used; // If this is false the information below is invalid
517 + struct tc_wrr_class_modf class_modf;
519 + unsigned char addr[ETH_ALEN];
520 + char usemac; // True if addr is a MAC address, else it is an IP address
521 + // (this value is only for convience, it is always the same
522 + // value as in the qdisc)
523 + int heappos; // Current heap position or 0 if not in heap
524 + __u64 penal_ls; // Penalty value in heap (ls)
525 + __u64 penal_ms; // Penalty value in heap (ms)
528 +// Qdisc-wide penalty information (boolean values - 2 not valid)
529 +struct tc_wrr_qdisc_weight {
530 + char weight_mode; // 0=No automatic change to weight
531 + // 1=Decrease normally
532 + // 2=Also multiply with number of machines
533 + // 3=Instead multiply with priority divided
534 + // with priority of the other.
538 +// Packet send when modifing a qdisc:
539 +struct tc_wrr_qdisc_modf {
540 + // Not-valid values are ignored:
541 + struct tc_wrr_qdisc_weight weight1;
542 + struct tc_wrr_qdisc_weight weight2;
545 +// Packet send when creating a qdisc:
546 +struct tc_wrr_qdisc_crt {
547 + struct tc_wrr_qdisc_modf qdisc_modf;
549 + char srcaddr; // 1=lookup source, 0=lookup destination
550 + char usemac; // 1=Classify on MAC addresses, 0=classify on IP
551 + char usemasq; // 1=Classify based on masqgrading - only valid
552 + // if usemac is zero
553 + int bands_max; // Maximal number of bands (i.e.: classes)
554 + int proxy_maxconn;// If differnt from 0 then we support proxy remapping
555 + // of packets. And this is the number of maximal
556 + // concurrent proxy connections.
559 +// Packet returned when quering a qdisc:
560 +struct tc_wrr_qdisc_stats {
561 + struct tc_wrr_qdisc_crt qdisc_crt;
563 + int nodes_in_heap; // Current number of bands wanting to send something
564 + int bands_cur; // Current number of bands used (i.e.: MAC/IP addresses seen)
565 + int bands_reused; // Number of times this band has been reused.
566 + int packets_requed; // Number of times packets have been requeued.
567 + __u64 priosum; // Sum of priorities in heap where 1 is 2^32
570 +struct tc_wrr_qdisc_modf_std {
571 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
572 + char proxy; // 0=This struct
574 + // Should we also change a class?
577 + // Only valid if change_class is false
578 + struct tc_wrr_qdisc_modf qdisc_modf;
580 + // Only valid if change_class is true:
581 + unsigned char addr[ETH_ALEN]; // Class to change (non-used bytes should be 0)
582 + struct tc_wrr_class_modf class_modf; // The change
585 +// Used for proxyrempping:
586 +struct tc_wrr_qdisc_modf_proxy {
587 + // This indicates which of the tc_wrr_qdisc_modf structers this is:
588 + char proxy; // 1=This struct
590 + // This is 1 if the proxyremap information should be reset
593 + // changec is the number of elements in changes.
596 + // This is an array of type ProxyRemapBlock:
601 Index: iproute-2.6.20-070313/ip/iproute.c
602 ===================================================================
603 --- iproute-2.6.20-070313.orig/ip/iproute.c 2007-06-09 13:53:56.000000000 +0100
604 +++ iproute-2.6.20-070313/ip/iproute.c 2007-06-09 13:53:57.000000000 +0100
606 fprintf(stderr, "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ]\n");
607 fprintf(stderr, " [ rtt NUMBER ] [ rttvar NUMBER ]\n");
608 fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n");
609 - fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ]\n");
610 + fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ hoplimit NUMBER ]\n");
611 fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
612 fprintf(stderr, " unreachable | prohibit | blackhole | nat ]\n");
613 fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
615 invarg("\"reordering\" value is invalid\n", *argv);
616 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_REORDERING, reord);
618 +#ifdef RTAX_HOPLIMIT
619 + } else if (strcmp(*argv, "hoplimit") == 0) {
622 + if (strcmp(*argv, "lock") == 0) {
623 + mxlock |= (1<<RTAX_HOPLIMIT);
626 + if (get_unsigned(&hoplim, *argv, 0))
627 + invarg("\"hoplimit\" value is invalid\n", *argv);
628 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplim);
630 +#ifdef RTAX_INITCWND
631 + } else if (strcmp(*argv, "initcwnd") == 0) {
634 + if (strcmp(*argv, "lock") == 0) {
635 + mxlock |= (1<<RTAX_HOPLIMIT);
638 + if (get_unsigned(&initcwnd, *argv, 0))
639 + invarg("\"initcwnd\" value is invalid\n", *argv);
640 + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITCWND, initcwnd);
642 } else if (strcmp(*argv, "rtt") == 0) {
645 Index: iproute-2.6.20-070313/ip/iptunnel.c
646 ===================================================================
647 --- iproute-2.6.20-070313.orig/ip/iptunnel.c 2007-06-09 13:53:56.000000000 +0100
648 +++ iproute-2.6.20-070313/ip/iptunnel.c 2007-06-09 13:53:57.000000000 +0100
651 p->i_flags |= GRE_KEY;
652 if (strchr(*argv, '.'))
653 - p->o_key = get_addr32(*argv);
654 + p->i_key = get_addr32(*argv);
656 if (get_unsigned(&uval, *argv, 0)<0) {
657 fprintf(stderr, "invalid value of \"ikey\"\n");
658 Index: iproute-2.6.20-070313/Makefile
659 ===================================================================
660 --- iproute-2.6.20-070313.orig/Makefile 2007-06-09 13:53:56.000000000 +0100
661 +++ iproute-2.6.20-070313/Makefile 2007-06-09 13:53:57.000000000 +0100
663 $(DESTDIR)$(DOCDIR)/examples
664 install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
665 $(DESTDIR)$(DOCDIR)/examples/diffserv
666 - @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
667 + @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
668 install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
669 install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
670 install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
675 - @for i in $(SUBDIRS) doc; \
676 + @set -e; for i in $(SUBDIRS) doc; \
677 do $(MAKE) $(MFLAGS) -C $$i clean; done
680 Index: iproute-2.6.20-070313/man/man8/ip.8
681 ===================================================================
682 --- iproute-2.6.20-070313.orig/man/man8/ip.8 2007-06-09 13:53:56.000000000 +0100
683 +++ iproute-2.6.20-070313/man/man8/ip.8 2007-06-09 13:53:57.000000000 +0100
684 @@ -1808,6 +1808,8 @@
685 .RB "IP Command reference " ip-cref.ps
687 .RB "IP tunnels " ip-cref.ps
689 +.RB http://lartc.org/
692 Original Manpage by Michail Litvak <mci@owl.openwall.com>
693 Index: iproute-2.6.20-070313/man/man8/tc.8
694 ===================================================================
695 --- iproute-2.6.20-070313.orig/man/man8/tc.8 2007-06-09 13:53:56.000000000 +0100
696 +++ iproute-2.6.20-070313/man/man8/tc.8 2007-06-09 13:53:57.000000000 +0100
700 .BR tc-pfifo_fast (8),
702 +.BR http://lartc.org/
705 Manpage maintained by bert hubert (ahu@ds9a.nl)
706 Index: iproute-2.6.20-070313/misc/Makefile
707 ===================================================================
708 --- iproute-2.6.20-070313.orig/misc/Makefile 2007-06-09 13:53:56.000000000 +0100
709 +++ iproute-2.6.20-070313/misc/Makefile 2007-06-09 13:53:57.000000000 +0100
711 SSOBJ=ss.o ssfilter.o
712 LNSTATOBJ=lnstat.o lnstat_util.o
714 -TARGETS=ss nstat ifstat rtacct arpd lnstat
715 +#TARGETS=ss nstat ifstat rtacct arpd lnstat
716 +TARGETS=ss nstat rtacct lnstat
720 Index: iproute-2.6.20-070313/misc/netbug
721 ===================================================================
722 --- iproute-2.6.20-070313.orig/misc/netbug 2007-06-09 13:53:56.000000000 +0100
723 +++ iproute-2.6.20-070313/misc/netbug 2007-06-09 13:53:57.000000000 +0100
729 echo -n "Send network configuration summary to [ENTER means kuznet@ms2.inr.ac.ru] "
730 IFS="" read mail || exit 1
731 [ -z "$mail" ] && mail=kuznet@ms2.inr.ac.ru
733 +netbug=`mktemp -d -t netbug.XXXXXX` || {echo "$0: Cannot create temporary directory" >&2; exit 1; }
734 +netbugtar=`tempfile -d $netbug --suffix=tar.gz` || {echo "$0: Cannot create temporary file" >&2; exit 1; }
736 +trap "/bin/rm -rf $netbug $netbugtar" 0 1 2 3 13 15
739 -while [ "$netbug" = "" ]; do
740 - netbug=`echo netbug.$$.$RANDOM`
741 - if [ -e /tmp/$netbug ]; then
746 -tmppath=/tmp/$netbug
748 -trap "rm -rf $tmppath $tmppath.tar.gz" 0 SIGINT
753 cat /proc/slabinfo > $tmppath/slabinfo
758 -tar c $netbug | gzip -9c > $netbug.tar.gz
760 -uuencode $netbug.tar.gz $netbug.tar.gz | mail -s $netbug "$mail"
761 +tar c $tmppath | gzip -9c > $netbugtar
762 +uuencode $netbugtar $netbugtar | mail -s $netbug "$mail"
764 echo "Sending to <$mail>; subject is $netbug"
766 Index: iproute-2.6.20-070313/tc/Makefile
767 ===================================================================
768 --- iproute-2.6.20-070313.orig/tc/Makefile 2007-06-09 13:53:56.000000000 +0100
769 +++ iproute-2.6.20-070313/tc/Makefile 2007-06-09 13:53:57.000000000 +0100
771 TCMODULES += q_prio.o
774 +TCMODULES += q_wrr.o
775 TCMODULES += f_rsvp.o
777 TCMODULES += f_route.o
778 Index: iproute-2.6.20-070313/tc/q_htb.c
779 ===================================================================
780 --- iproute-2.6.20-070313.orig/tc/q_htb.c 2007-06-09 13:53:56.000000000 +0100
781 +++ iproute-2.6.20-070313/tc/q_htb.c 2007-06-09 13:53:57.000000000 +0100
787 + * This program is free software; you can redistribute it and/or
788 + * modify it under the terms of the GNU General Public License
789 + * as published by the Free Software Foundation; either version
790 + * 2 of the License, or (at your option) any later version.
792 + * Authors: Martin Devera, devik@cdi.cz
801 +#include <sys/socket.h>
802 +#include <netinet/in.h>
803 +#include <arpa/inet.h>
807 +#include "tc_util.h"
809 +#define HTB_TC_VER 0x30003
810 +#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
811 +#error "Different kernel and TC HTB versions"
814 +static void explain(void)
816 + fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
817 + " default minor id of class to which unclassified packets are sent {0}\n"
818 + " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
819 + " debug string of 16 numbers each 0-3 {0}\n\n"
820 + "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
821 + " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
822 + " rate rate allocated to this class (class can still borrow)\n"
823 + " burst max bytes burst which can be accumulated during idle period {computed}\n"
824 + " ceil definite upper class rate (no borrows) {rate}\n"
825 + " cburst burst but for ceil {computed}\n"
826 + " mtu max packet size we create rate map for {1600}\n"
827 + " prio priority of leaf; lower are served first {0}\n"
828 + " quantum how much bytes to serve from leaf at once {use r2q}\n"
829 + "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
833 +static void explain1(char *arg)
835 + fprintf(stderr, "Illegal \"%s\"\n", arg);
840 +#define usage() return(-1)
842 +static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
844 + struct tc_htb_glob opt;
845 + struct rtattr *tail;
846 + unsigned i; char *p;
847 + memset(&opt,0,sizeof(opt));
848 + opt.rate2quantum = 10;
852 + if (matches(*argv, "r2q") == 0) {
854 + if (get_u32(&opt.rate2quantum, *argv, 10)) {
855 + explain1("r2q"); return -1;
857 + } else if (matches(*argv, "default") == 0) {
859 + if (get_u32(&opt.defcls, *argv, 16)) {
860 + explain1("default"); return -1;
862 + } else if (matches(*argv, "debug") == 0) {
863 + NEXT_ARG(); p = *argv;
864 + for (i=0; i<16; i++,p++) {
865 + if (*p<'0' || *p>'3') break;
866 + opt.debug |= (*p-'0')<<(2*i);
869 + fprintf(stderr, "What is \"%s\"?\n", *argv);
875 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
876 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
877 + addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
878 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
882 +static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
885 + struct tc_htb_opt opt;
886 + __u32 rtab[256],ctab[256];
887 + unsigned buffer=0,cbuffer=0;
888 + int cell_log=-1,ccell_log = -1,mtu;
889 + struct rtattr *tail;
891 + memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
894 + if (matches(*argv, "prio") == 0) {
896 + if (get_u32(&opt.prio, *argv, 10)) {
897 + explain1("prio"); return -1;
900 + } else if (matches(*argv, "mtu") == 0) {
902 + if (get_u32(&mtu, *argv, 10)) {
903 + explain1("mtu"); return -1;
905 + } else if (matches(*argv, "quantum") == 0) {
907 + if (get_u32(&opt.quantum, *argv, 10)) {
908 + explain1("quantum"); return -1;
910 + } else if (matches(*argv, "burst") == 0 ||
911 + strcmp(*argv, "buffer") == 0 ||
912 + strcmp(*argv, "maxburst") == 0) {
914 + if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
915 + explain1("buffer");
919 + } else if (matches(*argv, "cburst") == 0 ||
920 + strcmp(*argv, "cbuffer") == 0 ||
921 + strcmp(*argv, "cmaxburst") == 0) {
923 + if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
924 + explain1("cbuffer");
928 + } else if (strcmp(*argv, "ceil") == 0) {
930 + if (opt.ceil.rate) {
931 + fprintf(stderr, "Double \"ceil\" spec\n");
934 + if (get_rate(&opt.ceil.rate, *argv)) {
939 + } else if (strcmp(*argv, "rate") == 0) {
941 + if (opt.rate.rate) {
942 + fprintf(stderr, "Double \"rate\" spec\n");
945 + if (get_rate(&opt.rate.rate, *argv)) {
950 + } else if (strcmp(*argv, "help") == 0) {
954 + fprintf(stderr, "What is \"%s\"?\n", *argv);
964 + if (opt.rate.rate == 0) {
965 + fprintf(stderr, "\"rate\" is required.\n");
968 + /* if ceil params are missing, use the same as rate */
969 + if (!opt.ceil.rate) opt.ceil = opt.rate;
971 + /* compute minimal allowed burst from rate; mtu is added here to make
972 + sute that buffer is larger than mtu and to have some safeguard space */
973 + if (!buffer) buffer = opt.rate.rate / HZ + mtu;
974 + if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
976 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
977 + fprintf(stderr, "htb: failed to calculate rate table.\n");
980 + opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
981 + opt.rate.cell_log = cell_log;
983 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
984 + fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
987 + opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
988 + opt.ceil.cell_log = ccell_log;
990 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
991 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
992 + addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
993 + addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
994 + addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
995 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
999 +static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1001 + struct rtattr *tb[TCA_HTB_RTAB+1];
1002 + struct tc_htb_opt *hopt;
1003 + struct tc_htb_glob *gopt;
1004 + double buffer,cbuffer;
1011 + memset(tb, 0, sizeof(tb));
1012 + parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
1014 + if (tb[TCA_HTB_PARMS]) {
1016 + hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
1017 + if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
1019 + if (!hopt->level) {
1020 + fprintf(f, "prio %d ", (int)hopt->prio);
1022 + fprintf(f, "quantum %d ", (int)hopt->quantum);
1024 + fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
1025 + buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
1026 + fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
1027 + cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
1028 + if (show_details) {
1029 + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
1030 + 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
1031 + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
1032 + 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
1033 + fprintf(f, "level %d ", (int)hopt->level);
1035 + fprintf(f, "burst %s ", sprint_size(buffer, b1));
1036 + fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
1039 + fprintf(f, "buffer [%08x] cbuffer [%08x] ",
1040 + hopt->buffer,hopt->cbuffer);
1042 + if (tb[TCA_HTB_INIT]) {
1043 + gopt = RTA_DATA(tb[TCA_HTB_INIT]);
1044 + if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
1046 + fprintf(f, "r2q %d default %x direct_packets_stat %u",
1047 + gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
1049 + fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
1054 +static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1056 + struct tc_htb_xstats *st;
1057 + if (xstats == NULL)
1060 + if (RTA_PAYLOAD(xstats) < sizeof(*st))
1063 + st = RTA_DATA(xstats);
1064 + fprintf(f, " lended: %u borrowed: %u giants: %u\n",
1065 + st->lends,st->borrows,st->giants);
1066 + fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
1070 +struct qdisc_util htb_util = {
1076 + htb_parse_class_opt,
1080 +/* for testing of old one */
1081 +struct qdisc_util htb2_util = {
1087 + htb_parse_class_opt,
1094 Index: iproute-2.6.20-070313/tc/q_wrr.c
1095 ===================================================================
1096 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1097 +++ iproute-2.6.20-070313/tc/q_wrr.c 2007-06-09 13:53:57.000000000 +0100
1100 +#include <stdlib.h>
1101 +#include <unistd.h>
1102 +#include <syslog.h>
1104 +#include <sys/socket.h>
1105 +#include <netinet/in.h>
1106 +#include <arpa/inet.h>
1107 +#include <string.h>
1111 +#include "tc_util.h"
1113 +#define usage() return(-1)
1115 +// Returns -1 on error
1116 +static int wrr_parse_qdisc_weight(int argc, char** argv,
1117 + struct tc_wrr_qdisc_modf* opt) {
1120 + opt->weight1.weight_mode=-1;
1121 + opt->weight2.weight_mode=-1;
1123 + for(i=0; i<argc; i++) {
1124 + if(!memcmp(argv[i],"wmode1=",7)) {
1125 + opt->weight1.weight_mode=atoi(argv[i]+7);
1126 + } else if(!memcmp(argv[i],"wmode2=",7)) {
1127 + opt->weight2.weight_mode=atoi(argv[i]+7);
1129 + printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
1136 +static int wrr_parse_class_modf(int argc, char** argv,
1137 + struct tc_wrr_class_modf* modf) {
1141 + fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
1142 + fprintf(stderr, " The values can be floating point like 0.42 or divisions like 42/100\n");
1146 + // Set meaningless values:
1147 + modf->weight1.val=0;
1148 + modf->weight1.decr=(__u64)-1;
1149 + modf->weight1.incr=(__u64)-1;
1150 + modf->weight1.min=0;
1151 + modf->weight1.max=0;
1152 + modf->weight2.val=0;
1153 + modf->weight2.decr=(__u64)-1;
1154 + modf->weight2.incr=(__u64)-1;
1155 + modf->weight2.min=0;
1156 + modf->weight2.max=0;
1158 + // And read values:
1159 + for(i=0; i<argc; i++) {
1161 + char* name,*value1=0,*value2=0;
1162 + long double f_val1,f_val2=1,value;
1163 + if(strlen(argv[i])>=sizeof(arg)) {
1164 + fprintf(stderr,"Argument too long: %s\n",argv[i]);
1167 + strcpy(arg,argv[i]);
1169 + name=strtok(arg,"=");
1170 + if(name) value1=strtok(0,"/");
1171 + if(value1) value2=strtok(0,"");
1174 + fprintf(stderr,"No = found in argument: %s\n",argv[i]);
1178 + f_val1=atof(value1);
1179 + if(value2) f_val2=atof(value2);
1182 + fprintf(stderr,"Division by 0\n");
1186 + value=f_val1/f_val2;
1187 + if(value>1) value=1;
1188 + if(value<0) value=0;
1189 + value*=((__u64)-1);
1191 + // And find the value set
1192 + if(!strcmp(name,"weight1")) modf->weight1.val=value;
1193 + else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
1194 + else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
1195 + else if(!strcmp(name,"min1")) modf->weight1.min=value;
1196 + else if(!strcmp(name,"max1")) modf->weight1.max=value;
1197 + else if(!strcmp(name,"weight2")) modf->weight2.val=value;
1198 + else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
1199 + else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
1200 + else if(!strcmp(name,"min2")) modf->weight2.min=value;
1201 + else if(!strcmp(name,"max2")) modf->weight2.max=value;
1203 + fprintf(stderr,"illegal value: %s\n",name);
1211 +static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
1213 + if(n->nlmsg_flags & NLM_F_CREATE) {
1214 + // This is a create request:
1215 + struct tc_wrr_qdisc_crt opt;
1217 + int sour,dest,ip,mac,masq;
1220 + fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
1224 + // Read sour/dest:
1225 + memset(&opt,0,sizeof(opt));
1226 + sour=!strcmp(argv[0],"sour");
1227 + dest=!strcmp(argv[0],"dest");
1229 + if(!sour && !dest) {
1230 + fprintf(stderr,"sour or dest must be specified\n");
1235 + ip=!strcmp(argv[1],"ip");
1236 + mac=!strcmp(argv[1],"mac");
1237 + masq=!strcmp(argv[1],"masq");
1239 + if(!ip && !mac && !masq) {
1240 + fprintf(stderr,"ip, masq or mac must be specified\n");
1247 + opt.bands_max=atoi(argv[2]);
1249 + opt.proxy_maxconn=atoi(argv[3]);
1252 + if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
1253 + if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
1254 + if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
1256 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1258 + struct tc_wrr_qdisc_modf_std opt;
1261 + // This is a modify request:
1263 + fprintf(stderr,"... qdisc ... or ... class ...\n");
1267 + qdisc=!strcmp(argv[0],"qdisc");
1268 + class=!strcmp(argv[0],"class");
1270 + if(!qdisc && !class) {
1271 + fprintf(stderr,"qdisc or class must be specified\n");
1281 + opt.change_class=0;
1282 + if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
1284 + int a0,a1,a2,a3,a4=0,a5=0;
1286 + opt.change_class=1;
1289 + fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
1292 + memset(opt.addr,0,sizeof(opt.addr));
1294 + if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
1295 + (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
1296 + fprintf(stderr,"Wrong format of mac or ip address\n");
1300 + opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
1301 + opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
1303 + if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
1306 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1311 +static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
1312 + struct tc_wrr_class_modf opt;
1314 + memset(&opt,0,sizeof(opt));
1315 + if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
1317 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1321 +static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1323 + struct tc_wrr_qdisc_stats *qopt;
1328 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
1330 + qopt = RTA_DATA(opt);
1332 + fprintf(f,"\n (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
1333 + qopt->qdisc_crt.srcaddr ? "sour" : "dest",
1334 + qopt->qdisc_crt.usemac ? "mac" : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),
1335 + qopt->qdisc_crt.bands_max,
1337 + qopt->bands_reused
1340 + if(qopt->qdisc_crt.proxy_maxconn) {
1341 + fprintf(f," (proxy maxcon %i) (proxy curcon %i)\n",
1342 + qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
1345 + fprintf(f," (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
1346 + qopt->nodes_in_heap,
1347 + qopt->packets_requed,
1348 + qopt->priosum/((long double)((__u32)-1))
1351 + fprintf(f," (wmode1 %i) (wmode2 %i) \n",
1352 + qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
1353 + qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
1358 +static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
1359 + struct tc_wrr_class_stats *copt;
1360 + long double d=(__u64)-1;
1362 + if (opt == NULL) return 0;
1364 + if (RTA_PAYLOAD(opt) < sizeof(*copt))
1366 + copt = RTA_DATA(opt);
1369 + fprintf(f,"(unused)");
1373 + if(copt->usemac) {
1374 + fprintf(f,"\n (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
1375 + copt->addr[0],copt->addr[1],copt->addr[2],
1376 + copt->addr[3],copt->addr[4],copt->addr[5]);
1378 + fprintf(f,"\n (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
1381 + fprintf(f," (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
1382 + (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
1384 + (unsigned)(copt->penal_ms>>32),
1385 + (unsigned)(copt->penal_ms & 0xffffffffU),
1386 + (unsigned)(copt->penal_ls>>32),
1387 + (unsigned)(copt->penal_ls & 0xffffffffU)
1390 + fprintf(f," Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
1391 + copt->class_modf.weight1.val/d,
1392 + copt->class_modf.weight1.decr/d,
1393 + copt->class_modf.weight1.incr/d,
1394 + copt->class_modf.weight1.min/d,
1395 + copt->class_modf.weight1.max/d);
1397 + fprintf(f," Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
1398 + copt->class_modf.weight2.val/d,
1399 + copt->class_modf.weight2.decr/d,
1400 + copt->class_modf.weight2.incr/d,
1401 + copt->class_modf.weight2.min/d,
1402 + copt->class_modf.weight2.max/d);
1407 +static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1413 +struct qdisc_util wrr_qdisc_util = {
1415 + .parse_qopt = wrr_parse_opt,
1416 + .print_qopt = wrr_print_opt,
1417 + .print_xstats = wrr_print_xstats,
1418 + .parse_copt = wrr_parse_copt,
1419 + .print_copt = wrr_print_copt