source: freewrt/package/iproute2/patches/000-debian_patches_3.patch@ 6fc4520e

freewrt_1_0 freewrt_2_0
Last change on this file since 6fc4520e was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 39.8 KB
  • doc/ip-cref.tex

    diff -Nur iproute2-2.6.15-060110/doc/ip-cref.tex iproute2-2.6.15-060110-owrt/doc/ip-cref.tex
    old new  
    13221322    If it is not given, Linux uses the value selected with \verb|sysctl|
    13231323    variable \verb|net/ipv4/tcp_reordering|.
    13241324
     1325\item \verb|hoplimit NUMBER|
     1326
     1327--- [2.5.74+ only] Hop limit on the path to this destination. If it is not
     1328    given, Linux uses the value selected with \verb|sysctl| variable
     1329    \verb|net/ipv4/ip_default_ttl|.
     1330
     1331\item \verb|initcwnd NUMBER|
     1332
     1333--- [2.5.70+ only] Initial congestion window size when establishing
     1334    connections to this destination. This value is multiplied with the
     1335    MSS (``Maximal Segment Size'') for the connection to get the actual
     1336    window size. If it is not given (or set to zero), Linux uses the
     1337    values specified in~\cite{RFC2414}.
    13251338
    13261339
    13271340\item \verb|nexthop NEXTHOP|
     
    26512664\bibitem{RFC-DHCP} R.~Droms.
    26522665``Dynamic Host Configuration Protocol.'', RFC-2131
    26532666
     2667\bibitem{RFC2414}  M.~Allman, S.~Floyd, C.~Partridge.
     2668``Increasing TCP's Initial Window'', RFC-2414.
     2669
    26542670\end{thebibliography}
    26552671
    26562672
  • doc/Makefile

    diff -Nur iproute2-2.6.15-060110/doc/Makefile iproute2-2.6.15-060110-owrt/doc/Makefile
    old new  
    1414PAGESPERPAGE=2
    1515
    1616HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
     17TXTFILES=$(subst .sgml,.txt,$(shell echo *.sgml))
    1718DVIFILES=$(subst .ps,.dvi,$(PSFILES))
    1819
    1920
     
    2324
    2425html: $(HTMLFILES)
    2526
     27txt: $(TXTFILES)
     28
    2629dvi: $(DVIFILES)
    2730
    2831print: $(PSFILES)
     
    4750%.html: %.sgml
    4851        $(SGML2HTML) $<
    4952
     53%.txt: %.html
     54        lynx -nolist -dump $< > $@
     55
    5056install:
    5157        install -m 0644 $(shell echo *.tex) $(DESTDIR)$(DOCDIR)
    5258        install -m 0644 $(shell echo *.sgml) $(DESTDIR)$(DOCDIR)
    5359
    5460clean:
    55         rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html
     61        rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html $(TXTFILES)
  • include/linux/pkt_sched.h

    diff -Nur iproute2-2.6.15-060110/include/linux/pkt_sched.h iproute2-2.6.15-060110-owrt/include/linux/pkt_sched.h
    old new  
     1#if 0
     2#ifndef __LINUX_PKT_SCHED_H
     3#define __LINUX_PKT_SCHED_H
     4
     5/* Logical priority bands not depending on specific packet scheduler.
     6   Every scheduler will map them to real traffic classes, if it has
     7   no more precise mechanism to classify packets.
     8
     9   These numbers have no special meaning, though their coincidence
     10   with obsolete IPv6 values is not occasional :-). New IPv6 drafts
     11   preferred full anarchy inspired by diffserv group.
     12
     13   Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
     14   class, actually, as rule it will be handled with more care than
     15   filler or even bulk.
     16 */
     17
     18#define TC_PRIO_BESTEFFORT              0
     19#define TC_PRIO_FILLER                  1
     20#define TC_PRIO_BULK                    2
     21#define TC_PRIO_INTERACTIVE_BULK        4
     22#define TC_PRIO_INTERACTIVE             6
     23#define TC_PRIO_CONTROL                 7
     24
     25#define TC_PRIO_MAX                     15
     26
     27/* Generic queue statistics, available for all the elements.
     28   Particular schedulers may have also their private records.
     29 */
     30
     31struct tc_stats
     32{
     33        __u64   bytes;                  /* NUmber of enqueues bytes */
     34        __u32   packets;                /* Number of enqueued packets   */
     35        __u32   drops;                  /* Packets dropped because of lack of resources */
     36        __u32   overlimits;             /* Number of throttle events when this
     37                                         * flow goes out of allocated bandwidth */
     38        __u32   bps;                    /* Current flow byte rate */
     39        __u32   pps;                    /* Current flow packet rate */
     40        __u32   qlen;
     41        __u32   backlog;
     42#ifdef __KERNEL__
     43        spinlock_t *lock;
     44#endif
     45};
     46
     47struct tc_estimator
     48{
     49        char            interval;
     50        unsigned char   ewma_log;
     51};
     52
     53/* "Handles"
     54   ---------
     55
     56    All the traffic control objects have 32bit identifiers, or "handles".
     57
     58    They can be considered as opaque numbers from user API viewpoint,
     59    but actually they always consist of two fields: major and
     60    minor numbers, which are interpreted by kernel specially,
     61    that may be used by applications, though not recommended.
     62
     63    F.e. qdisc handles always have minor number equal to zero,
     64    classes (or flows) have major equal to parent qdisc major, and
     65    minor uniquely identifying class inside qdisc.
     66
     67    Macros to manipulate handles:
     68 */
     69
     70#define TC_H_MAJ_MASK (0xFFFF0000U)
     71#define TC_H_MIN_MASK (0x0000FFFFU)
     72#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
     73#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
     74#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
     75
     76#define TC_H_UNSPEC     (0U)
     77#define TC_H_ROOT       (0xFFFFFFFFU)
     78#define TC_H_INGRESS    (0xFFFFFFF1U)
     79
     80struct tc_ratespec
     81{
     82        unsigned char   cell_log;
     83        unsigned char   __reserved;
     84        unsigned short  feature;
     85        short           addend;
     86        unsigned short  mpu;
     87        __u32           rate;
     88};
     89
     90/* FIFO section */
     91
     92struct tc_fifo_qopt
     93{
     94        __u32   limit;  /* Queue length: bytes for bfifo, packets for pfifo */
     95};
     96
     97/* PRIO section */
     98
     99#define TCQ_PRIO_BANDS  16
     100
     101struct tc_prio_qopt
     102{
     103        int     bands;                  /* Number of bands */
     104        __u8    priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
     105};
     106
     107/* CSZ section */
     108
     109struct tc_csz_qopt
     110{
     111        int             flows;          /* Maximal number of guaranteed flows */
     112        unsigned char   R_log;          /* Fixed point position for round number */
     113        unsigned char   delta_log;      /* Log of maximal managed time interval */
     114        __u8            priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> CSZ band */
     115};
     116
     117struct tc_csz_copt
     118{
     119        struct tc_ratespec slice;
     120        struct tc_ratespec rate;
     121        struct tc_ratespec peakrate;
     122        __u32           limit;
     123        __u32           buffer;
     124        __u32           mtu;
     125};
     126
     127enum
     128{
     129        TCA_CSZ_UNSPEC,
     130        TCA_CSZ_PARMS,
     131        TCA_CSZ_RTAB,
     132        TCA_CSZ_PTAB,
     133};
     134
     135/* TBF section */
     136
     137struct tc_tbf_qopt
     138{
     139        struct tc_ratespec rate;
     140        struct tc_ratespec peakrate;
     141        __u32           limit;
     142        __u32           buffer;
     143        __u32           mtu;
     144};
     145
     146enum
     147{
     148        TCA_TBF_UNSPEC,
     149        TCA_TBF_PARMS,
     150        TCA_TBF_RTAB,
     151        TCA_TBF_PTAB,
     152};
     153
     154
     155/* TEQL section */
     156
     157/* TEQL does not require any parameters */
     158
     159/* SFQ section */
     160
     161struct tc_sfq_qopt
     162{
     163        unsigned        quantum;        /* Bytes per round allocated to flow */
     164        int             perturb_period; /* Period of hash perturbation */
     165        __u32           limit;          /* Maximal packets in queue */
     166        unsigned        divisor;        /* Hash divisor  */
     167        unsigned        flows;          /* Maximal number of flows  */
     168};
     169
     170/*
     171 *  NOTE: limit, divisor and flows are hardwired to code at the moment.
     172 *
     173 *      limit=flows=128, divisor=1024;
     174 *
     175 *      The only reason for this is efficiency, it is possible
     176 *      to change these parameters in compile time.
     177 */
     178
     179/* RED section */
     180
     181enum
     182{
     183        TCA_RED_UNSPEC,
     184        TCA_RED_PARMS,
     185        TCA_RED_STAB,
     186};
     187
     188struct tc_red_qopt
     189{
     190        __u32           limit;          /* HARD maximal queue length (bytes)    */
     191        __u32           qth_min;        /* Min average length threshold (bytes) */
     192        __u32           qth_max;        /* Max average length threshold (bytes) */
     193        unsigned char   Wlog;           /* log(W)               */
     194        unsigned char   Plog;           /* log(P_max/(qth_max-qth_min)) */
     195        unsigned char   Scell_log;      /* cell size for idle damping */
     196        unsigned char   flags;
     197#define TC_RED_ECN      1
     198};
     199
     200struct tc_red_xstats
     201{
     202        __u32           early;          /* Early drops */
     203        __u32           pdrop;          /* Drops due to queue limits */
     204        __u32           other;          /* Drops due to drop() calls */
     205        __u32           marked;         /* Marked packets */
     206};
     207
     208/* GRED section */
     209
     210#define MAX_DPs 16
     211
     212enum
     213{
     214       TCA_GRED_UNSPEC,
     215       TCA_GRED_PARMS,
     216       TCA_GRED_STAB,
     217       TCA_GRED_DPS,
     218};
     219
     220#define TCA_SET_OFF TCA_GRED_PARMS
     221struct tc_gred_qopt
     222{
     223       __u32           limit;          /* HARD maximal queue length (bytes)   
     224*/
     225       __u32           qth_min;        /* Min average length threshold (bytes)
     226*/
     227       __u32           qth_max;        /* Max average length threshold (bytes)
     228*/
     229       __u32           DP;             /* upto 2^32 DPs */
     230       __u32           backlog;       
     231       __u32           qave;   
     232       __u32           forced;
     233       __u32           early; 
     234       __u32           other; 
     235       __u32           pdrop; 
     236
     237       unsigned char   Wlog;           /* log(W)               */
     238       unsigned char   Plog;           /* log(P_max/(qth_max-qth_min)) */
     239       unsigned char   Scell_log;      /* cell size for idle damping */
     240       __u8            prio;            /* prio of this VQ */
     241       __u32    packets;
     242       __u32    bytesin;
     243};
     244/* gred setup */
     245struct tc_gred_sopt
     246{
     247       __u32           DPs;
     248       __u32           def_DP;
     249       __u8            grio;
     250};
     251
     252/* HTB section */
     253#define TC_HTB_NUMPRIO          8
     254#define TC_HTB_MAXDEPTH         8
     255#define TC_HTB_PROTOVER         3 /* the same as HTB and TC's major */
     256
     257struct tc_htb_opt
     258{
     259        struct tc_ratespec      rate;
     260        struct tc_ratespec      ceil;
     261        __u32   buffer;
     262        __u32   cbuffer;
     263        __u32   quantum;
     264        __u32   level;          /* out only */
     265        __u32   prio;
     266};
     267struct tc_htb_glob
     268{
     269        __u32 version;          /* to match HTB/TC */
     270        __u32 rate2quantum;     /* bps->quantum divisor */
     271        __u32 defcls;           /* default class number */
     272        __u32 debug;            /* debug flags */
     273
     274        /* stats */
     275        __u32 direct_pkts; /* count of non shapped packets */
     276};
     277enum
     278{
     279        TCA_HTB_UNSPEC,
     280        TCA_HTB_PARMS,
     281        TCA_HTB_INIT,
     282        TCA_HTB_CTAB,
     283        TCA_HTB_RTAB,
     284};
     285struct tc_htb_xstats
     286{
     287        __u32 lends;
     288        __u32 borrows;
     289        __u32 giants;   /* too big packets (rate will not be accurate) */
     290        __u32 tokens;
     291        __u32 ctokens;
     292};
     293
     294/* CBQ section */
     295
     296#define TC_CBQ_MAXPRIO          8
     297#define TC_CBQ_MAXLEVEL         8
     298#define TC_CBQ_DEF_EWMA         5
     299
     300struct tc_cbq_lssopt
     301{
     302        unsigned char   change;
     303        unsigned char   flags;
     304#define TCF_CBQ_LSS_BOUNDED     1
     305#define TCF_CBQ_LSS_ISOLATED    2
     306        unsigned char   ewma_log;
     307        unsigned char   level;
     308#define TCF_CBQ_LSS_FLAGS       1
     309#define TCF_CBQ_LSS_EWMA        2
     310#define TCF_CBQ_LSS_MAXIDLE     4
     311#define TCF_CBQ_LSS_MINIDLE     8
     312#define TCF_CBQ_LSS_OFFTIME     0x10
     313#define TCF_CBQ_LSS_AVPKT       0x20
     314        __u32           maxidle;
     315        __u32           minidle;
     316        __u32           offtime;
     317        __u32           avpkt;
     318};
     319
     320struct tc_cbq_wrropt
     321{
     322        unsigned char   flags;
     323        unsigned char   priority;
     324        unsigned char   cpriority;
     325        unsigned char   __reserved;
     326        __u32           allot;
     327        __u32           weight;
     328};
     329
     330struct tc_cbq_ovl
     331{
     332        unsigned char   strategy;
     333#define TC_CBQ_OVL_CLASSIC      0
     334#define TC_CBQ_OVL_DELAY        1
     335#define TC_CBQ_OVL_LOWPRIO      2
     336#define TC_CBQ_OVL_DROP         3
     337#define TC_CBQ_OVL_RCLASSIC     4
     338        unsigned char   priority2;
     339        __u32           penalty;
     340};
     341
     342struct tc_cbq_police
     343{
     344        unsigned char   police;
     345        unsigned char   __res1;
     346        unsigned short  __res2;
     347};
     348
     349struct tc_cbq_fopt
     350{
     351        __u32           split;
     352        __u32           defmap;
     353        __u32           defchange;
     354};
     355
     356struct tc_cbq_xstats
     357{
     358        __u32           borrows;
     359        __u32           overactions;
     360        __s32           avgidle;
     361        __s32           undertime;
     362};
     363
     364enum
     365{
     366        TCA_CBQ_UNSPEC,
     367        TCA_CBQ_LSSOPT,
     368        TCA_CBQ_WRROPT,
     369        TCA_CBQ_FOPT,
     370        TCA_CBQ_OVL_STRATEGY,
     371        TCA_CBQ_RATE,
     372        TCA_CBQ_RTAB,
     373        TCA_CBQ_POLICE,
     374};
     375
     376#define TCA_CBQ_MAX     TCA_CBQ_POLICE
     377
     378/* dsmark section */
     379
     380enum {
     381        TCA_DSMARK_UNSPEC,
     382        TCA_DSMARK_INDICES,
     383        TCA_DSMARK_DEFAULT_INDEX,
     384        TCA_DSMARK_SET_TC_INDEX,
     385        TCA_DSMARK_MASK,
     386        TCA_DSMARK_VALUE
     387};
     388
     389#define TCA_DSMARK_MAX TCA_DSMARK_VALUE
     390
     391/* ATM  section */
     392
     393enum {
     394        TCA_ATM_UNSPEC,
     395        TCA_ATM_FD,             /* file/socket descriptor */
     396        TCA_ATM_PTR,            /* pointer to descriptor - later */
     397        TCA_ATM_HDR,            /* LL header */
     398        TCA_ATM_EXCESS,         /* excess traffic class (0 for CLP)  */
     399        TCA_ATM_ADDR,           /* PVC address (for output only) */
     400        TCA_ATM_STATE           /* VC state (ATM_VS_*; for output only) */
     401};
     402
     403#define TCA_ATM_MAX     TCA_ATM_STATE
     404
     405#endif
     406#endif
    1407#ifndef __LINUX_PKT_SCHED_H
    2408#define __LINUX_PKT_SCHED_H
    3409
     
    466872
    467873#define NETEM_DIST_SCALE        8192
    468874
     875/* WRR section */
     876
     877/* Other includes */
     878#include <linux/if_ether.h>
     879
     880// A sub weight and of a class
     881// All numbers are represented as parts of (2^64-1).
     882struct tc_wrr_class_weight {
     883        __u64 val;      // Current value                        (0 is not valid)
     884        __u64 decr;     // Value pr bytes                       (2^64-1 is not valid)
     885        __u64 incr;     // Value pr seconds                     (2^64-1 is not valid)
     886        __u64 min;      // Minimal value                        (0 is not valid)
     887        __u64 max;      // Minimal value                        (0 is not valid)
     888
     889// The time where the above information was correct:
     890        time_t tim;
     891};
     892
     893// Packet send when modifying a class:
     894struct tc_wrr_class_modf {
     895        // Not-valid values are ignored.
     896        struct tc_wrr_class_weight weight1;
     897        struct tc_wrr_class_weight weight2;
     898};
     899
     900// Packet returned when quering a class:
     901struct tc_wrr_class_stats {
     902        char used;      // If this is false the information below is invalid
     903
     904        struct tc_wrr_class_modf class_modf;
     905
     906        unsigned char addr[ETH_ALEN];
     907        char usemac;    // True if addr is a MAC address, else it is an IP address
     908                        // (this value is only for convience, it is always the same
     909                        //  value as in the qdisc)
     910        int heappos;    // Current heap position or 0 if not in heap
     911        __u64 penal_ls; // Penalty value in heap (ls)
     912        __u64 penal_ms; // Penalty value in heap (ms)
     913};
     914
     915// Qdisc-wide penalty information (boolean values - 2 not valid)
     916struct tc_wrr_qdisc_weight {
     917        char weight_mode;       // 0=No automatic change to weight
     918                                // 1=Decrease normally
     919                                // 2=Also multiply with number of machines
     920                                // 3=Instead multiply with priority divided
     921                                //   with priority of the other.
     922                                // -1=no change
     923};
     924
     925// Packet send when modifing a qdisc:
     926struct tc_wrr_qdisc_modf {
     927        // Not-valid values are ignored:
     928        struct tc_wrr_qdisc_weight weight1;
     929        struct tc_wrr_qdisc_weight weight2;
     930};
     931
     932// Packet send when creating a qdisc:
     933struct tc_wrr_qdisc_crt {
     934        struct tc_wrr_qdisc_modf qdisc_modf;
     935
     936        char srcaddr;   // 1=lookup source, 0=lookup destination
     937        char usemac;    // 1=Classify on MAC addresses, 0=classify on IP
     938        char usemasq;   // 1=Classify based on masqgrading - only valid
     939                        //   if usemac is zero
     940        int bands_max;  // Maximal number of bands (i.e.: classes)
     941        int proxy_maxconn;// If differnt from 0 then we support proxy remapping
     942                        // of packets. And this is the number of maximal
     943                        // concurrent proxy connections.
     944};
     945
     946// Packet returned when quering a qdisc:
     947struct tc_wrr_qdisc_stats {
     948        struct tc_wrr_qdisc_crt qdisc_crt;
     949        int proxy_curconn;
     950        int nodes_in_heap;      // Current number of bands wanting to send something
     951        int bands_cur;          // Current number of bands used (i.e.: MAC/IP addresses seen)
     952        int bands_reused;       // Number of times this band has been reused.
     953        int packets_requed;     // Number of times packets have been requeued.
     954        __u64 priosum;          // Sum of priorities in heap where 1 is 2^32
     955};
     956
     957struct tc_wrr_qdisc_modf_std {
     958        // This indicates which of the tc_wrr_qdisc_modf structers this is:
     959        char proxy; // 0=This struct
     960
     961        // Should we also change a class?
     962        char change_class;
     963
     964        // Only valid if change_class is false
     965        struct tc_wrr_qdisc_modf qdisc_modf;
     966
     967        // Only valid if change_class is true:
     968        unsigned char addr[ETH_ALEN]; // Class to change (non-used bytes should be 0)
     969        struct tc_wrr_class_modf class_modf; // The change
     970};
     971
     972// Used for proxyrempping:
     973struct tc_wrr_qdisc_modf_proxy {
     974        // This indicates which of the tc_wrr_qdisc_modf structers this is:
     975        char proxy;     // 1=This struct
     976
     977        // This is 1 if the proxyremap information should be reset
     978        char reset;
     979
     980        // changec is the number of elements in changes.
     981        int changec;
     982
     983        // This is an array of type ProxyRemapBlock:
     984        long changes[0];
     985};
     986
    469987#endif
  • ip/iproute.c

    diff -Nur iproute2-2.6.15-060110/ip/iproute.c iproute2-2.6.15-060110-owrt/ip/iproute.c
    old new  
    6060        fprintf(stderr, "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ]\n");
    6161        fprintf(stderr, "           [ rtt NUMBER ] [ rttvar NUMBER ]\n");
    6262        fprintf(stderr, "           [ window NUMBER] [ cwnd NUMBER ] [ ssthresh NUMBER ]\n");
    63         fprintf(stderr, "           [ realms REALM ]\n");
     63        fprintf(stderr, "           [ realms REALM ] [ hoplimit NUMBER ] [ initcwnd NUMBER ]\n");
    6464        fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
    6565        fprintf(stderr, "          unreachable | prohibit | blackhole | nat ]\n");
    6666        fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
     
    497497                                "cwnd",
    498498                                "advmss",
    499499                                "reordering",
     500                                "hoplimit",
     501                                "initcwnd",
    500502                        };
    501503                        static int hz;
    502504                        if (mxrta[i] == NULL)
     
    764766                                invarg("\"reordering\" value is invalid\n", *argv);
    765767                        rta_addattr32(mxrta, sizeof(mxbuf), RTAX_REORDERING, reord);
    766768#endif
     769#ifdef RTAX_HOPLIMIT
     770                } else if (strcmp(*argv, "hoplimit") == 0) {
     771                        unsigned hoplim;
     772                        NEXT_ARG();
     773                        if (strcmp(*argv, "lock") == 0) {
     774                                mxlock |= (1<<RTAX_HOPLIMIT);
     775                                NEXT_ARG();
     776                        }
     777                        if (get_unsigned(&hoplim, *argv, 0))
     778                                invarg("\"hoplimit\" value is invalid\n", *argv);
     779                        rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplim);
     780#endif
     781#ifdef RTAX_INITCWND
     782                } else if (strcmp(*argv, "initcwnd") == 0) {
     783                        unsigned initcwnd;
     784                        NEXT_ARG();
     785                        if (strcmp(*argv, "lock") == 0) {
     786                                mxlock |= (1<<RTAX_HOPLIMIT);
     787                                NEXT_ARG();
     788                        }
     789                        if (get_unsigned(&initcwnd, *argv, 0))
     790                                invarg("\"initcwnd\" value is invalid\n", *argv);
     791                        rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITCWND, initcwnd);
     792#endif
    767793                } else if (strcmp(*argv, "rtt") == 0) {
    768794                        unsigned rtt;
    769795                        NEXT_ARG();
  • ip/iptunnel.c

    diff -Nur iproute2-2.6.15-060110/ip/iptunnel.c iproute2-2.6.15-060110-owrt/ip/iptunnel.c
    old new  
    225225                        NEXT_ARG();
    226226                        p->i_flags |= GRE_KEY;
    227227                        if (strchr(*argv, '.'))
    228                                 p->o_key = get_addr32(*argv);
     228                                p->i_key = get_addr32(*argv);
    229229                        else {
    230230                                if (get_unsigned(&uval, *argv, 0)<0) {
    231231                                        fprintf(stderr, "invalid value of \"ikey\"\n");
  • iproute2-2.6.

    diff -Nur iproute2-2.6.15-060110/Makefile iproute2-2.6.15-060110-owrt/Makefile
    old new  
    3232LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
    3333
    3434all: Config
    35         @for i in $(SUBDIRS); \
     35        @set -e; for i in $(SUBDIRS); \
    3636        do $(MAKE) $(MFLAGS) -C $$i; done
    3737
    3838Config:
     
    4747                $(DESTDIR)$(DOCDIR)/examples
    4848        install -m 0644 $(shell find examples/diffserv -maxdepth 1 -type f) \
    4949                $(DESTDIR)$(DOCDIR)/examples/diffserv
    50         @for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
     50        @set -e; for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
    5151        install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
    5252        install -m 0755 -d $(DESTDIR)$(MANDIR)/man8
    5353        install -m 0644 $(shell find man/man8 -maxdepth 1 -type f) $(DESTDIR)$(MANDIR)/man8
     
    5858
    5959clean:
    6060        rm -f cscope.*
    61         @for i in $(SUBDIRS) doc; \
     61        @set -e; for i in $(SUBDIRS) doc; \
    6262        do $(MAKE) $(MFLAGS) -C $$i clean; done
    6363
    6464clobber: clean
  • man/man8/ip.8

    diff -Nur iproute2-2.6.15-060110/man/man8/ip.8 iproute2-2.6.15-060110-owrt/man/man8/ip.8
    old new  
    18081808.RB "IP Command reference " ip-cref.ps
    18091809.br
    18101810.RB "IP tunnels " ip-cref.ps
     1811.br
     1812.RB http://lartc.org/
    18111813
    18121814.SH AUTHOR
    18131815Original Manpage  by Michail Litvak <mci@owl.openwall.com>
  • man/man8/tc.8

    diff -Nur iproute2-2.6.15-060110/man/man8/tc.8 iproute2-2.6.15-060110-owrt/man/man8/tc.8
    old new  
    341341.BR tc-pfifo (8),
    342342.BR tc-bfifo (8),
    343343.BR tc-pfifo_fast (8),
    344 .BR tc-filters (8)
     344.BR http://lartc.org/
    345345
    346346.SH AUTHOR
    347347Manpage maintained by bert hubert (ahu@ds9a.nl)
  • misc/Makefile

    diff -Nur iproute2-2.6.15-060110/misc/Makefile iproute2-2.6.15-060110-owrt/misc/Makefile
    old new  
    11SSOBJ=ss.o ssfilter.o
    22LNSTATOBJ=lnstat.o lnstat_util.o
    33
    4 TARGETS=ss nstat ifstat rtacct arpd lnstat
     4#TARGETS=ss nstat ifstat rtacct arpd lnstat
     5TARGETS=ss nstat rtacct lnstat
    56
    67include ../Config
    78
  • iproute2-2.6.

    diff -Nur iproute2-2.6.15-060110/misc/netbug iproute2-2.6.15-060110-owrt/misc/netbug
    old new  
    11#! /bin/bash
    22
     3set -e
     4
    35echo -n "Send network configuration summary to [ENTER means kuznet@ms2.inr.ac.ru] "
    46IFS="" read mail || exit 1
    57[ -z "$mail" ] && mail=kuznet@ms2.inr.ac.ru
    68
     9netbug=`mktemp -d -t netbug.XXXXXX` || {echo "$0: Cannot create temporary directory" >&2; exit 1;  }
     10netbugtar=`tempfile -d $netbug --suffix=tar.gz` || {echo "$0: Cannot create temporary file" >&2; exit 1;  }
     11tmppath=$netbug
     12trap "/bin/rm -rf $netbug $netbugtar" 0 1 2 3 13 15
    713
    8 netbug=""
    9 while [ "$netbug" = "" ]; do
    10         netbug=`echo netbug.$$.$RANDOM`
    11         if [ -e /tmp/$netbug ]; then
    12                 netbug=""
    13         fi
    14 done
    15 
    16 tmppath=/tmp/$netbug
    17 
    18 trap "rm -rf $tmppath $tmppath.tar.gz" 0 SIGINT
    19 
    20 mkdir $tmppath
    2114mkdir $tmppath/net
    2215
    2316cat /proc/slabinfo > $tmppath/slabinfo
     
    4437fi
    4538
    4639cd /tmp
    47 tar c $netbug | gzip -9c > $netbug.tar.gz
    48 
    49 uuencode $netbug.tar.gz $netbug.tar.gz | mail -s $netbug "$mail"
     40tar c $tmppath | gzip -9c > $netbugtar
     41uuencode $netbugtar $netbugtar | mail -s $netbug "$mail"
    5042
    5143echo "Sending to <$mail>; subject is $netbug"
    5244
  • iproute2-2.6.

    diff -Nur iproute2-2.6.15-060110/tc/Makefile iproute2-2.6.15-060110-owrt/tc/Makefile
    old new  
    1111TCMODULES += q_prio.o
    1212TCMODULES += q_tbf.o
    1313TCMODULES += q_cbq.o
     14TCMODULES += q_wrr.o
    1415TCMODULES += f_rsvp.o
    1516TCMODULES += f_u32.o
    1617TCMODULES += f_route.o
  • iproute2-2.6.

    diff -Nur iproute2-2.6.15-060110/tc/q_htb.c iproute2-2.6.15-060110-owrt/tc/q_htb.c
    old new  
     1#if 0
     2/*
     3 * q_htb.c              HTB.
     4 *
     5 *              This program is free software; you can redistribute it and/or
     6 *              modify it under the terms of the GNU General Public License
     7 *              as published by the Free Software Foundation; either version
     8 *              2 of the License, or (at your option) any later version.
     9 *
     10 * Authors:     Martin Devera, devik@cdi.cz
     11 *
     12 */
     13
     14#include <stdio.h>
     15#include <stdlib.h>
     16#include <unistd.h>
     17#include <syslog.h>
     18#include <fcntl.h>
     19#include <sys/socket.h>
     20#include <netinet/in.h>
     21#include <arpa/inet.h>
     22#include <string.h>
     23
     24#include "utils.h"
     25#include "tc_util.h"
     26
     27#define HTB_TC_VER 0x30003
     28#if HTB_TC_VER >> 16 != TC_HTB_PROTOVER
     29#error "Different kernel and TC HTB versions"
     30#endif
     31
     32static void explain(void)
     33{
     34        fprintf(stderr, "Usage: ... qdisc add ... htb [default N] [r2q N]\n"
     35                " default  minor id of class to which unclassified packets are sent {0}\n"
     36                " r2q      DRR quantums are computed as rate in Bps/r2q {10}\n"
     37                " debug    string of 16 numbers each 0-3 {0}\n\n"
     38                "... class add ... htb rate R1 burst B1 [prio P] [slot S] [pslot PS]\n"
     39                "                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]\n"
     40                " rate     rate allocated to this class (class can still borrow)\n"
     41                " burst    max bytes burst which can be accumulated during idle period {computed}\n"
     42                " ceil     definite upper class rate (no borrows) {rate}\n"
     43                " cburst   burst but for ceil {computed}\n"
     44                " mtu      max packet size we create rate map for {1600}\n"
     45                " prio     priority of leaf; lower are served first {0}\n"
     46                " quantum  how much bytes to serve from leaf at once {use r2q}\n"
     47                "\nTC HTB version %d.%d\n",HTB_TC_VER>>16,HTB_TC_VER&0xffff
     48                );
     49}
     50
     51static void explain1(char *arg)
     52{
     53    fprintf(stderr, "Illegal \"%s\"\n", arg);
     54    explain();
     55}
     56
     57
     58#define usage() return(-1)
     59
     60static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
     61{
     62        struct tc_htb_glob opt;
     63        struct rtattr *tail;
     64        unsigned i; char *p;
     65        memset(&opt,0,sizeof(opt));
     66        opt.rate2quantum = 10;
     67        opt.version = 3;
     68
     69        while (argc > 0) {
     70                if (matches(*argv, "r2q") == 0) {
     71                    NEXT_ARG();
     72                    if (get_u32(&opt.rate2quantum, *argv, 10)) {
     73                        explain1("r2q"); return -1;
     74                    }
     75                } else if (matches(*argv, "default") == 0) {
     76                    NEXT_ARG();
     77                    if (get_u32(&opt.defcls, *argv, 16)) {
     78                        explain1("default"); return -1;
     79                    }
     80                } else if (matches(*argv, "debug") == 0) {
     81                    NEXT_ARG(); p = *argv;
     82                    for (i=0; i<16; i++,p++) {
     83                        if (*p<'0' || *p>'3') break;
     84                        opt.debug |= (*p-'0')<<(2*i);
     85                    }
     86                } else {
     87                        fprintf(stderr, "What is \"%s\"?\n", *argv);
     88                        explain();
     89                        return -1;
     90                }
     91                argc--; argv++;
     92        }
     93        tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
     94        addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
     95        addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
     96        tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
     97        return 0;
     98}
     99
     100static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
     101{
     102        int ok=0;
     103        struct tc_htb_opt opt;
     104        __u32 rtab[256],ctab[256];
     105        unsigned buffer=0,cbuffer=0;
     106        int cell_log=-1,ccell_log = -1,mtu;
     107        struct rtattr *tail;
     108
     109        memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */
     110
     111        while (argc > 0) {
     112                if (matches(*argv, "prio") == 0) {
     113                        NEXT_ARG();
     114                        if (get_u32(&opt.prio, *argv, 10)) {
     115                                explain1("prio"); return -1;
     116                        }
     117                        ok++;
     118                } else if (matches(*argv, "mtu") == 0) {
     119                        NEXT_ARG();
     120                        if (get_u32(&mtu, *argv, 10)) {
     121                                explain1("mtu"); return -1;
     122                        }
     123                } else if (matches(*argv, "quantum") == 0) {
     124                        NEXT_ARG();
     125                        if (get_u32(&opt.quantum, *argv, 10)) {
     126                                explain1("quantum"); return -1;
     127                        }
     128                } else if (matches(*argv, "burst") == 0 ||
     129                        strcmp(*argv, "buffer") == 0 ||
     130                        strcmp(*argv, "maxburst") == 0) {
     131                        NEXT_ARG();
     132                        if (get_size_and_cell(&buffer, &cell_log, *argv) < 0) {
     133                                explain1("buffer");
     134                                return -1;
     135                        }
     136                        ok++;
     137                } else if (matches(*argv, "cburst") == 0 ||
     138                        strcmp(*argv, "cbuffer") == 0 ||
     139                        strcmp(*argv, "cmaxburst") == 0) {
     140                        NEXT_ARG();
     141                        if (get_size_and_cell(&cbuffer, &ccell_log, *argv) < 0) {
     142                                explain1("cbuffer");
     143                                return -1;
     144                        }
     145                        ok++;
     146                } else if (strcmp(*argv, "ceil") == 0) {
     147                        NEXT_ARG();
     148                        if (opt.ceil.rate) {
     149                                fprintf(stderr, "Double \"ceil\" spec\n");
     150                                return -1;
     151                        }
     152                        if (get_rate(&opt.ceil.rate, *argv)) {
     153                                explain1("ceil");
     154                                return -1;
     155                        }
     156                        ok++;
     157                } else if (strcmp(*argv, "rate") == 0) {
     158                        NEXT_ARG();
     159                        if (opt.rate.rate) {
     160                                fprintf(stderr, "Double \"rate\" spec\n");
     161                                return -1;
     162                        }
     163                        if (get_rate(&opt.rate.rate, *argv)) {
     164                                explain1("rate");
     165                                return -1;
     166                        }
     167                        ok++;
     168                } else if (strcmp(*argv, "help") == 0) {
     169                        explain();
     170                        return -1;
     171                } else {
     172                        fprintf(stderr, "What is \"%s\"?\n", *argv);
     173                        explain();
     174                        return -1;
     175                }
     176                argc--; argv++;
     177        }
     178
     179/*      if (!ok)
     180                return 0;*/
     181
     182        if (opt.rate.rate == 0) {
     183                fprintf(stderr, "\"rate\" is required.\n");
     184                return -1;
     185        }
     186        /* if ceil params are missing, use the same as rate */
     187        if (!opt.ceil.rate) opt.ceil = opt.rate;
     188
     189        /* compute minimal allowed burst from rate; mtu is added here to make
     190           sute that buffer is larger than mtu and to have some safeguard space */
     191        if (!buffer) buffer = opt.rate.rate / HZ + mtu;
     192        if (!cbuffer) cbuffer = opt.ceil.rate / HZ + mtu;
     193
     194        if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, 0)) < 0) {
     195                fprintf(stderr, "htb: failed to calculate rate table.\n");
     196                return -1;
     197        }
     198        opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
     199        opt.rate.cell_log = cell_log;
     200       
     201        if ((ccell_log = tc_calc_rtable(opt.ceil.rate, ctab, cell_log, mtu, 0)) < 0) {
     202                fprintf(stderr, "htb: failed to calculate ceil rate table.\n");
     203                return -1;
     204        }
     205        opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
     206        opt.ceil.cell_log = ccell_log;
     207
     208        tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
     209        addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
     210        addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
     211        addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
     212        addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
     213        tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
     214        return 0;
     215}
     216
     217static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
     218{
     219        struct rtattr *tb[TCA_HTB_RTAB+1];
     220        struct tc_htb_opt *hopt;
     221        struct tc_htb_glob *gopt;
     222        double buffer,cbuffer;
     223        SPRINT_BUF(b1);
     224        SPRINT_BUF(b2);
     225
     226        if (opt == NULL)
     227                return 0;
     228
     229        memset(tb, 0, sizeof(tb));
     230        parse_rtattr(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
     231
     232        if (tb[TCA_HTB_PARMS]) {
     233
     234            hopt = RTA_DATA(tb[TCA_HTB_PARMS]);
     235            if (RTA_PAYLOAD(tb[TCA_HTB_PARMS])  < sizeof(*hopt)) return -1;
     236
     237                if (!hopt->level) {
     238                        fprintf(f, "prio %d ", (int)hopt->prio);
     239                        if (show_details)
     240                                fprintf(f, "quantum %d ", (int)hopt->quantum);
     241                }
     242            fprintf(f, "rate %s ", sprint_rate(hopt->rate.rate, b1));
     243            buffer = ((double)hopt->rate.rate*tc_core_tick2usec(hopt->buffer))/1000000;
     244            fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1));
     245            cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000;
     246            if (show_details) {
     247                fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
     248                        1<<hopt->rate.cell_log, sprint_size(hopt->rate.mpu, b2));
     249                fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1),
     250                        1<<hopt->ceil.cell_log, sprint_size(hopt->ceil.mpu, b2));
     251                fprintf(f, "level %d ", (int)hopt->level);
     252            } else {
     253                fprintf(f, "burst %s ", sprint_size(buffer, b1));
     254                fprintf(f, "cburst %s ", sprint_size(cbuffer, b1));
     255            }
     256            if (show_raw)
     257                fprintf(f, "buffer [%08x] cbuffer [%08x] ",
     258                        hopt->buffer,hopt->cbuffer);
     259        }
     260        if (tb[TCA_HTB_INIT]) {
     261            gopt = RTA_DATA(tb[TCA_HTB_INIT]);
     262            if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
     263
     264            fprintf(f, "r2q %d default %x direct_packets_stat %u",
     265                    gopt->rate2quantum,gopt->defcls,gopt->direct_pkts);
     266                if (show_details)
     267                        fprintf(f," ver %d.%d",gopt->version >> 16,gopt->version & 0xffff);
     268        }
     269        return 0;
     270}
     271
     272static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
     273{
     274        struct tc_htb_xstats *st;
     275        if (xstats == NULL)
     276                return 0;
     277
     278        if (RTA_PAYLOAD(xstats) < sizeof(*st))
     279                return -1;
     280
     281        st = RTA_DATA(xstats);
     282        fprintf(f, " lended: %u borrowed: %u giants: %u\n",
     283                st->lends,st->borrows,st->giants);
     284        fprintf(f, " tokens: %d ctokens: %d\n", st->tokens,st->ctokens);
     285        return 0;
     286}
     287
     288struct qdisc_util htb_util = {
     289        NULL,
     290        "htb",
     291        htb_parse_opt,
     292        htb_print_opt,
     293        htb_print_xstats,
     294        htb_parse_class_opt,
     295        htb_print_opt,
     296};
     297
     298/* for testing of old one */
     299struct qdisc_util htb2_util = {
     300        NULL,
     301        "htb2",
     302        htb_parse_opt,
     303        htb_print_opt,
     304        htb_print_xstats,
     305        htb_parse_class_opt,
     306        htb_print_opt,
     307};
     308#endif
    1309/*
    2310 * q_htb.c              HTB.
    3311 *
  • iproute2-2.6.

    diff -Nur iproute2-2.6.15-060110/tc/q_wrr.c iproute2-2.6.15-060110-owrt/tc/q_wrr.c
    old new  
     1#include <stdio.h>
     2#include <stdlib.h>
     3#include <unistd.h>
     4#include <syslog.h>
     5#include <fcntl.h>
     6#include <sys/socket.h>
     7#include <netinet/in.h>
     8#include <arpa/inet.h>
     9#include <string.h>
     10#include <math.h>
     11
     12#include "utils.h"
     13#include "tc_util.h"
     14
     15#define usage() return(-1)
     16
     17// Returns -1 on error
     18static int wrr_parse_qdisc_weight(int argc, char** argv,
     19                              struct tc_wrr_qdisc_modf* opt) {
     20  int i;
     21 
     22  opt->weight1.weight_mode=-1;
     23  opt->weight2.weight_mode=-1;
     24 
     25  for(i=0; i<argc; i++) { 
     26    if(!memcmp(argv[i],"wmode1=",7)) {
     27      opt->weight1.weight_mode=atoi(argv[i]+7);           
     28    } else if(!memcmp(argv[i],"wmode2=",7)) {
     29      opt->weight2.weight_mode=atoi(argv[i]+7);
     30    } else {
     31      printf("Usage: ... [wmode1=0|1|2|3] [wmode2=0|1|2|3]\n");
     32      return -1;
     33    }
     34  }
     35  return 0;
     36}
     37
     38static int wrr_parse_class_modf(int argc, char** argv,
     39                                struct tc_wrr_class_modf* modf) {
     40  int i;
     41 
     42  if(argc<1) {
     43    fprintf(stderr, "Usage: ... [weight1=val] [decr1=val] [incr1=val] [min1=val] [max1=val] [val2=val] ...\n");
     44    fprintf(stderr, "  The values can be floating point like 0.42 or divisions like 42/100\n");
     45    return -1;
     46  }
     47 
     48  // Set meaningless values:
     49  modf->weight1.val=0;
     50  modf->weight1.decr=(__u64)-1;
     51  modf->weight1.incr=(__u64)-1;
     52  modf->weight1.min=0;
     53  modf->weight1.max=0;
     54  modf->weight2.val=0;
     55  modf->weight2.decr=(__u64)-1;
     56  modf->weight2.incr=(__u64)-1;
     57  modf->weight2.min=0;
     58  modf->weight2.max=0;
     59 
     60  // And read values:
     61  for(i=0; i<argc; i++) {
     62    char arg[80];
     63    char* name,*value1=0,*value2=0;
     64    long double f_val1,f_val2=1,value;
     65    if(strlen(argv[i])>=sizeof(arg)) {
     66      fprintf(stderr,"Argument too long: %s\n",argv[i]);
     67      return -1;
     68    }
     69    strcpy(arg,argv[i]);
     70   
     71    name=strtok(arg,"=");
     72    if(name) value1=strtok(0,"/");
     73    if(value1) value2=strtok(0,"");
     74   
     75    if(!value1) {
     76      fprintf(stderr,"No = found in argument: %s\n",argv[i]);
     77      return -1;
     78    }
     79   
     80    f_val1=atof(value1);
     81    if(value2) f_val2=atof(value2);   
     82   
     83    if(f_val2==0)  {
     84      fprintf(stderr,"Division by 0\n");
     85      return -1;
     86    }
     87       
     88    value=f_val1/f_val2;   
     89    if(value>1) value=1;
     90    if(value<0) value=0;           
     91    value*=((__u64)-1);
     92   
     93    // And find the value set
     94    if(!strcmp(name,"weight1"))    modf->weight1.val=value;
     95    else if(!strcmp(name,"decr1")) modf->weight1.decr=value;
     96    else if(!strcmp(name,"incr1")) modf->weight1.incr=value;
     97    else if(!strcmp(name,"min1"))  modf->weight1.min=value;
     98    else if(!strcmp(name,"max1"))  modf->weight1.max=value;
     99    else if(!strcmp(name,"weight2")) modf->weight2.val=value;
     100    else if(!strcmp(name,"decr2")) modf->weight2.decr=value;
     101    else if(!strcmp(name,"incr2")) modf->weight2.incr=value;
     102    else if(!strcmp(name,"min2"))  modf->weight2.min=value;
     103    else if(!strcmp(name,"max2"))  modf->weight2.max=value;
     104    else {
     105      fprintf(stderr,"illegal value: %s\n",name);
     106      return -1;
     107    }
     108  }   
     109
     110  return 0;
     111}
     112
     113static int wrr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
     114{
     115  if(n->nlmsg_flags & NLM_F_CREATE) {
     116    // This is a create request:
     117    struct tc_wrr_qdisc_crt opt;
     118       
     119    int sour,dest,ip,mac,masq;
     120
     121    if(argc<4) {
     122      fprintf(stderr, "Usage: ... wrr sour|dest ip|masq|mac maxclasses proxymaxcon [penalty-setup]\n");
     123      return -1;
     124    }     
     125 
     126    // Read sour/dest:
     127    memset(&opt,0,sizeof(opt));
     128    sour=!strcmp(argv[0],"sour");
     129    dest=!strcmp(argv[0],"dest");       
     130       
     131    if(!sour && !dest) {
     132      fprintf(stderr,"sour or dest must be specified\n");
     133      return -1;
     134    }   
     135
     136    // Read ip/mac
     137    ip=!strcmp(argv[1],"ip");
     138    mac=!strcmp(argv[1],"mac");
     139    masq=!strcmp(argv[1],"masq");       
     140
     141    if(!ip && !mac && !masq) {
     142      fprintf(stderr,"ip, masq or mac must be specified\n");
     143      return -1;
     144    }   
     145
     146    opt.srcaddr=sour;           
     147    opt.usemac=mac;
     148    opt.usemasq=masq;           
     149    opt.bands_max=atoi(argv[2]);
     150   
     151    opt.proxy_maxconn=atoi(argv[3]);
     152   
     153    // Read weights:
     154    if(wrr_parse_qdisc_weight(argc-4,argv+4,&opt.qdisc_modf)<0) return -1;
     155    if(opt.qdisc_modf.weight1.weight_mode==-1) opt.qdisc_modf.weight1.weight_mode=0;
     156    if(opt.qdisc_modf.weight2.weight_mode==-1) opt.qdisc_modf.weight2.weight_mode=0;
     157               
     158    addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
     159  } else {
     160    struct tc_wrr_qdisc_modf_std opt;
     161    char qdisc,class;
     162   
     163    // This is a modify request:
     164    if(argc<1) {
     165      fprintf(stderr,"... qdisc ... or ... class ...\n");
     166      return -1;
     167    }
     168           
     169    qdisc=!strcmp(argv[0],"qdisc");
     170    class=!strcmp(argv[0],"class");
     171
     172    if(!qdisc && !class) {
     173      fprintf(stderr,"qdisc or class must be specified\n");
     174      return -1;
     175    }
     176     
     177    argc--;
     178    argv++;
     179     
     180    opt.proxy=0;
     181   
     182    if(qdisc) {
     183      opt.change_class=0;
     184      if(wrr_parse_qdisc_weight(argc, argv, &opt.qdisc_modf)<0) return -1;
     185    } else {
     186      int a0,a1,a2,a3,a4=0,a5=0;     
     187
     188      opt.change_class=1;
     189     
     190      if(argc<1) {
     191        fprintf(stderr,"... <mac>|<ip>|<masq> ...\n");
     192        return -1;
     193      }
     194      memset(opt.addr,0,sizeof(opt.addr));
     195
     196      if((sscanf(argv[0],"%i.%i.%i.%i",&a0,&a1,&a2,&a3)!=4) &&
     197         (sscanf(argv[0],"%x:%x:%x:%x:%x:%x",&a0,&a1,&a2,&a3,&a4,&a5)!=6)) {
     198        fprintf(stderr,"Wrong format of mac or ip address\n");
     199        return -1;
     200      }
     201     
     202      opt.addr[0]=a0; opt.addr[1]=a1; opt.addr[2]=a2;
     203      opt.addr[3]=a3; opt.addr[4]=a4; opt.addr[5]=a5;
     204
     205      if(wrr_parse_class_modf(argc-1, argv+1, &opt.class_modf)<0) return -1;
     206    } 
     207 
     208    addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
     209  }
     210  return 0;
     211}
     212
     213static int wrr_parse_copt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) {
     214  struct tc_wrr_class_modf opt;
     215 
     216  memset(&opt,0,sizeof(opt));
     217  if(wrr_parse_class_modf(argc,argv,&opt)<0) return -1;
     218 
     219  addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
     220  return 0; 
     221
     222
     223static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
     224{
     225        struct tc_wrr_qdisc_stats *qopt;
     226
     227        if (opt == NULL)
     228                return 0;
     229
     230        if (RTA_PAYLOAD(opt)  < sizeof(*qopt))
     231                return -1;
     232        qopt = RTA_DATA(opt);
     233       
     234        fprintf(f,"\n  (%s/%s) (maxclasses %i) (usedclasses %i) (reused classes %i)\n",
     235          qopt->qdisc_crt.srcaddr ? "sour" : "dest",
     236          qopt->qdisc_crt.usemac  ? "mac"  : (qopt->qdisc_crt.usemasq ? "masq" : "ip"),   
     237          qopt->qdisc_crt.bands_max,                     
     238          qopt->bands_cur,
     239          qopt->bands_reused
     240          );
     241         
     242        if(qopt->qdisc_crt.proxy_maxconn) {
     243          fprintf(f,"  (proxy maxcon %i) (proxy curcon %i)\n",
     244            qopt->qdisc_crt.proxy_maxconn,qopt->proxy_curconn);
     245        }
     246       
     247        fprintf(f,"  (waiting classes %i) (packets requeued %i) (priosum: %Lg)\n",
     248          qopt->nodes_in_heap,
     249          qopt->packets_requed,
     250          qopt->priosum/((long double)((__u32)-1))
     251          );
     252
     253        fprintf(f,"  (wmode1 %i) (wmode2 %i) \n",
     254          qopt->qdisc_crt.qdisc_modf.weight1.weight_mode,
     255          qopt->qdisc_crt.qdisc_modf.weight2.weight_mode);
     256         
     257        return 0;
     258}
     259
     260static int wrr_print_copt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {
     261  struct tc_wrr_class_stats *copt;
     262  long double d=(__u64)-1;
     263
     264  if (opt == NULL) return 0;
     265
     266  if (RTA_PAYLOAD(opt)  < sizeof(*copt))
     267    return -1;
     268  copt = RTA_DATA(opt);
     269
     270  if(!copt->used) {
     271    fprintf(f,"(unused)");
     272    return 0;
     273  }
     274 
     275  if(copt->usemac) {
     276    fprintf(f,"\n  (address: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X)\n",
     277      copt->addr[0],copt->addr[1],copt->addr[2],
     278      copt->addr[3],copt->addr[4],copt->addr[5]);
     279  } else {     
     280    fprintf(f,"\n  (address: %i.%i.%i.%i)\n",copt->addr[0],copt->addr[1],copt->addr[2],copt->addr[3]);
     281  }   
     282 
     283  fprintf(f,"  (total weight: %Lg) (current position: %i) (counters: %u %u : %u %u)\n",
     284    (copt->class_modf.weight1.val/d)*(copt->class_modf.weight2.val/d),
     285    copt->heappos,
     286    (unsigned)(copt->penal_ms>>32),
     287    (unsigned)(copt->penal_ms & 0xffffffffU),
     288    (unsigned)(copt->penal_ls>>32),
     289    (unsigned)(copt->penal_ls & 0xffffffffU)
     290    );
     291   
     292  fprintf(f,"  Pars 1: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)\n",
     293    copt->class_modf.weight1.val/d,
     294    copt->class_modf.weight1.decr/d,
     295    copt->class_modf.weight1.incr/d,
     296    copt->class_modf.weight1.min/d,
     297    copt->class_modf.weight1.max/d);
     298
     299  fprintf(f,"  Pars 2: (weight %Lg) (decr: %Lg) (incr: %Lg) (min: %Lg) (max: %Lg)",
     300    copt->class_modf.weight2.val/d,
     301    copt->class_modf.weight2.decr/d,
     302    copt->class_modf.weight2.incr/d,
     303    copt->class_modf.weight2.min/d,
     304    copt->class_modf.weight2.max/d);
     305 
     306  return 0;
     307}
     308
     309static int wrr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
     310{
     311        return 0;
     312}
     313
     314
     315struct qdisc_util wrr_qdisc_util = {
     316        .id = "wrr",
     317        .parse_qopt = wrr_parse_opt,
     318        .print_qopt = wrr_print_opt,
     319        .print_xstats = wrr_print_xstats,
     320        .parse_copt = wrr_parse_copt,
     321        .print_copt = wrr_print_copt
     322};
Note: See TracBrowser for help on using the repository browser.