Commit 3c37a0b9 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[NET]: Add synchronize_net.

Currently it takes then releases BR_NETPROTO_LOCK as a writer.
Later it will be converted to RCUs synchronize_kernel().

All call sites have been verified to be sleep friendly.
parent 35ed9412
......@@ -486,6 +486,7 @@ extern int dev_close(struct net_device *dev);
extern int dev_queue_xmit(struct sk_buff *skb);
extern int register_netdevice(struct net_device *dev);
extern int unregister_netdevice(struct net_device *dev);
extern void synchronize_net(void);
extern int register_netdevice_notifier(struct notifier_block *nb);
extern int unregister_netdevice_notifier(struct notifier_block *nb);
extern int call_netdevice_notifiers(unsigned long val, void *v);
......
......@@ -2646,6 +2646,13 @@ int netdev_finish_unregister(struct net_device *dev)
return 0;
}
/* Synchronize with packet receive processing. */
void synchronize_net(void)
{
br_write_lock_bh(BR_NETPROTO_LOCK);
br_write_unlock_bh(BR_NETPROTO_LOCK);
}
/**
* unregister_netdevice - remove device from the kernel
* @dev: device
......@@ -2688,10 +2695,7 @@ int unregister_netdevice(struct net_device *dev)
return -ENODEV;
}
/* Synchronize to net_rx_action. */
br_write_lock_bh(BR_NETPROTO_LOCK);
br_write_unlock_bh(BR_NETPROTO_LOCK);
synchronize_net();
#ifdef CONFIG_NET_FASTROUTE
dev_clear_fastroute(dev);
......
......@@ -544,6 +544,7 @@ EXPORT_SYMBOL(call_netdevice_notifiers);
EXPORT_SYMBOL(loopback_dev);
EXPORT_SYMBOL(register_netdevice);
EXPORT_SYMBOL(unregister_netdevice);
EXPORT_SYMBOL(synchronize_net);
EXPORT_SYMBOL(netdev_state_change);
EXPORT_SYMBOL(dev_new_index);
EXPORT_SYMBOL(dev_get_by_flags);
......
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