Skip to content

Commit 7d5cd2c

Browse files
Nikolay Aleksandrovdavem330
Nikolay Aleksandrov
authored andcommitted
bonding: correctly handle bonding type change on enslave failure
If the bond is enslaving a device with different type it will be setup by it, but if after being setup the enslave fails the bond doesn't switch back its type and also keeps pointers to foreign structures that can be long gone. Thus revert back any type changes if the enslave failed and the bond had to change its type. Example: Before patch: $ echo lo > bond0/bonding/slaves -bash: echo: write error: Cannot assign requested address $ ip l sh bond0 20: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN mode DEFAULT group default link/loopback 16:54:78:34:bd:41 brd 00:00:00:00:00:00 $ echo +eth1 > bond0/bonding/slaves $ ip l sh bond0 20: bond0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 52:54:00:3f:47:69 brd ff:ff:ff:ff:ff:ff (notice the MASTER flag is gone) After patch: $ echo lo > bond0/bonding/slaves -bash: echo: write error: Cannot assign requested address $ ip l sh bond0 21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 6e:66:94:f6:07:fc brd ff:ff:ff:ff:ff:ff $ echo +eth1 > bond0/bonding/slaves $ ip l sh bond0 21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 52:54:00:3f:47:69 brd ff:ff:ff:ff:ff:ff Signed-off-by: Nikolay Aleksandrov <[email protected]> Fixes: e36b9d1 ("bonding: clean muticast addresses when device changes type") Signed-off-by: David S. Miller <[email protected]>
1 parent 06f6d10 commit 7d5cd2c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,9 +1725,16 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
17251725

17261726
err_undo_flags:
17271727
/* Enslave of first slave has failed and we need to fix master's mac */
1728-
if (!bond_has_slaves(bond) &&
1729-
ether_addr_equal_64bits(bond_dev->dev_addr, slave_dev->dev_addr))
1730-
eth_hw_addr_random(bond_dev);
1728+
if (!bond_has_slaves(bond)) {
1729+
if (ether_addr_equal_64bits(bond_dev->dev_addr,
1730+
slave_dev->dev_addr))
1731+
eth_hw_addr_random(bond_dev);
1732+
if (bond_dev->type != ARPHRD_ETHER) {
1733+
ether_setup(bond_dev);
1734+
bond_dev->flags |= IFF_MASTER;
1735+
bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
1736+
}
1737+
}
17311738

17321739
return res;
17331740
}

0 commit comments

Comments
 (0)