Commit 1b3ef46c authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: remove dev_base_lock

dev_base_lock is not needed anymore, all remaining users also hold RTNL.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e51b9624
...@@ -3077,8 +3077,6 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev); ...@@ -3077,8 +3077,6 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
int call_netdevice_notifiers_info(unsigned long val, int call_netdevice_notifiers_info(unsigned long val,
struct netdev_notifier_info *info); struct netdev_notifier_info *info);
extern rwlock_t dev_base_lock; /* Device list lock */
#define for_each_netdev(net, d) \ #define for_each_netdev(net, d) \
list_for_each_entry(d, &(net)->dev_base_head, dev_list) list_for_each_entry(d, &(net)->dev_base_head, dev_list)
#define for_each_netdev_reverse(net, d) \ #define for_each_netdev_reverse(net, d) \
......
...@@ -168,28 +168,6 @@ static int call_netdevice_notifiers_extack(unsigned long val, ...@@ -168,28 +168,6 @@ static int call_netdevice_notifiers_extack(unsigned long val,
struct net_device *dev, struct net_device *dev,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
/*
* The @dev_base_head list is protected by @dev_base_lock and the rtnl
* semaphore.
*
* Pure readers hold dev_base_lock for reading, or rcu_read_lock()
*
* Writers must hold the rtnl semaphore while they loop through the
* dev_base_head list, and hold dev_base_lock for writing when they do the
* actual updates. This allows pure readers to access the list even
* while a writer is preparing to update it.
*
* To put it another way, dev_base_lock is held for writing only to
* protect against pure readers; the rtnl semaphore provides the
* protection against other writers.
*
* See, for example usages, register_netdevice() and
* unregister_netdevice(), which must be called with the rtnl
* semaphore held.
*/
DEFINE_RWLOCK(dev_base_lock);
EXPORT_SYMBOL(dev_base_lock);
static DEFINE_MUTEX(ifalias_mutex); static DEFINE_MUTEX(ifalias_mutex);
/* protects napi_hash addition/deletion and napi_gen_id */ /* protects napi_hash addition/deletion and napi_gen_id */
...@@ -395,12 +373,10 @@ static void list_netdevice(struct net_device *dev) ...@@ -395,12 +373,10 @@ static void list_netdevice(struct net_device *dev)
ASSERT_RTNL(); ASSERT_RTNL();
write_lock(&dev_base_lock);
list_add_tail_rcu(&dev->dev_list, &net->dev_base_head); list_add_tail_rcu(&dev->dev_list, &net->dev_base_head);
netdev_name_node_add(net, dev->name_node); netdev_name_node_add(net, dev->name_node);
hlist_add_head_rcu(&dev->index_hlist, hlist_add_head_rcu(&dev->index_hlist,
dev_index_hash(net, dev->ifindex)); dev_index_hash(net, dev->ifindex));
write_unlock(&dev_base_lock);
netdev_for_each_altname(dev, name_node) netdev_for_each_altname(dev, name_node)
netdev_name_node_add(net, name_node); netdev_name_node_add(net, name_node);
...@@ -427,11 +403,9 @@ static void unlist_netdevice(struct net_device *dev) ...@@ -427,11 +403,9 @@ static void unlist_netdevice(struct net_device *dev)
netdev_name_node_del(name_node); netdev_name_node_del(name_node);
/* Unlink dev from the device chain */ /* Unlink dev from the device chain */
write_lock(&dev_base_lock);
list_del_rcu(&dev->dev_list); list_del_rcu(&dev->dev_list);
netdev_name_node_del(dev->name_node); netdev_name_node_del(dev->name_node);
hlist_del_rcu(&dev->index_hlist); hlist_del_rcu(&dev->index_hlist);
write_unlock(&dev_base_lock);
dev_base_seq_inc(dev_net(dev)); dev_base_seq_inc(dev_net(dev));
} }
...@@ -752,9 +726,9 @@ EXPORT_SYMBOL_GPL(dev_fill_forward_path); ...@@ -752,9 +726,9 @@ EXPORT_SYMBOL_GPL(dev_fill_forward_path);
* @net: the applicable net namespace * @net: the applicable net namespace
* @name: name to find * @name: name to find
* *
* Find an interface by name. Must be called under RTNL semaphore * Find an interface by name. Must be called under RTNL semaphore.
* or @dev_base_lock. If the name is found a pointer to the device * If the name is found a pointer to the device is returned.
* is returned. If the name is not found then %NULL is returned. The * If the name is not found then %NULL is returned. The
* reference counters are not incremented so the caller must be * reference counters are not incremented so the caller must be
* careful with locks. * careful with locks.
*/ */
...@@ -835,8 +809,7 @@ EXPORT_SYMBOL(netdev_get_by_name); ...@@ -835,8 +809,7 @@ EXPORT_SYMBOL(netdev_get_by_name);
* Search for an interface by index. Returns %NULL if the device * Search for an interface by index. Returns %NULL if the device
* is not found or a pointer to the device. The device has not * is not found or a pointer to the device. The device has not
* had its reference counter increased so the caller must be careful * had its reference counter increased so the caller must be careful
* about locking. The caller must hold either the RTNL semaphore * about locking. The caller must hold the RTNL semaphore.
* or @dev_base_lock.
*/ */
struct net_device *__dev_get_by_index(struct net *net, int ifindex) struct net_device *__dev_get_by_index(struct net *net, int ifindex)
...@@ -1241,15 +1214,11 @@ int dev_change_name(struct net_device *dev, const char *newname) ...@@ -1241,15 +1214,11 @@ int dev_change_name(struct net_device *dev, const char *newname)
netdev_adjacent_rename_links(dev, oldname); netdev_adjacent_rename_links(dev, oldname);
write_lock(&dev_base_lock);
netdev_name_node_del(dev->name_node); netdev_name_node_del(dev->name_node);
write_unlock(&dev_base_lock);
synchronize_net(); synchronize_net();
write_lock(&dev_base_lock);
netdev_name_node_add(net, dev->name_node); netdev_name_node_add(net, dev->name_node);
write_unlock(&dev_base_lock);
ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev); ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev);
ret = notifier_to_errno(ret); ret = notifier_to_errno(ret);
......
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