Skip to contentSkip to conversation

bonding: add synchronize_net() after netdev_rx_handler_unregister

PATCH In review dingtianhong 2 participants 2 messages May 23, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: add synchronize_net() after netdev_rx_handler_unregister

commit 00cfec3 (net: add a synchronize_net() in netdev_rx_handler_unregister()) add a synchronize_net() in netdev_rx_handler_unregister() to guarantee the rx_handler is NULL when rx_handler_data is a non NULL in rcu_read_lock().

so the caller should not use netdev_rx_handler_unregister in atomic as it may schedule and sleep, the bonding release met the problem.

the commit fcd99434f (bonding: get netdev_rx_handler_unregister out of locks) fix the bug in bond release, but there is no action to guarantee the rx_handler_data is NULL when bond release, so add synchronize_net() behind netdev_rx_handler_unregister() to guarantee it.

This patch adds more comments to netdev_rx_handler_unregister(), as its more reasonable.

---
 drivers/net/bonding/bond_main.c | 2 ++
 net/core/dev.c                  | 3 +++
 2 files changed, 5 insertions(+)
drivers/net/bonding/bond_main.c +2 -0
index d0aade0..592a603 100644
@@ -2007,6 +2007,8 @@ static int __bond_release_one(struct net_device *bond_dev,
 	 * for this slave anymore.
 	 */
 	netdev_rx_handler_unregister(slave_dev);
+	synchronize_net();
+
 	write_lock_bh(&bond->lock);
 
 	if (!all && !bond->params.fail_over_mac) {
net/core/dev.c +3 -0
index fc1e289..9ffeda9 100644
@@ -3344,6 +3344,9 @@ EXPORT_SYMBOL_GPL(netdev_rx_handler_register);
  *	Unregister a receive handler from a device.
  *
  *	The caller must hold the rtnl_mutex.
+ *
+ *	The function should only be called outside the atomic as it
+ *	might sleep and schedule.
  */
 void netdev_rx_handler_unregister(struct net_device *dev)
 {
Signature · 1 line
1.8.0
#1 lore raw
Quoted 12 lines · dingtianhong

commit 00cfec3 (net: add a synchronize_net() in netdev_rx_handler_unregister()) add a synchronize_net() in netdev_rx_handler_unregister() to guarantee the rx_handler is NULL when rx_handler_data is a non NULL in rcu_read_lock().

so the caller should not use netdev_rx_handler_unregister in atomic as it may schedule and sleep, the bonding release met the problem.

the commit fcd99434f (bonding: get netdev_rx_handler_unregister out of locks) fix the bug in bond release, but there is no action to guarantee the rx_handler_data is NULL when bond release, so add synchronize_net() behind netdev_rx_handler_unregister() to guarantee it.

Quoted 8 lines

This patch adds more comments to netdev_rx_handler_unregister(), as its more reasonable.

---
 drivers/net/bonding/bond_main.c | 2 ++
 net/core/dev.c                  | 3 +++
 2 files changed, 5 insertions(+)

I NACK this patch. This makes absolutely no sense to me.