Skip to content

Commit 1f718f0

Browse files
Veaceslav Falicodavem330
authored andcommitted
bonding: populate neighbour's private on enslave
Use the new provided function when attaching the lower slave to populate its ->private with struct slave *new_slave. Also, move it to the end to be able to 'find' it only after it was completely initialized, and deinitialize in the first place on release. CC: Jay Vosburgh <[email protected]> CC: Andy Gospodarek <[email protected]> Signed-off-by: Veaceslav Falico <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 402dae9 commit 1f718f0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,11 +1233,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
12331233
}
12341234

12351235
static int bond_master_upper_dev_link(struct net_device *bond_dev,
1236-
struct net_device *slave_dev)
1236+
struct net_device *slave_dev,
1237+
struct slave *slave)
12371238
{
12381239
int err;
12391240

1240-
err = netdev_master_upper_dev_link(slave_dev, bond_dev);
1241+
err = netdev_master_upper_dev_link_private(slave_dev, bond_dev, slave);
12411242
if (err)
12421243
return err;
12431244
slave_dev->flags |= IFF_SLAVE;
@@ -1413,17 +1414,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
14131414
}
14141415
}
14151416

1416-
res = bond_master_upper_dev_link(bond_dev, slave_dev);
1417-
if (res) {
1418-
pr_debug("Error %d calling bond_master_upper_dev_link\n", res);
1419-
goto err_restore_mac;
1420-
}
1421-
14221417
/* open the slave since the application closed it */
14231418
res = dev_open(slave_dev);
14241419
if (res) {
14251420
pr_debug("Opening slave %s failed\n", slave_dev->name);
1426-
goto err_unset_master;
1421+
goto err_restore_mac;
14271422
}
14281423

14291424
new_slave->bond = bond;
@@ -1637,6 +1632,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
16371632
goto err_dest_symlinks;
16381633
}
16391634

1635+
res = bond_master_upper_dev_link(bond_dev, slave_dev, new_slave);
1636+
if (res) {
1637+
pr_debug("Error %d calling bond_master_upper_dev_link\n", res);
1638+
goto err_unregister;
1639+
}
1640+
1641+
16401642
pr_info("%s: enslaving %s as a%s interface with a%s link.\n",
16411643
bond_dev->name, slave_dev->name,
16421644
bond_is_active_slave(new_slave) ? "n active" : " backup",
@@ -1646,6 +1648,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
16461648
return 0;
16471649

16481650
/* Undo stages on error */
1651+
err_unregister:
1652+
netdev_rx_handler_unregister(slave_dev);
1653+
16491654
err_dest_symlinks:
16501655
bond_destroy_slave_symlinks(bond_dev, slave_dev);
16511656

@@ -1675,9 +1680,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
16751680
slave_dev->priv_flags &= ~IFF_BONDING;
16761681
dev_close(slave_dev);
16771682

1678-
err_unset_master:
1679-
bond_upper_dev_unlink(bond_dev, slave_dev);
1680-
16811683
err_restore_mac:
16821684
if (!bond->params.fail_over_mac) {
16831685
/* XXX TODO - fom follow mode needs to change master's
@@ -1748,6 +1750,8 @@ static int __bond_release_one(struct net_device *bond_dev,
17481750
}
17491751

17501752
write_unlock_bh(&bond->lock);
1753+
1754+
bond_upper_dev_unlink(bond_dev, slave_dev);
17511755
/* unregister rx_handler early so bond_handle_frame wouldn't be called
17521756
* for this slave anymore.
17531757
*/
@@ -1866,8 +1870,6 @@ static int __bond_release_one(struct net_device *bond_dev,
18661870
bond_hw_addr_flush(bond_dev, slave_dev);
18671871
}
18681872

1869-
bond_upper_dev_unlink(bond_dev, slave_dev);
1870-
18711873
slave_disable_netpoll(slave);
18721874

18731875
/* close slave before restoring its mac address */

0 commit comments

Comments
 (0)