X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fifenslave.c;h=1cb765e230d83756ac85531e864f45b9d0e8a865;hb=c6725b0af68238a456690146adec763c04f66c82;hp=16fcd54f1054918a208614ef6482fc9a231b72c0;hpb=f3b92d385695aecefd93d5f199be1f64270c2687;p=oweals%2Fbusybox.git diff --git a/networking/ifenslave.c b/networking/ifenslave.c index 16fcd54f1..1cb765e23 100644 --- a/networking/ifenslave.c +++ b/networking/ifenslave.c @@ -97,24 +97,60 @@ * - Code cleanup and style changes * set version to 1.1.0 */ +//config:config IFENSLAVE +//config: bool "ifenslave" +//config: default y +//config: select PLATFORM_LINUX +//config: help +//config: Userspace application to bind several interfaces +//config: to a logical interface (use with kernel bonding driver). + +//applet:IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o + +//usage:#define ifenslave_trivial_usage +//usage: "[-cdf] MASTER_IFACE SLAVE_IFACE..." +//usage:#define ifenslave_full_usage "\n\n" +//usage: "Configure network interfaces for parallel routing\n" +//usage: "\n -c,--change-active Change active slave" +//usage: "\n -d,--detach Remove slave interface from bonding device" +//usage: "\n -f,--force Force, even if interface is not Ethernet" +/* //usage: "\n -r,--receive-slave Create a receive-only slave" */ +//usage: +//usage:#define ifenslave_example_usage +//usage: "To create a bond device, simply follow these three steps:\n" +//usage: "- ensure that the required drivers are properly loaded:\n" +//usage: " # modprobe bonding ; modprobe <3c59x|eepro100|pcnet32|tulip|...>\n" +//usage: "- assign an IP address to the bond device:\n" +//usage: " # ifconfig bond0 netmask broadcast \n" +//usage: "- attach all the interfaces you need to the bond device:\n" +//usage: " # ifenslave bond0 eth0 eth1 eth2\n" +//usage: " If bond0 didn't have a MAC address, it will take eth0's. Then, all\n" +//usage: " interfaces attached AFTER this assignment will get the same MAC addr.\n\n" +//usage: " To detach a dead interface without setting the bond device down:\n" +//usage: " # ifenslave -d bond0 eth1\n\n" +//usage: " To set the bond device down and automatically release all the slaves:\n" +//usage: " # ifconfig bond0 down\n\n" +//usage: " To change active slave:\n" +//usage: " # ifenslave -c bond0 eth0\n" #include "libbb.h" /* #include - no. linux/if_bonding.h pulls in linux/if.h */ -#include +#include +//#include - not needed? #include #include - +#include "fix_u32.h" /* hack, so we may include kernel's ethtool.h */ +#include +#ifndef BOND_ABI_VERSION +# define BOND_ABI_VERSION 2 +#endif #ifndef IFNAMSIZ -#define IFNAMSIZ 16 +# define IFNAMSIZ 16 #endif -typedef uint64_t u64; /* hack, so we may include kernel's ethtool.h */ -typedef uint32_t u32; /* ditto */ -typedef uint16_t u16; /* ditto */ -typedef uint8_t u8; /* ditto */ -#include - struct dev_data { struct ifreq mtu, flags, hwaddr; @@ -245,7 +281,7 @@ static int set_if_addr(char *master_ifname, char *slave_ifname) if (res < 0) { ifr.ifr_addr.sa_family = AF_INET; memset(ifr.ifr_addr.sa_data, 0, - sizeof(ifr.ifr_addr.sa_data)); + sizeof(ifr.ifr_addr.sa_data)); } res = set_ifrname_and_do_ioctl(ifra[i].s_ioctl, &ifr, slave_ifname); @@ -521,7 +557,7 @@ int ifenslave_main(int argc UNUSED_PARAM, char **argv) #ifdef WHY_BOTHER /* Neither -c[hange] nor -d[etach] -> it's "enslave" then; * and -f[orce] is not there too. Check that it's ethernet. */ - if (!(opt & (OPT_d|OPT_c|OPT_f)) { + if (!(opt & (OPT_d|OPT_c|OPT_f))) { /* The family '1' is ARPHRD_ETHER for ethernet. */ if (master.hwaddr.ifr_hwaddr.sa_family != 1) { bb_error_msg_and_die( @@ -552,8 +588,8 @@ int ifenslave_main(int argc UNUSED_PARAM, char **argv) /* Can't work with this slave, */ /* remember the error and skip it */ bb_perror_msg( - "skipping %s: can't get flags", - slave_ifname); + "skipping %s: can't get %s", + slave_ifname, "flags"); res = rv; continue; } @@ -570,8 +606,8 @@ int ifenslave_main(int argc UNUSED_PARAM, char **argv) /* Can't work with this slave, */ /* remember the error and skip it */ bb_perror_msg( - "skipping %s: can't get settings", - slave_ifname); + "skipping %s: can't get %s", + slave_ifname, "settings"); res = rv; continue; }