net: bonding: Unsync device addresses on ndo_stop
[ Upstream commit 86247aba599e5b07d7e828e6edaaebb0ef2b1158 ]
Netdev drivers are expected to call dev_{uc,mc}_sync() in their
ndo_set_rx_mode method and dev_{uc,mc}_unsync() in their ndo_stop method.
This is mentioned in the kerneldoc for those dev_* functions.
The bonding driver calls dev_{uc,mc}_unsync() during ndo_uninit instead of
ndo_stop. This is ineffective because address lists (dev->{uc,mc}) have
already been emptied in unregister_netdevice_many() before ndo_uninit is
called. This mistake can result in addresses being leftover on former bond
slaves after a bond has been deleted; see test_LAG_cleanup() in the last
patch in this series.
Add unsync calls, via bond_hw_addr_flush(), at their expected location,
bond_close().
Add dev_mc_add() call to bond_open() to match the above change.
v3:
* When adding or deleting a slave, only sync/unsync, add/del addresses if
the bond is up. In other cases, it is taken care of at the right time by
ndo_open/ndo_set_rx_mode/ndo_stop.
Fixes: 1da177e4c3
("Linux-2.6.12-rc2")
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
dc209962c0
commit
e2b94a1122
@@ -848,6 +848,7 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
|
|||||||
if (bond->dev->flags & IFF_ALLMULTI)
|
if (bond->dev->flags & IFF_ALLMULTI)
|
||||||
dev_set_allmulti(old_active->dev, -1);
|
dev_set_allmulti(old_active->dev, -1);
|
||||||
|
|
||||||
|
if (bond->dev->flags & IFF_UP)
|
||||||
bond_hw_addr_flush(bond->dev, old_active->dev);
|
bond_hw_addr_flush(bond->dev, old_active->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,11 +860,13 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
|
|||||||
if (bond->dev->flags & IFF_ALLMULTI)
|
if (bond->dev->flags & IFF_ALLMULTI)
|
||||||
dev_set_allmulti(new_active->dev, 1);
|
dev_set_allmulti(new_active->dev, 1);
|
||||||
|
|
||||||
|
if (bond->dev->flags & IFF_UP) {
|
||||||
netif_addr_lock_bh(bond->dev);
|
netif_addr_lock_bh(bond->dev);
|
||||||
dev_uc_sync(new_active->dev, bond->dev);
|
dev_uc_sync(new_active->dev, bond->dev);
|
||||||
dev_mc_sync(new_active->dev, bond->dev);
|
dev_mc_sync(new_active->dev, bond->dev);
|
||||||
netif_addr_unlock_bh(bond->dev);
|
netif_addr_unlock_bh(bond->dev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2069,6 +2072,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bond_dev->flags & IFF_UP) {
|
||||||
netif_addr_lock_bh(bond_dev);
|
netif_addr_lock_bh(bond_dev);
|
||||||
dev_mc_sync_multiple(slave_dev, bond_dev);
|
dev_mc_sync_multiple(slave_dev, bond_dev);
|
||||||
dev_uc_sync_multiple(slave_dev, bond_dev);
|
dev_uc_sync_multiple(slave_dev, bond_dev);
|
||||||
@@ -2077,6 +2081,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
if (BOND_MODE(bond) == BOND_MODE_8023AD)
|
if (BOND_MODE(bond) == BOND_MODE_8023AD)
|
||||||
dev_mc_add(slave_dev, lacpdu_mcast_addr);
|
dev_mc_add(slave_dev, lacpdu_mcast_addr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bond->slave_cnt++;
|
bond->slave_cnt++;
|
||||||
bond_compute_features(bond);
|
bond_compute_features(bond);
|
||||||
@@ -2302,6 +2307,7 @@ static int __bond_release_one(struct net_device *bond_dev,
|
|||||||
if (old_flags & IFF_ALLMULTI)
|
if (old_flags & IFF_ALLMULTI)
|
||||||
dev_set_allmulti(slave_dev, -1);
|
dev_set_allmulti(slave_dev, -1);
|
||||||
|
|
||||||
|
if (old_flags & IFF_UP)
|
||||||
bond_hw_addr_flush(bond_dev, slave_dev);
|
bond_hw_addr_flush(bond_dev, slave_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3764,6 +3770,9 @@ static int bond_open(struct net_device *bond_dev)
|
|||||||
/* register to receive LACPDUs */
|
/* register to receive LACPDUs */
|
||||||
bond->recv_probe = bond_3ad_lacpdu_recv;
|
bond->recv_probe = bond_3ad_lacpdu_recv;
|
||||||
bond_3ad_initiate_agg_selection(bond, 1);
|
bond_3ad_initiate_agg_selection(bond, 1);
|
||||||
|
|
||||||
|
bond_for_each_slave(bond, slave, iter)
|
||||||
|
dev_mc_add(slave->dev, lacpdu_mcast_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bond_mode_can_use_xmit_hash(bond))
|
if (bond_mode_can_use_xmit_hash(bond))
|
||||||
@@ -3775,6 +3784,7 @@ static int bond_open(struct net_device *bond_dev)
|
|||||||
static int bond_close(struct net_device *bond_dev)
|
static int bond_close(struct net_device *bond_dev)
|
||||||
{
|
{
|
||||||
struct bonding *bond = netdev_priv(bond_dev);
|
struct bonding *bond = netdev_priv(bond_dev);
|
||||||
|
struct slave *slave;
|
||||||
|
|
||||||
bond_work_cancel_all(bond);
|
bond_work_cancel_all(bond);
|
||||||
bond->send_peer_notif = 0;
|
bond->send_peer_notif = 0;
|
||||||
@@ -3782,6 +3792,19 @@ static int bond_close(struct net_device *bond_dev)
|
|||||||
bond_alb_deinitialize(bond);
|
bond_alb_deinitialize(bond);
|
||||||
bond->recv_probe = NULL;
|
bond->recv_probe = NULL;
|
||||||
|
|
||||||
|
if (bond_uses_primary(bond)) {
|
||||||
|
rcu_read_lock();
|
||||||
|
slave = rcu_dereference(bond->curr_active_slave);
|
||||||
|
if (slave)
|
||||||
|
bond_hw_addr_flush(bond_dev, slave->dev);
|
||||||
|
rcu_read_unlock();
|
||||||
|
} else {
|
||||||
|
struct list_head *iter;
|
||||||
|
|
||||||
|
bond_for_each_slave(bond, slave, iter)
|
||||||
|
bond_hw_addr_flush(bond_dev, slave->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user