Commit bcddb0e6 authored by Shmulik Hen's avatar Shmulik Hen Committed by Jeff Garzik

[PATCH] bonding cleanup 2.6 - consolidate return values of functions.

parent 9fec364c
...@@ -338,7 +338,7 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct ...@@ -338,7 +338,7 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct
{ {
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct arp_pkt *arp = (struct arp_pkt *)skb->data; struct arp_pkt *arp = (struct arp_pkt *)skb->data;
int ret = NET_RX_DROP; int res = NET_RX_DROP;
if (!(bond_dev->flags & IFF_MASTER)) { if (!(bond_dev->flags & IFF_MASTER)) {
goto out; goto out;
...@@ -360,12 +360,12 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct ...@@ -360,12 +360,12 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct
dprintk("Server received an ARP Reply from client\n"); dprintk("Server received an ARP Reply from client\n");
} }
ret = NET_RX_SUCCESS; res = NET_RX_SUCCESS;
out: out:
dev_kfree_skb(skb); dev_kfree_skb(skb);
return ret; return res;
} }
/* Caller must hold bond lock for read */ /* Caller must hold bond lock for read */
...@@ -1074,7 +1074,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) ...@@ -1074,7 +1074,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
struct sockaddr sa; struct sockaddr sa;
struct slave *slave, *stop_at; struct slave *slave, *stop_at;
char tmp_addr[ETH_ALEN]; char tmp_addr[ETH_ALEN];
int error; int res;
int i; int i;
if (bond->alb_info.rlb_enabled) { if (bond->alb_info.rlb_enabled) {
...@@ -1083,19 +1083,19 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) ...@@ -1083,19 +1083,19 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
if (slave->dev->set_mac_address == NULL) { if (slave->dev->set_mac_address == NULL) {
error = -EOPNOTSUPP; res = -EOPNOTSUPP;
goto unwind; goto unwind;
} }
/* save net_device's current hw address */ /* save net_device's current hw address */
memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN); memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
error = slave->dev->set_mac_address(slave->dev, addr); res = slave->dev->set_mac_address(slave->dev, addr);
/* restore net_device's hw address */ /* restore net_device's hw address */
memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN); memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
if (error) { if (res) {
goto unwind; goto unwind;
} }
} }
...@@ -1114,7 +1114,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) ...@@ -1114,7 +1114,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN); memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
} }
return error; return res;
} }
/************************ exported alb funcions ************************/ /************************ exported alb funcions ************************/
...@@ -1378,12 +1378,12 @@ void bond_alb_monitor(struct bonding *bond) ...@@ -1378,12 +1378,12 @@ void bond_alb_monitor(struct bonding *bond)
*/ */
int bond_alb_init_slave(struct bonding *bond, struct slave *slave) int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
{ {
int err = 0; int res;
err = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
bond->alb_info.rlb_enabled); bond->alb_info.rlb_enabled);
if (err) { if (res) {
return err; return res;
} }
/* caller must hold the bond lock for write since the mac addresses /* caller must hold the bond lock for write since the mac addresses
...@@ -1391,12 +1391,12 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave) ...@@ -1391,12 +1391,12 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
*/ */
write_lock_bh(&bond->lock); write_lock_bh(&bond->lock);
err = alb_handle_addr_collision_on_attach(bond, slave); res = alb_handle_addr_collision_on_attach(bond, slave);
write_unlock_bh(&bond->lock); write_unlock_bh(&bond->lock);
if (err) { if (res) {
return err; return res;
} }
tlb_init_slave(slave); tlb_init_slave(slave);
...@@ -1514,16 +1514,16 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) ...@@ -1514,16 +1514,16 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct sockaddr *sa = addr; struct sockaddr *sa = addr;
struct slave *swap_slave; struct slave *swap_slave;
int error = 0; int res;
int i, found = 0; int i, found = 0;
if (!is_valid_ether_addr(sa->sa_data)) { if (!is_valid_ether_addr(sa->sa_data)) {
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
} }
error = alb_set_mac_address(bond, addr); res = alb_set_mac_address(bond, addr);
if (error) { if (res) {
return error; return res;
} }
memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len); memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len);
......
...@@ -704,12 +704,12 @@ static void bond_attach_slave(struct bonding *bond, struct slave *new_slave) ...@@ -704,12 +704,12 @@ static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
* Needs "ioctl" variable to be supplied by calling context. * Needs "ioctl" variable to be supplied by calling context.
*/ */
#define IOCTL(dev, arg, cmd) ({ \ #define IOCTL(dev, arg, cmd) ({ \
int ret; \ int res = 0; \
mm_segment_t fs = get_fs(); \ mm_segment_t fs = get_fs(); \
set_fs(get_ds()); \ set_fs(get_ds()); \
ret = ioctl(dev, arg, cmd); \ res = ioctl(dev, arg, cmd); \
set_fs(fs); \ set_fs(fs); \
ret; }) res; })
/* /*
* Get link speed and duplex from the slave's base driver * Get link speed and duplex from the slave's base driver
...@@ -810,7 +810,7 @@ static int bond_check_dev_link(struct net_device *slave_dev, int reporting) ...@@ -810,7 +810,7 @@ static int bond_check_dev_link(struct net_device *slave_dev, int reporting)
if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) { if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) {
mii->reg_num = MII_BMSR; mii->reg_num = MII_BMSR;
if (IOCTL(slave_dev, &ifr, SIOCGMIIREG) == 0) { if (IOCTL(slave_dev, &ifr, SIOCGMIIREG) == 0) {
return mii->val_out & BMSR_LSTATUS; return (mii->val_out & BMSR_LSTATUS);
} }
} }
...@@ -836,7 +836,7 @@ static int bond_check_dev_link(struct net_device *slave_dev, int reporting) ...@@ -836,7 +836,7 @@ static int bond_check_dev_link(struct net_device *slave_dev, int reporting)
* cannot report link status). If not reporting, pretend * cannot report link status). If not reporting, pretend
* we're ok. * we're ok.
*/ */
return reporting ? -1 : BMSR_LSTATUS; return (reporting ? -1 : BMSR_LSTATUS);
} }
/* register to receive lacpdus on a bond */ /* register to receive lacpdus on a bond */
...@@ -1225,10 +1225,10 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de ...@@ -1225,10 +1225,10 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
{ {
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct slave *new_slave = NULL; struct slave *new_slave = NULL;
int err = 0;
struct dev_mc_list *dmi; struct dev_mc_list *dmi;
int link_reporting; int link_reporting;
struct sockaddr addr; struct sockaddr addr;
int res = 0;
if (slave_dev->do_ioctl == NULL) { if (slave_dev->do_ioctl == NULL) {
printk(KERN_WARNING DRV_NAME printk(KERN_WARNING DRV_NAME
...@@ -1315,23 +1315,23 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de ...@@ -1315,23 +1315,23 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
*/ */
memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
addr.sa_family = slave_dev->type; addr.sa_family = slave_dev->type;
err = slave_dev->set_mac_address(slave_dev, &addr); res = slave_dev->set_mac_address(slave_dev, &addr);
if (err) { if (res) {
dprintk("Error %d calling set_mac_address\n", err); dprintk("Error %d calling set_mac_address\n", res);
goto err_free; goto err_free;
} }
/* open the slave since the application closed it */ /* open the slave since the application closed it */
err = dev_open(slave_dev); res = dev_open(slave_dev);
if (err) { if (res) {
dprintk("Openning slave %s failed\n", slave_dev->name); dprintk("Openning slave %s failed\n", slave_dev->name);
goto err_restore_mac; goto err_restore_mac;
} }
} }
err = netdev_set_master(slave_dev, bond_dev); res = netdev_set_master(slave_dev, bond_dev);
if (err) { if (res) {
dprintk("Error %d calling netdev_set_master\n", err); dprintk("Error %d calling netdev_set_master\n", res);
if (app_abi_ver < 1) { if (app_abi_ver < 1) {
goto err_free; goto err_free;
} else { } else {
...@@ -1346,8 +1346,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de ...@@ -1346,8 +1346,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
/* bond_alb_init_slave() must be called before all other stages since /* bond_alb_init_slave() must be called before all other stages since
* it might fail and we do not want to have to undo everything * it might fail and we do not want to have to undo everything
*/ */
err = bond_alb_init_slave(bond, new_slave); res = bond_alb_init_slave(bond, new_slave);
if (err) { if (res) {
goto err_unset_master; goto err_unset_master;
} }
} }
...@@ -1585,7 +1585,7 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de ...@@ -1585,7 +1585,7 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
err_free: err_free:
kfree(new_slave); kfree(new_slave);
return err; return res;
} }
/* /*
...@@ -1604,7 +1604,7 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi ...@@ -1604,7 +1604,7 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct slave *old_active = NULL; struct slave *old_active = NULL;
struct slave *new_active = NULL; struct slave *new_active = NULL;
int ret = 0; int res = 0;
/* Verify that master_dev is indeed the master of slave_dev */ /* Verify that master_dev is indeed the master of slave_dev */
if (!(slave_dev->flags & IFF_SLAVE) || if (!(slave_dev->flags & IFF_SLAVE) ||
...@@ -1632,10 +1632,10 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi ...@@ -1632,10 +1632,10 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
IS_UP(new_active->dev)) { IS_UP(new_active->dev)) {
bond_change_active_slave(bond, new_active); bond_change_active_slave(bond, new_active);
} else { } else {
ret = -EINVAL; res = -EINVAL;
} }
write_unlock_bh(&bond->lock); write_unlock_bh(&bond->lock);
return ret; return res;
} }
/** /**
...@@ -1958,7 +1958,6 @@ static int bond_release_all(struct net_device *bond_dev) ...@@ -1958,7 +1958,6 @@ static int bond_release_all(struct net_device *bond_dev)
struct slave *slave; struct slave *slave;
struct net_device *slave_dev; struct net_device *slave_dev;
struct sockaddr addr; struct sockaddr addr;
int err = 0;
write_lock_bh(&bond->lock); write_lock_bh(&bond->lock);
...@@ -2050,7 +2049,7 @@ static int bond_release_all(struct net_device *bond_dev) ...@@ -2050,7 +2049,7 @@ static int bond_release_all(struct net_device *bond_dev)
out: out:
write_unlock_bh(&bond->lock); write_unlock_bh(&bond->lock);
return err; return 0;
} }
/* this function is called regularly to monitor each slave's link. */ /* this function is called regularly to monitor each slave's link. */
...@@ -2757,7 +2756,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd ...@@ -2757,7 +2756,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
struct ifslave *u_sinfo = NULL, k_sinfo; struct ifslave *u_sinfo = NULL, k_sinfo;
struct mii_ioctl_data *mii = NULL; struct mii_ioctl_data *mii = NULL;
int prev_abi_ver = orig_app_abi_ver; int prev_abi_ver = orig_app_abi_ver;
int ret = 0; int res = 0;
dprintk("bond_ioctl: master=%s, cmd=%d\n", dprintk("bond_ioctl: master=%s, cmd=%d\n",
bond_dev->name, cmd); bond_dev->name, cmd);
...@@ -2800,26 +2799,26 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd ...@@ -2800,26 +2799,26 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) { if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) {
return -EFAULT; return -EFAULT;
} }
ret = bond_info_query(bond_dev, &k_binfo); res = bond_info_query(bond_dev, &k_binfo);
if (ret == 0) { if (res == 0) {
if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) { if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) {
return -EFAULT; return -EFAULT;
} }
} }
return ret; return res;
case BOND_SLAVE_INFO_QUERY_OLD: case BOND_SLAVE_INFO_QUERY_OLD:
case SIOCBONDSLAVEINFOQUERY: case SIOCBONDSLAVEINFOQUERY:
u_sinfo = (struct ifslave *)ifr->ifr_data; u_sinfo = (struct ifslave *)ifr->ifr_data;
if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) { if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) {
return -EFAULT; return -EFAULT;
} }
ret = bond_slave_info_query(bond_dev, &k_sinfo); res = bond_slave_info_query(bond_dev, &k_sinfo);
if (ret == 0) { if (res == 0) {
if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) { if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) {
return -EFAULT; return -EFAULT;
} }
} }
return ret; return res;
} }
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN)) {
...@@ -2846,38 +2845,38 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd ...@@ -2846,38 +2845,38 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
dprintk("slave_dev=%p: \n", slave_dev); dprintk("slave_dev=%p: \n", slave_dev);
if (slave_dev == NULL) { if (slave_dev == NULL) {
ret = -ENODEV; res = -ENODEV;
} else { } else {
dprintk("slave_dev->name=%s: \n", slave_dev->name); dprintk("slave_dev->name=%s: \n", slave_dev->name);
switch (cmd) { switch (cmd) {
case BOND_ENSLAVE_OLD: case BOND_ENSLAVE_OLD:
case SIOCBONDENSLAVE: case SIOCBONDENSLAVE:
ret = bond_enslave(bond_dev, slave_dev); res = bond_enslave(bond_dev, slave_dev);
break; break;
case BOND_RELEASE_OLD: case BOND_RELEASE_OLD:
case SIOCBONDRELEASE: case SIOCBONDRELEASE:
ret = bond_release(bond_dev, slave_dev); res = bond_release(bond_dev, slave_dev);
break; break;
case BOND_SETHWADDR_OLD: case BOND_SETHWADDR_OLD:
case SIOCBONDSETHWADDR: case SIOCBONDSETHWADDR:
ret = bond_sethwaddr(bond_dev, slave_dev); res = bond_sethwaddr(bond_dev, slave_dev);
break; break;
case BOND_CHANGE_ACTIVE_OLD: case BOND_CHANGE_ACTIVE_OLD:
case SIOCBONDCHANGEACTIVE: case SIOCBONDCHANGEACTIVE:
if (USES_PRIMARY(bond_mode)) { if (USES_PRIMARY(bond_mode)) {
ret = bond_ioctl_change_active(bond_dev, slave_dev); res = bond_ioctl_change_active(bond_dev, slave_dev);
} }
else { else {
ret = -EINVAL; res = -EINVAL;
} }
break; break;
default: default:
ret = -EOPNOTSUPP; res = -EOPNOTSUPP;
} }
dev_put(slave_dev); dev_put(slave_dev);
} }
if (ret < 0) { if (res < 0) {
/* The ioctl failed, so there's no point in changing the /* The ioctl failed, so there's no point in changing the
* orig_app_abi_ver. We'll restore it's value just in case * orig_app_abi_ver. We'll restore it's value just in case
* we've changed it earlier in this function. * we've changed it earlier in this function.
...@@ -2885,7 +2884,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd ...@@ -2885,7 +2884,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
orig_app_abi_ver = prev_abi_ver; orig_app_abi_ver = prev_abi_ver;
} }
return ret; return res;
} }
#ifdef CONFIG_NET_FASTROUTE #ifdef CONFIG_NET_FASTROUTE
...@@ -3069,7 +3068,6 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) ...@@ -3069,7 +3068,6 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev)
{ {
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
int ret;
if (!IS_UP(bond_dev)) { /* bond down */ if (!IS_UP(bond_dev)) { /* bond down */
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -3094,7 +3092,7 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d ...@@ -3094,7 +3092,7 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
skb->dev = bond->curr_active_slave->dev; skb->dev = bond->curr_active_slave->dev;
read_unlock(&bond->curr_slave_lock); read_unlock(&bond->curr_slave_lock);
skb->priority = 1; skb->priority = 1;
ret = dev_queue_xmit(skb); dev_queue_xmit(skb);
read_unlock(&bond->lock); read_unlock(&bond->lock);
return 0; return 0;
} }
...@@ -3314,16 +3312,16 @@ static int bond_info_open(struct inode *inode, struct file *file) ...@@ -3314,16 +3312,16 @@ static int bond_info_open(struct inode *inode, struct file *file)
{ {
struct seq_file *seq; struct seq_file *seq;
struct proc_dir_entry *proc; struct proc_dir_entry *proc;
int rc; int res;
rc = seq_open(file, &bond_info_seq_ops); res = seq_open(file, &bond_info_seq_ops);
if (!rc) { if (!res) {
/* recover the pointer buried in proc_dir_entry data */ /* recover the pointer buried in proc_dir_entry data */
seq = file->private_data; seq = file->private_data;
proc = PDE(inode); proc = PDE(inode);
seq->private = proc->data; seq->private = proc->data;
} }
return rc; return res;
} }
static struct file_operations bond_info_fops = { static struct file_operations bond_info_fops = {
...@@ -3435,7 +3433,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) ...@@ -3435,7 +3433,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct sockaddr *sa = addr, tmp_sa; struct sockaddr *sa = addr, tmp_sa;
struct slave *slave, *stop_at; struct slave *slave, *stop_at;
int error; int res = 0;
int i; int i;
dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None")); dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None"));
...@@ -3462,20 +3460,20 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) ...@@ -3462,20 +3460,20 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
dprintk("slave %p %s\n", slave, slave->dev->name); dprintk("slave %p %s\n", slave, slave->dev->name);
if (slave->dev->set_mac_address == NULL) { if (slave->dev->set_mac_address == NULL) {
error = -EOPNOTSUPP; res = -EOPNOTSUPP;
dprintk("EOPNOTSUPP %s\n", slave->dev->name); dprintk("EOPNOTSUPP %s\n", slave->dev->name);
goto unwind; goto unwind;
} }
error = slave->dev->set_mac_address(slave->dev, addr); res = slave->dev->set_mac_address(slave->dev, addr);
if (error) { if (res) {
/* TODO: consider downing the slave /* TODO: consider downing the slave
* and retry ? * and retry ?
* User should expect communications * User should expect communications
* breakage anyway until ARP finish * breakage anyway until ARP finish
* updating, so... * updating, so...
*/ */
dprintk("err %d %s\n", error, slave->dev->name); dprintk("err %d %s\n", res, slave->dev->name);
goto unwind; goto unwind;
} }
} }
...@@ -3491,16 +3489,16 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) ...@@ -3491,16 +3489,16 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
/* unwind from the first slave that failed to head */ /* unwind from the first slave that failed to head */
stop_at = slave; stop_at = slave;
bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) { bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
int tmp_error; int tmp_res;
tmp_error = slave->dev->set_mac_address(slave->dev, &tmp_sa); tmp_res = slave->dev->set_mac_address(slave->dev, &tmp_sa);
if (tmp_error) { if (tmp_res) {
dprintk("unwind err %d dev %s\n", tmp_error, dprintk("unwind err %d dev %s\n", tmp_res,
slave->dev->name); slave->dev->name);
} }
} }
return error; return res;
} }
/* /*
...@@ -3510,7 +3508,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) ...@@ -3510,7 +3508,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
{ {
struct bonding *bond = (struct bonding *)bond_dev->priv; struct bonding *bond = (struct bonding *)bond_dev->priv;
struct slave *slave, *stop_at; struct slave *slave, *stop_at;
int error; int res = 0;
int i; int i;
dprintk("bond=%p, name=%s, new_mtu=%d\n", bond, dprintk("bond=%p, name=%s, new_mtu=%d\n", bond,
...@@ -3535,13 +3533,13 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) ...@@ -3535,13 +3533,13 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
dprintk("s %p s->p %p c_m %p\n", slave, dprintk("s %p s->p %p c_m %p\n", slave,
slave->prev, slave->dev->change_mtu); slave->prev, slave->dev->change_mtu);
if (slave->dev->change_mtu) { if (slave->dev->change_mtu) {
error = slave->dev->change_mtu(slave->dev, new_mtu); res = slave->dev->change_mtu(slave->dev, new_mtu);
} else { } else {
slave->dev->mtu = new_mtu; slave->dev->mtu = new_mtu;
error = 0; res = 0;
} }
if (error) { if (res) {
/* If we failed to set the slave's mtu to the new value /* If we failed to set the slave's mtu to the new value
* we must abort the operation even in ACTIVE_BACKUP * we must abort the operation even in ACTIVE_BACKUP
* mode, because if we allow the backup slaves to have * mode, because if we allow the backup slaves to have
...@@ -3550,7 +3548,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) ...@@ -3550,7 +3548,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
* means changing their mtu from timer context, which * means changing their mtu from timer context, which
* is probably not a good idea. * is probably not a good idea.
*/ */
dprintk("err %d %s\n", error, slave->dev->name); dprintk("err %d %s\n", res, slave->dev->name);
goto unwind; goto unwind;
} }
} }
...@@ -3563,14 +3561,20 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) ...@@ -3563,14 +3561,20 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
/* unwind from the first slave that failed to head */ /* unwind from the first slave that failed to head */
stop_at = slave; stop_at = slave;
bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) { bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
int tmp_res;
if (slave->dev->change_mtu) { if (slave->dev->change_mtu) {
slave->dev->change_mtu(slave->dev, bond_dev->mtu); tmp_res = slave->dev->change_mtu(slave->dev, bond_dev->mtu);
if (tmp_res) {
dprintk("unwind err %d dev %s\n", tmp_res,
slave->dev->name);
}
} else { } else {
slave->dev->mtu = bond_dev->mtu; slave->dev->mtu = bond_dev->mtu;
} }
} }
return error; return res;
} }
/* /*
...@@ -4054,13 +4058,13 @@ static int bond_check_params(void) ...@@ -4054,13 +4058,13 @@ static int bond_check_params(void)
static int __init bonding_init(void) static int __init bonding_init(void)
{ {
int i; int i;
int err; int res;
printk(KERN_INFO "%s", version); printk(KERN_INFO "%s", version);
err = bond_check_params(); res = bond_check_params();
if (err) { if (res) {
return err; return res;
} }
rtnl_lock(); rtnl_lock();
...@@ -4069,18 +4073,17 @@ static int __init bonding_init(void) ...@@ -4069,18 +4073,17 @@ static int __init bonding_init(void)
bond_create_proc_dir(); bond_create_proc_dir();
#endif #endif
err = 0;
for (i = 0; i < max_bonds; i++) { for (i = 0; i < max_bonds; i++) {
struct net_device *bond_dev; struct net_device *bond_dev;
bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup);
if (!bond_dev) { if (!bond_dev) {
err = -ENOMEM; res = -ENOMEM;
goto out_err; goto out_err;
} }
err = dev_alloc_name(bond_dev, "bond%d"); res = dev_alloc_name(bond_dev, "bond%d");
if (err < 0) { if (res < 0) {
free_netdev(bond_dev); free_netdev(bond_dev);
goto out_err; goto out_err;
} }
...@@ -4089,16 +4092,16 @@ static int __init bonding_init(void) ...@@ -4089,16 +4092,16 @@ static int __init bonding_init(void)
* /proc files), but before register_netdevice(), because we * /proc files), but before register_netdevice(), because we
* need to set function pointers. * need to set function pointers.
*/ */
err = bond_init(bond_dev); res = bond_init(bond_dev);
if (err < 0) { if (res < 0) {
free_netdev(bond_dev); free_netdev(bond_dev);
goto out_err; goto out_err;
} }
SET_MODULE_OWNER(bond_dev); SET_MODULE_OWNER(bond_dev);
err = register_netdevice(bond_dev); res = register_netdevice(bond_dev);
if (err < 0) { if (res < 0) {
bond_deinit(bond_dev); bond_deinit(bond_dev);
free_netdev(bond_dev); free_netdev(bond_dev);
goto out_err; goto out_err;
...@@ -4116,7 +4119,7 @@ static int __init bonding_init(void) ...@@ -4116,7 +4119,7 @@ static int __init bonding_init(void)
rtnl_unlock(); rtnl_unlock();
return err; return res;
} }
static void __exit bonding_exit(void) static void __exit bonding_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment