1 Index: iproute2-2.6.25/doc/ip-cref.tex
2 ===================================================================
3 --- iproute2-2.6.25.orig/doc/ip-cref.tex 2008-05-01 00:17:55.000000000 +0100
4 +++ iproute2-2.6.25/doc/ip-cref.tex 2008-05-01 00:26:48.000000000 +0100
5 @@ -1315,6 +1315,19 @@ peers are allowed to send to us.
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|
25 @@ -2644,6 +2657,9 @@ http://www.cisco.com/univercd/cc/td/doc/
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: iproute2-2.6.25/doc/Makefile
36 ===================================================================
37 --- iproute2-2.6.25.orig/doc/Makefile 2008-05-01 00:17:55.000000000 +0100
38 +++ iproute2-2.6.25/doc/Makefile 2008-05-01 00:26:48.000000000 +0100
39 @@ -14,6 +14,7 @@ PAGESIZE=a4
42 HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
43 +TXTFILES=$(subst .sgml,.txt,$(shell echo *.sgml))
44 DVIFILES=$(subst .ps,.dvi,$(PSFILES))
47 @@ -23,6 +24,8 @@ pstwocol: $(PSFILES)
56 @@ -47,9 +50,12 @@ print: $(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: iproute2-2.6.25/include/linux/pkt_sched.h
71 ===================================================================
72 --- iproute2-2.6.25.orig/include/linux/pkt_sched.h 2008-05-01 00:17:55.000000000 +0100
73 +++ iproute2-2.6.25/include/linux/pkt_sched.h 2008-05-01 00:37:45.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 @@ -482,4 +888,116 @@ struct tc_netem_corrupt
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: iproute2-2.6.25/ip/iproute.c
602 ===================================================================
603 --- iproute2-2.6.25.orig/ip/iproute.c 2008-05-01 00:17:55.000000000 +0100
604 +++ iproute2-2.6.25/ip/iproute.c 2008-05-01 00:28:02.000000000 +0100
605 @@ -73,7 +73,7 @@ static void usage(void)
606 fprintf(stderr, " [ rtt TIME ] [ rttvar TIME ]\n");
607 fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n");
608 fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n");
609 - fprintf(stderr, " [ rto_min TIME ]\n");
610 + fprintf(stderr, " [ rto_min TIME ] [ hoplimit NUMBER ]\n");
611 fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
612 fprintf(stderr, " unreachable | prohibit | blackhole | nat ]\n");
613 fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
614 @@ -780,6 +780,30 @@ int iproute_modify(int cmd, unsigned fla
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: iproute2-2.6.25/ip/iptunnel.c
646 ===================================================================
647 --- iproute2-2.6.25.orig/ip/iptunnel.c 2008-05-01 00:17:55.000000000 +0100
648 +++ iproute2-2.6.25/ip/iptunnel.c 2008-05-01 00:26:48.000000000 +0100
649 @@ -134,7 +134,7 @@ static int parse_args(int argc, char **a
651 p->o_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 \"okey\"\n");
658 Index: iproute2-2.6.25/Makefile
659 ===================================================================
660 --- iproute2-2.6.25.orig/Makefile 2008-05-01 00:17:55.000000000 +0100
661 +++ iproute2-2.6.25/Makefile 2008-05-01 00:26:48.000000000 +0100
662 @@ -48,7 +48,7 @@ install: all
663 $(DESTDIR)$(DOCDIR)/examples
664 install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
665 $(DESTDIR)$(DOCDIR)/examples/diffserv
666 - @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
667 + @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
668 install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
669 install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
670 install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
671 @@ -65,7 +65,7 @@ snapshot:
675 - @for i in $(SUBDIRS) doc; \
676 + @set -e; for i in $(SUBDIRS) doc; \
677 do $(MAKE) $(MFLAGS) -C $$i clean; done
680 Index: iproute2-2.6.25/misc/Makefile
681 ===================================================================
682 --- iproute2-2.6.25.orig/misc/Makefile 2008-05-01 00:17:55.000000000 +0100
683 +++ iproute2-2.6.25/misc/Makefile 2008-05-01 00:26:48.000000000 +0100
685 SSOBJ=ss.o ssfilter.o
686 LNSTATOBJ=lnstat.o lnstat_util.o
688 -TARGETS=ss nstat ifstat rtacct arpd lnstat
689 +#TARGETS=ss nstat ifstat rtacct arpd lnstat
690 +TARGETS=ss nstat rtacct lnstat
694 Index: iproute2-2.6.25/tc/Makefile
695 ===================================================================
696 --- iproute2-2.6.25.orig/tc/Makefile 2008-05-01 00:17:55.000000000 +0100
697 +++ iproute2-2.6.25/tc/Makefile 2008-05-01 00:30:13.000000000 +0100
698 @@ -13,6 +13,7 @@ TCMODULES += q_tbf.o
701 TCMODULES += q_netem.o
702 +TCMODULES += q_wrr.o
703 TCMODULES += f_rsvp.o
705 TCMODULES += f_route.o
706 Index: iproute2-2.6.25/tc/q_htb.c
707 ===================================================================
708 --- iproute2-2.6.25.orig/tc/q_htb.c 2008-05-01 00:17:55.000000000 +0100
709 +++ iproute2-2.6.25/tc/q_htb.c 2008-05-01 00:37:50.000000000 +0100
715 + * This program is free software; you can redistribute it and/or
716 + * modify it under the terms of the GNU General Public License
717 + * as published by the Free Software Foundation; either version
718 + * 2 of the License, or (at your option) any later version.
720 + * Authors: Martin Devera, devik@cdi.cz
729 +#include <sys/socket.h>
730 +#include <netinet/in.h>
731 +#include <arpa/inet.h>
735 +#include "tc_util.h"
737 +#define HTB_TC_VER 0x30003
738 +#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
739 +#error "Different kernel and TC HTB versions"
742 +static void explain(void)
744 + fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
745 + " default minor id of class to which unclassified packets are sent {0}\n"
746 + " r2q DRR quantums are computed as rate in Bps/r2q {10}\n"
747 + " debug string of 16 numbers each 0-3 {0}\n\n"
748 + "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
749 + " [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
750 + " rate rate allocated to this class (class can still borrow)\n"
751 + " burst max bytes burst which can be accumulated during idle period {computed}\n"
752 + " ceil definite upper class rate (no borrows) {rate}\n"
753 + " cburst burst but for ceil {computed}\n"
754 + " mtu max packet size we create rate map for {1600}\n"
755 + " prio priority of leaf; lower are served first {0}\n"
756 + " quantum how much bytes to serve from leaf at once {use r2q}\n"
757 + "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
761 +static void explain1(char *arg)
763 + fprintf(stderr, "Illegal \"%s\"\n", arg);
768 +#define usage() return(-1)
770 +static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
772 + struct tc_htb_glob opt;
773 + struct rtattr *tail;
774 + unsigned i; char *p;
775 + memset(&opt,0,sizeof(opt));
776 + opt.rate2quantum = 10;
780 + if (matches(*argv, "r2q") == 0) {
782 + if (get_u32(&opt.rate2quantum, *argv, 10)) {
783 + explain1("r2q"); return -1;
785 + } else if (matches(*argv, "default") == 0) {
787 + if (get_u32(&opt.defcls, *argv, 16)) {
788 + explain1("default"); return -1;
790 + } else if (matches(*argv, "debug") == 0) {
791 + NEXT_ARG(); p = *argv;
792 + for (i=0; i<16; i++,p++) {
793 + if (*p<'0' || *p>'3') break;
794 + opt.debug |= (*p-'0')<<(2*i);
797 + fprintf(stderr, "What is \"%s\"?\n", *argv);
803 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
804 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
805 + addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
806 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
810 +static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
813 + struct tc_htb_opt opt;
814 + __u32 rtab[256],ctab[256];
815 + unsigned buffer=0,cbuffer=0;
816 + int cell_log=-1,ccell_log = -1,mtu;
817 + struct rtattr *tail;
819 + memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
822 + if (matches(*argv, "prio") == 0) {
824 + if (get_u32(&opt.prio, *argv, 10)) {
825 + explain1("prio"); return -1;
828 + } else if (matches(*argv, "mtu") == 0) {
830 + if (get_u32(&mtu, *argv, 10)) {
831 + explain1("mtu"); return -1;
833 + } else if (matches(*argv, "quantum") == 0) {
835 + if (get_u32(&opt.quantum, *argv, 10)) {
836 + explain1("quantum"); return -1;
838 + } else if (matches(*argv, "burst") == 0 ||
839 + strcmp(*argv, "buffer") == 0 ||
840 + strcmp(*argv, "maxburst") == 0) {
842 + if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
843 + explain1("buffer");
847 + } else if (matches(*argv, "cburst") == 0 ||
848 + strcmp(*argv, "cbuffer") == 0 ||
849 + strcmp(*argv, "cmaxburst") == 0) {
851 + if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
852 + explain1("cbuffer");
856 + } else if (strcmp(*argv, "ceil") == 0) {
858 + if (opt.ceil.rate) {
859 + fprintf(stderr, "Double \"ceil\" spec\n");
862 + if (get_rate(&opt.ceil.rate, *argv)) {
867 + } else if (strcmp(*argv, "rate") == 0) {
869 + if (opt.rate.rate) {
870 + fprintf(stderr, "Double \"rate\" spec\n");
873 + if (get_rate(&opt.rate.rate, *argv)) {
878 + } else if (strcmp(*argv, "help") == 0) {
882 + fprintf(stderr, "What is \"%s\"?\n", *argv);
892 + if (opt.rate.rate == 0) {
893 + fprintf(stderr, "\"rate\" is required.\n");
896 + /* if ceil params are missing, use the same as rate */
897 + if (!opt.ceil.rate) opt.ceil = opt.rate;
899 + /* compute minimal allowed burst from rate; mtu is added here to make
900 + sute that buffer is larger than mtu and to have some safeguard space */
901 + if (!buffer) buffer = opt.rate.rate / HZ + mtu;
902 + if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
904 + if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
905 + fprintf(stderr, "htb: failed to calculate rate table.\n");
908 + opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
909 + opt.rate.cell_log = cell_log;
911 + if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
912 + fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
915 + opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
916 + opt.ceil.cell_log = ccell_log;
918 + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
919 + addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
920 + addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
921 + addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
922 + addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
923 + tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
927 +static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
929 + struct rtattr *tb[TCA_HTB_RTAB+1];
930 + struct tc_htb_opt *hopt;
931 + struct tc_htb_glob *gopt;
932 + double buffer,cbuffer;
939 + memset(tb, 0, sizeof(tb));
940 + parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
942 + if (tb[TCA_HTB_PARMS]) {
944 + hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
945 + if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1;
947 + if (!hopt->level) {
948 + fprintf(f, "prio %d ", (int)hopt->prio);
950 + fprintf(f, "quantum %d ", (int)hopt->quantum);
952 + fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
953 + buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
954 + fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
955 + cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
956 + if (show_details) {
957 + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
958 + 1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
959 + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
960 + 1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
961 + fprintf(f, "level %d ", (int)hopt->level);
963 + fprintf(f, "burst %s ", sprint_size(buffer, b1));
964 + fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
967 + fprintf(f, "buffer [%08x] cbuffer [%08x] ",
968 + hopt->buffer,hopt->cbuffer);
970 + if (tb[TCA_HTB_INIT]) {
971 + gopt = RTA_DATA(tb[TCA_HTB_INIT]);
972 + if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
974 + fprintf(f, "r2q %d default %x direct_packets_stat %u",
975 + gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
977 + fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
982 +static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
984 + struct tc_htb_xstats *st;
985 + if (xstats == NULL)
988 + if (RTA_PAYLOAD(xstats) < sizeof(*st))
991 + st = RTA_DATA(xstats);
992 + fprintf(f, " lended: %u borrowed: %u giants: %u\n",
993 + st->lends,st->borrows,st->giants);
994 + fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
998 +struct qdisc_util htb_util = {
1004 + htb_parse_class_opt,
1008 +/* for testing of old one */
1009 +struct qdisc_util htb2_util = {
1015 + htb_parse_class_opt,
1022 Index: iproute2-2.6.25/tc/q_wrr.c
1023 ===================================================================
1024 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1025 +++ iproute2-2.6.25/tc/q_wrr.c 2008-05-01 00:37:17.000000000 +0100
1028 +#include <stdlib.h>
1029 +#include <unistd.h>
1030 +#include <syslog.h>
1032 +#include <sys/socket.h>
1033 +#include <netinet/in.h>
1034 +#include <arpa/inet.h>
1035 +#include <string.h>
1039 +#include "tc_util.h"
1041 +#define usage() return(-1)
1043 +// Returns -1 on error
1044 +static int wrr_parse_qdisc_weight(int argc, char** argv,
1045 + struct tc_wrr_qdisc_modf* opt) {
1048 + opt->weight1.weight_mode=-1;
1049 + opt->weight2.weight_mode=-1;
1051 + for(i=0; i<argc; i++) {
1052 + if(!memcmp(argv[i],"wmode1=",7)) {
1053 + opt->weight1.weight_mode=atoi(argv[i]+7);
1054 + } else if(!memcmp(argv[i],"wmode2=",7)) {
1055 + opt->weight2.weight_mode=atoi(argv[i]+7);
1057 + printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
1064 +static int wrr_parse_class_modf(int argc, char** argv,
1065 + struct tc_wrr_class_modf* modf) {
1069 + fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
1070 + fprintf(stderr, " The values can be floating point like 0.42 or divisions like 42/100\n");
1074 + // Set meaningless values:
1075 + modf->weight1.val=0;
1076 + modf->weight1.decr=(__u64)-1;
1077 + modf->weight1.incr=(__u64)-1;
1078 + modf->weight1.min=0;
1079 + modf->weight1.max=0;
1080 + modf->weight2.val=0;
1081 + modf->weight2.decr=(__u64)-1;
1082 + modf->weight2.incr=(__u64)-1;
1083 + modf->weight2.min=0;
1084 + modf->weight2.max=0;
1086 + // And read values:
1087 + for(i=0; i<argc; i++) {
1089 + char* name,*value1=0,*value2=0;
1090 + long double f_val1,f_val2=1,value;
1091 + if(strlen(argv[i])>=sizeof(arg)) {
1092 + fprintf(stderr,"Argument too long: %s\n",argv[i]);
1095 + strcpy(arg,argv[i]);
1097 + name=strtok(arg,"=");
1098 + if(name) value1=strtok(0,"/");
1099 + if(value1) value2=strtok(0,"");
1102 + fprintf(stderr,"No = found in argument: %s\n",argv[i]);
1106 + f_val1=atof(value1);
1107 + if(value2) f_val2=atof(value2);
1110 + fprintf(stderr,"Division by 0\n");
1114 + value=f_val1/f_val2;
1115 + if(value>1) value=1;
1116 + if(value<0) value=0;
1117 + value*=((__u64)-1);
1119 + // And find the value set
1120 + if(!strcmp(name,"weight1")) modf->weight1.val=value;
1121 + else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
1122 + else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
1123 + else if(!strcmp(name,"min1")) modf->weight1.min=value;
1124 + else if(!strcmp(name,"max1")) modf->weight1.max=value;
1125 + else if(!strcmp(name,"weight2")) modf->weight2.val=value;
1126 + else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
1127 + else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
1128 + else if(!strcmp(name,"min2")) modf->weight2.min=value;
1129 + else if(!strcmp(name,"max2")) modf->weight2.max=value;
1131 + fprintf(stderr,"illegal value: %s\n",name);
1139 +static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
1141 + if(n->nlmsg_flags & NLM_F_CREATE) {
1142 + // This is a create request:
1143 + struct tc_wrr_qdisc_crt opt;
1145 + int sour,dest,ip,mac,masq;
1148 + fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
1152 + // Read sour/dest:
1153 + memset(&opt,0,sizeof(opt));
1154 + sour=!strcmp(argv[0],"sour");
1155 + dest=!strcmp(argv[0],"dest");
1157 + if(!sour && !dest) {
1158 + fprintf(stderr,"sour or dest must be specified\n");
1163 + ip=!strcmp(argv[1],"ip");
1164 + mac=!strcmp(argv[1],"mac");
1165 + masq=!strcmp(argv[1],"masq");
1167 + if(!ip && !mac && !masq) {
1168 + fprintf(stderr,"ip, masq or mac must be specified\n");
1175 + opt.bands_max=atoi(argv[2]);
1177 + opt.proxy_maxconn=atoi(argv[3]);
1180 + if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
1181 + if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
1182 + if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
1184 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1186 + struct tc_wrr_qdisc_modf_std opt;
1189 + // This is a modify request:
1191 + fprintf(stderr,"... qdisc ... or ... class ...\n");
1195 + qdisc=!strcmp(argv[0],"qdisc");
1196 + class=!strcmp(argv[0],"class");
1198 + if(!qdisc && !class) {
1199 + fprintf(stderr,"qdisc or class must be specified\n");
1209 + opt.change_class=0;
1210 + if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
1212 + int a0,a1,a2,a3,a4=0,a5=0;
1214 + opt.change_class=1;
1217 + fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
1220 + memset(opt.addr,0,sizeof(opt.addr));
1222 + if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
1223 + (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
1224 + fprintf(stderr,"Wrong format of mac or ip address\n");
1228 + opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
1229 + opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
1231 + if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
1234 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1239 +static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
1240 + struct tc_wrr_class_modf opt;
1242 + memset(&opt,0,sizeof(opt));
1243 + if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
1245 + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
1249 +static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
1251 + struct tc_wrr_qdisc_stats *qopt;
1256 + if (RTA_PAYLOAD(opt) < sizeof(*qopt))
1258 + qopt = RTA_DATA(opt);
1260 + fprintf(f,"\n (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
1261 + qopt->qdisc_crt.srcaddr ? "sour" : "dest",
1262 + qopt->qdisc_crt.usemac ? "mac" : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),
1263 + qopt->qdisc_crt.bands_max,
1265 + qopt->bands_reused
1268 + if(qopt->qdisc_crt.proxy_maxconn) {
1269 + fprintf(f," (proxy maxcon %i) (proxy curcon %i)\n",
1270 + qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
1273 + fprintf(f," (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
1274 + qopt->nodes_in_heap,
1275 + qopt->packets_requed,
1276 + qopt->priosum/((long double)((__u32)-1))
1279 + fprintf(f," (wmode1 %i) (wmode2 %i) \n",
1280 + qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
1281 + qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
1286 +static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
1287 + struct tc_wrr_class_stats *copt;
1288 + long double d=(__u64)-1;
1290 + if (opt == NULL) return 0;
1292 + if (RTA_PAYLOAD(opt) < sizeof(*copt))
1294 + copt = RTA_DATA(opt);
1297 + fprintf(f,"(unused)");
1301 + if(copt->usemac) {
1302 + fprintf(f,"\n (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
1303 + copt->addr[0],copt->addr[1],copt->addr[2],
1304 + copt->addr[3],copt->addr[4],copt->addr[5]);
1306 + fprintf(f,"\n (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
1309 + fprintf(f," (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
1310 + (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
1312 + (unsigned)(copt->penal_ms>>32),
1313 + (unsigned)(copt->penal_ms & 0xffffffffU),
1314 + (unsigned)(copt->penal_ls>>32),
1315 + (unsigned)(copt->penal_ls & 0xffffffffU)
1318 + fprintf(f," Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
1319 + copt->class_modf.weight1.val/d,
1320 + copt->class_modf.weight1.decr/d,
1321 + copt->class_modf.weight1.incr/d,
1322 + copt->class_modf.weight1.min/d,
1323 + copt->class_modf.weight1.max/d);
1325 + fprintf(f," Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
1326 + copt->class_modf.weight2.val/d,
1327 + copt->class_modf.weight2.decr/d,
1328 + copt->class_modf.weight2.incr/d,
1329 + copt->class_modf.weight2.min/d,
1330 + copt->class_modf.weight2.max/d);
1335 +static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
1341 +struct qdisc_util wrr_qdisc_util = {
1343 + .parse_qopt = wrr_parse_opt,
1344 + .print_qopt = wrr_print_opt,
1345 + .print_xstats = wrr_print_xstats,
1346 + .parse_copt = wrr_parse_copt,
1347 + .print_copt = wrr_print_copt