Commit f07d5b94 authored by Alan Stern's avatar Alan Stern Committed by David S. Miller

[NET]: Make netdev_chain a raw notifier.

From: Alan Stern <stern@rowland.harvard.edu>

This chain does it's own locking via the RTNL semaphore, and
can also run recursively so adding a new mutex here was causing
deadlocks.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 63cbd2fd
...@@ -193,7 +193,7 @@ static inline struct hlist_head *dev_index_hash(int ifindex) ...@@ -193,7 +193,7 @@ static inline struct hlist_head *dev_index_hash(int ifindex)
* Our notifier list * Our notifier list
*/ */
static BLOCKING_NOTIFIER_HEAD(netdev_chain); static RAW_NOTIFIER_HEAD(netdev_chain);
/* /*
* Device drivers call our routines to queue packets here. We empty the * Device drivers call our routines to queue packets here. We empty the
...@@ -736,7 +736,7 @@ int dev_change_name(struct net_device *dev, char *newname) ...@@ -736,7 +736,7 @@ int dev_change_name(struct net_device *dev, char *newname)
if (!err) { if (!err) {
hlist_del(&dev->name_hlist); hlist_del(&dev->name_hlist);
hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGENAME, dev); NETDEV_CHANGENAME, dev);
} }
...@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname) ...@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname)
*/ */
void netdev_features_change(struct net_device *dev) void netdev_features_change(struct net_device *dev)
{ {
blocking_notifier_call_chain(&netdev_chain, NETDEV_FEAT_CHANGE, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_FEAT_CHANGE, dev);
} }
EXPORT_SYMBOL(netdev_features_change); EXPORT_SYMBOL(netdev_features_change);
...@@ -766,7 +766,7 @@ EXPORT_SYMBOL(netdev_features_change); ...@@ -766,7 +766,7 @@ EXPORT_SYMBOL(netdev_features_change);
void netdev_state_change(struct net_device *dev) void netdev_state_change(struct net_device *dev)
{ {
if (dev->flags & IFF_UP) { if (dev->flags & IFF_UP) {
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGE, dev); NETDEV_CHANGE, dev);
rtmsg_ifinfo(RTM_NEWLINK, dev, 0); rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
} }
...@@ -864,7 +864,7 @@ int dev_open(struct net_device *dev) ...@@ -864,7 +864,7 @@ int dev_open(struct net_device *dev)
/* /*
* ... and announce new interface. * ... and announce new interface.
*/ */
blocking_notifier_call_chain(&netdev_chain, NETDEV_UP, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_UP, dev);
} }
return ret; return ret;
} }
...@@ -887,7 +887,7 @@ int dev_close(struct net_device *dev) ...@@ -887,7 +887,7 @@ int dev_close(struct net_device *dev)
* Tell people we are going down, so that they can * Tell people we are going down, so that they can
* prepare to death, when device is still operating. * prepare to death, when device is still operating.
*/ */
blocking_notifier_call_chain(&netdev_chain, NETDEV_GOING_DOWN, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_GOING_DOWN, dev);
dev_deactivate(dev); dev_deactivate(dev);
...@@ -924,7 +924,7 @@ int dev_close(struct net_device *dev) ...@@ -924,7 +924,7 @@ int dev_close(struct net_device *dev)
/* /*
* Tell people we are down * Tell people we are down
*/ */
blocking_notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev);
return 0; return 0;
} }
...@@ -955,7 +955,7 @@ int register_netdevice_notifier(struct notifier_block *nb) ...@@ -955,7 +955,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
int err; int err;
rtnl_lock(); rtnl_lock();
err = blocking_notifier_chain_register(&netdev_chain, nb); err = raw_notifier_chain_register(&netdev_chain, nb);
if (!err) { if (!err) {
for (dev = dev_base; dev; dev = dev->next) { for (dev = dev_base; dev; dev = dev->next) {
nb->notifier_call(nb, NETDEV_REGISTER, dev); nb->notifier_call(nb, NETDEV_REGISTER, dev);
...@@ -983,7 +983,7 @@ int unregister_netdevice_notifier(struct notifier_block *nb) ...@@ -983,7 +983,7 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
int err; int err;
rtnl_lock(); rtnl_lock();
err = blocking_notifier_chain_unregister(&netdev_chain, nb); err = raw_notifier_chain_unregister(&netdev_chain, nb);
rtnl_unlock(); rtnl_unlock();
return err; return err;
} }
...@@ -994,12 +994,12 @@ int unregister_netdevice_notifier(struct notifier_block *nb) ...@@ -994,12 +994,12 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
* @v: pointer passed unmodified to notifier function * @v: pointer passed unmodified to notifier function
* *
* Call all network notifier blocks. Parameters and return value * Call all network notifier blocks. Parameters and return value
* are as for blocking_notifier_call_chain(). * are as for raw_notifier_call_chain().
*/ */
int call_netdevice_notifiers(unsigned long val, void *v) int call_netdevice_notifiers(unsigned long val, void *v)
{ {
return blocking_notifier_call_chain(&netdev_chain, val, v); return raw_notifier_call_chain(&netdev_chain, val, v);
} }
/* When > 0 there are consumers of rx skb time stamps */ /* When > 0 there are consumers of rx skb time stamps */
...@@ -2308,7 +2308,7 @@ int dev_change_flags(struct net_device *dev, unsigned flags) ...@@ -2308,7 +2308,7 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
if (dev->flags & IFF_UP && if (dev->flags & IFF_UP &&
((old_flags ^ dev->flags) &~ (IFF_UP | IFF_PROMISC | IFF_ALLMULTI | ((old_flags ^ dev->flags) &~ (IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
IFF_VOLATILE))) IFF_VOLATILE)))
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGE, dev); NETDEV_CHANGE, dev);
if ((flags ^ dev->gflags) & IFF_PROMISC) { if ((flags ^ dev->gflags) & IFF_PROMISC) {
...@@ -2353,7 +2353,7 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) ...@@ -2353,7 +2353,7 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
else else
dev->mtu = new_mtu; dev->mtu = new_mtu;
if (!err && dev->flags & IFF_UP) if (!err && dev->flags & IFF_UP)
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGEMTU, dev); NETDEV_CHANGEMTU, dev);
return err; return err;
} }
...@@ -2370,7 +2370,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) ...@@ -2370,7 +2370,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
return -ENODEV; return -ENODEV;
err = dev->set_mac_address(dev, sa); err = dev->set_mac_address(dev, sa);
if (!err) if (!err)
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGEADDR, dev); NETDEV_CHANGEADDR, dev);
return err; return err;
} }
...@@ -2427,7 +2427,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd) ...@@ -2427,7 +2427,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
return -EINVAL; return -EINVAL;
memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data, memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len)); min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_CHANGEADDR, dev); NETDEV_CHANGEADDR, dev);
return 0; return 0;
...@@ -2882,7 +2882,7 @@ int register_netdevice(struct net_device *dev) ...@@ -2882,7 +2882,7 @@ int register_netdevice(struct net_device *dev)
write_unlock_bh(&dev_base_lock); write_unlock_bh(&dev_base_lock);
/* Notify protocols, that a new device appeared. */ /* Notify protocols, that a new device appeared. */
blocking_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
/* Finish registration after unlock */ /* Finish registration after unlock */
net_set_todo(dev); net_set_todo(dev);
...@@ -2961,7 +2961,7 @@ static void netdev_wait_allrefs(struct net_device *dev) ...@@ -2961,7 +2961,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
rtnl_lock(); rtnl_lock();
/* Rebroadcast unregister notification */ /* Rebroadcast unregister notification */
blocking_notifier_call_chain(&netdev_chain, raw_notifier_call_chain(&netdev_chain,
NETDEV_UNREGISTER, dev); NETDEV_UNREGISTER, dev);
if (test_bit(__LINK_STATE_LINKWATCH_PENDING, if (test_bit(__LINK_STATE_LINKWATCH_PENDING,
...@@ -3216,7 +3216,7 @@ int unregister_netdevice(struct net_device *dev) ...@@ -3216,7 +3216,7 @@ int unregister_netdevice(struct net_device *dev)
/* Notify protocols, that we are about to destroy /* Notify protocols, that we are about to destroy
this device. They should clean all the things. this device. They should clean all the things.
*/ */
blocking_notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev); raw_notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev);
/* /*
* Flush the multicast chain * Flush the multicast chain
......
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