Commit 569f0c4d authored by Jay Vosburgh's avatar Jay Vosburgh Committed by Jeff Garzik

bonding: fix enslavement error unwinds

	As part of:

commit c2edacf8
Author: Jay Vosburgh <fubar@us.ibm.com>
Date:   Mon Jul 9 10:42:47 2007 -0700

    bonding / ipv6: no addrconf for slaves separately from master

two steps were rearranged in the enslavement process: netdev_set_master
is now before the call to dev_open to open the slave.

	This patch updates the error cases and unwind process at the
end of bond_enslave to match the new order.  Without this patch, it is
possible for the enslavement to fail, but leave the slave with IFF_SLAVE
set in its flags.
Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent ae68c398
...@@ -1425,13 +1425,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) ...@@ -1425,13 +1425,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
res = netdev_set_master(slave_dev, bond_dev); res = netdev_set_master(slave_dev, bond_dev);
if (res) { if (res) {
dprintk("Error %d calling netdev_set_master\n", res); dprintk("Error %d calling netdev_set_master\n", res);
goto err_close; goto err_restore_mac;
} }
/* open the slave since the application closed it */ /* open the slave since the application closed it */
res = dev_open(slave_dev); res = dev_open(slave_dev);
if (res) { 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_unset_master;
} }
new_slave->dev = slave_dev; new_slave->dev = slave_dev;
...@@ -1444,7 +1444,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) ...@@ -1444,7 +1444,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
*/ */
res = bond_alb_init_slave(bond, new_slave); res = bond_alb_init_slave(bond, new_slave);
if (res) { if (res) {
goto err_unset_master; goto err_close;
} }
} }
...@@ -1619,7 +1619,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) ...@@ -1619,7 +1619,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
res = bond_create_slave_symlinks(bond_dev, slave_dev); res = bond_create_slave_symlinks(bond_dev, slave_dev);
if (res) if (res)
goto err_unset_master; goto err_close;
printk(KERN_INFO DRV_NAME printk(KERN_INFO DRV_NAME
": %s: enslaving %s as a%s interface with a%s link.\n", ": %s: enslaving %s as a%s interface with a%s link.\n",
...@@ -1631,12 +1631,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) ...@@ -1631,12 +1631,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
return 0; return 0;
/* Undo stages on error */ /* Undo stages on error */
err_unset_master:
netdev_set_master(slave_dev, NULL);
err_close: err_close:
dev_close(slave_dev); dev_close(slave_dev);
err_unset_master:
netdev_set_master(slave_dev, NULL);
err_restore_mac: err_restore_mac:
if (!bond->params.fail_over_mac) { if (!bond->params.fail_over_mac) {
memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN); memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
......
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