aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-05-09 18:23:03 -0400
committerDavid S. Miller <davem@davemloft.net>2006-05-09 18:23:03 -0400
commitf07d5b946510a54937a75a3654941e855ffdc4c2 (patch)
tree53cc1ae30f78f345cd4b3d7944425dda6a795423 /net
parent63cbd2fda38f3d1f107c4fd6261e5660be3eccf9 (diff)
[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: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 9ab3cfa58466..ced57430f6d8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -193,7 +193,7 @@ static inline struct hlist_head *dev_index_hash(int ifindex)
193 * Our notifier list 193 * Our notifier list
194 */ 194 */
195 195
196static BLOCKING_NOTIFIER_HEAD(netdev_chain); 196static RAW_NOTIFIER_HEAD(netdev_chain);
197 197
198/* 198/*
199 * Device drivers call our routines to queue packets here. We empty the 199 * 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 if (!err) { 736 if (!err) {
737 hlist_del(&dev->name_hlist); 737 hlist_del(&dev->name_hlist);
738 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); 738 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
739 blocking_notifier_call_chain(&netdev_chain, 739 raw_notifier_call_chain(&netdev_chain,
740 NETDEV_CHANGENAME, dev); 740 NETDEV_CHANGENAME, dev);
741 } 741 }
742 742
@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname)
751 */ 751 */
752void netdev_features_change(struct net_device *dev) 752void netdev_features_change(struct net_device *dev)
753{ 753{
754 blocking_notifier_call_chain(&netdev_chain, NETDEV_FEAT_CHANGE, dev); 754 raw_notifier_call_chain(&netdev_chain, NETDEV_FEAT_CHANGE, dev);
755} 755}
756EXPORT_SYMBOL(netdev_features_change); 756EXPORT_SYMBOL(netdev_features_change);
757 757
@@ -766,7 +766,7 @@ EXPORT_SYMBOL(netdev_features_change);
766void netdev_state_change(struct net_device *dev) 766void netdev_state_change(struct net_device *dev)
767{ 767{
768 if (dev->flags & IFF_UP) { 768 if (dev->flags & IFF_UP) {
769 blocking_notifier_call_chain(&netdev_chain, 769 raw_notifier_call_chain(&netdev_chain,
770 NETDEV_CHANGE, dev); 770 NETDEV_CHANGE, dev);
771 rtmsg_ifinfo(RTM_NEWLINK, dev, 0); 771 rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
772 } 772 }
@@ -864,7 +864,7 @@ int dev_open(struct net_device *dev)
864 /* 864 /*
865 * ... and announce new interface. 865 * ... and announce new interface.
866 */ 866 */
867 blocking_notifier_call_chain(&netdev_chain, NETDEV_UP, dev); 867 raw_notifier_call_chain(&netdev_chain, NETDEV_UP, dev);
868 } 868 }
869 return ret; 869 return ret;
870} 870}
@@ -887,7 +887,7 @@ int dev_close(struct net_device *dev)
887 * Tell people we are going down, so that they can 887 * Tell people we are going down, so that they can
888 * prepare to death, when device is still operating. 888 * prepare to death, when device is still operating.
889 */ 889 */
890 blocking_notifier_call_chain(&netdev_chain, NETDEV_GOING_DOWN, dev); 890 raw_notifier_call_chain(&netdev_chain, NETDEV_GOING_DOWN, dev);
891 891
892 dev_deactivate(dev); 892 dev_deactivate(dev);
893 893
@@ -924,7 +924,7 @@ int dev_close(struct net_device *dev)
924 /* 924 /*
925 * Tell people we are down 925 * Tell people we are down
926 */ 926 */
927 blocking_notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev); 927 raw_notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev);
928 928
929 return 0; 929 return 0;
930} 930}
@@ -955,7 +955,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
955 int err; 955 int err;
956 956
957 rtnl_lock(); 957 rtnl_lock();
958 err = blocking_notifier_chain_register(&netdev_chain, nb); 958 err = raw_notifier_chain_register(&netdev_chain, nb);
959 if (!err) { 959 if (!err) {
960 for (dev = dev_base; dev; dev = dev->next) { 960 for (dev = dev_base; dev; dev = dev->next) {
961 nb->notifier_call(nb, NETDEV_REGISTER, dev); 961 nb->notifier_call(nb, NETDEV_REGISTER, dev);
@@ -983,7 +983,7 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
983 int err; 983 int err;
984 984
985 rtnl_lock(); 985 rtnl_lock();
986 err = blocking_notifier_chain_unregister(&netdev_chain, nb); 986 err = raw_notifier_chain_unregister(&netdev_chain, nb);
987 rtnl_unlock(); 987 rtnl_unlock();
988 return err; 988 return err;
989} 989}
@@ -994,12 +994,12 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
994 * @v: pointer passed unmodified to notifier function 994 * @v: pointer passed unmodified to notifier function
995 * 995 *
996 * Call all network notifier blocks. Parameters and return value 996 * Call all network notifier blocks. Parameters and return value
997 * are as for blocking_notifier_call_chain(). 997 * are as for raw_notifier_call_chain().
998 */ 998 */
999 999
1000int call_netdevice_notifiers(unsigned long val, void *v) 1000int call_netdevice_notifiers(unsigned long val, void *v)
1001{ 1001{
1002 return blocking_notifier_call_chain(&netdev_chain, val, v); 1002 return raw_notifier_call_chain(&netdev_chain, val, v);
1003} 1003}
1004 1004
1005/* When > 0 there are consumers of rx skb time stamps */ 1005/* 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 if (dev->flags & IFF_UP && 2308 if (dev->flags & IFF_UP &&
2309 ((old_flags ^ dev->flags) &~ (IFF_UP | IFF_PROMISC | IFF_ALLMULTI | 2309 ((old_flags ^ dev->flags) &~ (IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
2310 IFF_VOLATILE))) 2310 IFF_VOLATILE)))
2311 blocking_notifier_call_chain(&netdev_chain, 2311 raw_notifier_call_chain(&netdev_chain,
2312 NETDEV_CHANGE, dev); 2312 NETDEV_CHANGE, dev);
2313 2313
2314 if ((flags ^ dev->gflags) & IFF_PROMISC) { 2314 if ((flags ^ dev->gflags) & IFF_PROMISC) {
@@ -2353,7 +2353,7 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
2353 else 2353 else
2354 dev->mtu = new_mtu; 2354 dev->mtu = new_mtu;
2355 if (!err && dev->flags & IFF_UP) 2355 if (!err && dev->flags & IFF_UP)
2356 blocking_notifier_call_chain(&netdev_chain, 2356 raw_notifier_call_chain(&netdev_chain,
2357 NETDEV_CHANGEMTU, dev); 2357 NETDEV_CHANGEMTU, dev);
2358 return err; 2358 return err;
2359} 2359}
@@ -2370,7 +2370,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
2370 return -ENODEV; 2370 return -ENODEV;
2371 err = dev->set_mac_address(dev, sa); 2371 err = dev->set_mac_address(dev, sa);
2372 if (!err) 2372 if (!err)
2373 blocking_notifier_call_chain(&netdev_chain, 2373 raw_notifier_call_chain(&netdev_chain,
2374 NETDEV_CHANGEADDR, dev); 2374 NETDEV_CHANGEADDR, dev);
2375 return err; 2375 return err;
2376} 2376}
@@ -2427,7 +2427,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
2427 return -EINVAL; 2427 return -EINVAL;
2428 memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data, 2428 memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
2429 min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len)); 2429 min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
2430 blocking_notifier_call_chain(&netdev_chain, 2430 raw_notifier_call_chain(&netdev_chain,
2431 NETDEV_CHANGEADDR, dev); 2431 NETDEV_CHANGEADDR, dev);
2432 return 0; 2432 return 0;
2433 2433
@@ -2882,7 +2882,7 @@ int register_netdevice(struct net_device *dev)
2882 write_unlock_bh(&dev_base_lock); 2882 write_unlock_bh(&dev_base_lock);
2883 2883
2884 /* Notify protocols, that a new device appeared. */ 2884 /* Notify protocols, that a new device appeared. */
2885 blocking_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev); 2885 raw_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
2886 2886
2887 /* Finish registration after unlock */ 2887 /* Finish registration after unlock */
2888 net_set_todo(dev); 2888 net_set_todo(dev);
@@ -2961,7 +2961,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
2961 rtnl_lock(); 2961 rtnl_lock();
2962 2962
2963 /* Rebroadcast unregister notification */ 2963 /* Rebroadcast unregister notification */
2964 blocking_notifier_call_chain(&netdev_chain, 2964 raw_notifier_call_chain(&netdev_chain,
2965 NETDEV_UNREGISTER, dev); 2965 NETDEV_UNREGISTER, dev);
2966 2966
2967 if (test_bit(__LINK_STATE_LINKWATCH_PENDING, 2967 if (test_bit(__LINK_STATE_LINKWATCH_PENDING,
@@ -3216,7 +3216,7 @@ int unregister_netdevice(struct net_device *dev)
3216 /* Notify protocols, that we are about to destroy 3216 /* Notify protocols, that we are about to destroy
3217 this device. They should clean all the things. 3217 this device. They should clean all the things.
3218 */ 3218 */
3219 blocking_notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev); 3219 raw_notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev);
3220 3220
3221 /* 3221 /*
3222 * Flush the multicast chain 3222 * Flush the multicast chain