Changeset 10889


Ignore:
Timestamp:
11/13/08 00:11:31 (5 years ago)
Author:
BrainSlayer
Message:

new bonding driver (implementation)

Location:
src/router
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/router/httpd/visuals/dd-wrt.c

    r10867 r10889  
    20972097    websWrite( wp, "<div class=\"label\">Bonding Type</div>\n", count ); 
    20982098    showOptions( wp, "bonding_type", 
    2099                  "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb", 
     2099                 "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb weighted-rr duplex", 
    21002100                 nvram_default_get( "bonding_type", "balance-rr" ) ); 
    21012101    websWrite( wp, "&nbsp;Bonding Interfaces&nbsp;" ); 
  • src/router/ifenslave/ifenslave.c

    r4844 r10889  
    110110"       ifenslave -d   <master-if> <slave-if> [<slave-if>...]\n" 
    111111"       ifenslave -c   <master-if> <slave-if>\n" 
     112"       ifenslave -w   <master-if> <slave-if> <weight>\n" 
    112113"       ifenslave --help\n"; 
    113114 
     
    140141"       # ifenslave {-a|--all-interfaces}\n" 
    141142"\n" 
     143"       To change iface weight to 3\n" 
     144"       # ifenslave -w bond0 eth0 3\n" 
     145"\n" 
    142146"       To be more verbose\n" 
    143147"       # ifenslave {-v|--verbose} ...\n" 
     
    176180        {"change-active",       0, 0, 'c'},     /* Change the active slave.  */ 
    177181        {"detach",              0, 0, 'd'},     /* Detach a slave interface. */ 
     182        {"weight",              0, 0, 'w'},     /* Detach a slave interface. */ 
    178183        {"force",               0, 0, 'f'},     /* Force the operation. */ 
    179184        {"help",                0, 0, 'h'},     /* Give help */ 
     
    192197opt_h = 0,      /* Help */ 
    193198opt_u = 0,      /* Usage */ 
     199opt_w = 0,      /* Weight */ 
    194200opt_v = 0,      /* Verbose flag. */ 
    195201opt_V = 0;      /* Version */ 
     
    199205int hwaddr_set = 0;     /* Master's hwaddr is set */ 
    200206int saved_errno; 
     207int weight; 
    201208 
    202209struct ifreq master_mtu, master_flags, master_hwaddr; 
     
    229236static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr); 
    230237static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr); 
     238static int set_slave_weight(char *master_ifname, char* slave_ifname, 
     239                int weight); 
    231240static int set_slave_mtu(char *slave_ifname, int mtu); 
    232241static int set_if_flags(char *ifname, short flags); 
     
    249258        int exclusive = 0; 
    250259 
    251         while ((c = getopt_long(argc, argv, "acdfhuvV", longopts, 0)) != EOF) { 
     260        while ((c = getopt_long(argc, argv, "acdfhuwvV", longopts, 0)) != EOF) { 
    252261                switch (c) { 
    253262                case 'a': opt_a++; exclusive++; break; 
     
    257266                case 'h': opt_h++; exclusive++; break; 
    258267                case 'u': opt_u++; exclusive++; break; 
     268                case 'w': opt_w++; ; break; 
    259269                case 'v': opt_v++; break; 
    260270                case 'V': opt_V++; exclusive++; break; 
     
    422432                                master_family); 
    423433                } 
     434        } 
     435         
     436        if (opt_w) { 
     437                if (*spp == NULL) { 
     438                        fprintf(stderr, usage_msg); 
     439                        res = 2; 
     440                        goto out; 
     441                } 
     442                weight = strtol(*spp++, 0, 10); 
     443                if (errno == ERANGE) { 
     444                        fprintf(stderr, "invalid weight"); 
     445                        res = 2; 
     446                        goto out; 
     447                } 
     448                res = get_slave_flags(slave_ifname); 
     449                if (res) { 
     450                        fprintf(stderr, 
     451                                "Slave '%s': Error: get flags failed. " 
     452                                "Aborting\n", 
     453                                slave_ifname); 
     454                        goto out; 
     455                } 
     456                res = set_slave_weight(master_ifname, slave_ifname, weight); 
     457                if (res) { 
     458                        fprintf(stderr, 
     459                                "Master '%s', Slave '%s': Error: " 
     460                                "Change weight failed\n", 
     461                                master_ifname, slave_ifname); 
     462                } 
     463                goto out; 
    424464        } 
    425465 
     
    9661006} 
    9671007 
     1008static int set_slave_weight(char *master_ifname, char *slave_ifname, int weight) 
     1009{ 
     1010        struct ifreq ifr; 
     1011        int res = 0; 
     1012 
     1013        if (!(slave_flags.ifr_flags & IFF_SLAVE)) { 
     1014                fprintf(stderr, 
     1015                        "Illegal operation: The specified slave interface " 
     1016                        "'%s' is not a slave\n", 
     1017                        slave_ifname); 
     1018                return 1; 
     1019        } 
     1020 
     1021        strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); 
     1022        strncpy(ifr.ifr_weight_slave, slave_ifname, IFNAMSIZ); 
     1023        ifr.ifr_weight_weight = weight; 
     1024        if (ioctl(skfd, SIOCBONDSETWEIGHT, &ifr) < 0) { 
     1025                saved_errno = errno; 
     1026                v_print("Master '%s': Error: SIOCBONDSETWEIGHT failed: " 
     1027                        "%s\n", 
     1028                        master_ifname, strerror(saved_errno)); 
     1029                res = 1; 
     1030        } 
     1031 
     1032        return res; 
     1033} 
     1034 
    9681035static int set_slave_mtu(char *slave_ifname, int mtu) 
    9691036{ 
  • src/router/services/services/bonding.c

    r10612 r10889  
    3636    sprintf( count, "max_bonds=%s", 
    3737             nvram_default_get( "bonding_number", "1" ) ); 
    38     eval( "insmod", "bonding", "miimon=100", mode, count ); 
     38    eval( "insmod", "bonding", "miimon=100","downdelay=200","updelay=200", mode, count ); 
    3939 
    4040    static char word[256]; 
Note: See TracChangeset for help on using the changeset viewer.