@@ -168,28 +168,6 @@ static int call_netdevice_notifiers_extack(unsigned long val,
168
168
struct net_device * dev ,
169
169
struct netlink_ext_ack * extack );
170
170
171
- /*
172
- * The @dev_base_head list is protected by @dev_base_lock and the rtnl
173
- * semaphore.
174
- *
175
- * Pure readers hold dev_base_lock for reading, or rcu_read_lock()
176
- *
177
- * Writers must hold the rtnl semaphore while they loop through the
178
- * dev_base_head list, and hold dev_base_lock for writing when they do the
179
- * actual updates. This allows pure readers to access the list even
180
- * while a writer is preparing to update it.
181
- *
182
- * To put it another way, dev_base_lock is held for writing only to
183
- * protect against pure readers; the rtnl semaphore provides the
184
- * protection against other writers.
185
- *
186
- * See, for example usages, register_netdevice() and
187
- * unregister_netdevice(), which must be called with the rtnl
188
- * semaphore held.
189
- */
190
- DEFINE_RWLOCK (dev_base_lock );
191
- EXPORT_SYMBOL (dev_base_lock );
192
-
193
171
static DEFINE_MUTEX (ifalias_mutex );
194
172
195
173
/* protects napi_hash addition/deletion and napi_gen_id */
@@ -395,12 +373,10 @@ static void list_netdevice(struct net_device *dev)
395
373
396
374
ASSERT_RTNL ();
397
375
398
- write_lock (& dev_base_lock );
399
376
list_add_tail_rcu (& dev -> dev_list , & net -> dev_base_head );
400
377
netdev_name_node_add (net , dev -> name_node );
401
378
hlist_add_head_rcu (& dev -> index_hlist ,
402
379
dev_index_hash (net , dev -> ifindex ));
403
- write_unlock (& dev_base_lock );
404
380
405
381
netdev_for_each_altname (dev , name_node )
406
382
netdev_name_node_add (net , name_node );
@@ -427,11 +403,9 @@ static void unlist_netdevice(struct net_device *dev)
427
403
netdev_name_node_del (name_node );
428
404
429
405
/* Unlink dev from the device chain */
430
- write_lock (& dev_base_lock );
431
406
list_del_rcu (& dev -> dev_list );
432
407
netdev_name_node_del (dev -> name_node );
433
408
hlist_del_rcu (& dev -> index_hlist );
434
- write_unlock (& dev_base_lock );
435
409
436
410
dev_base_seq_inc (dev_net (dev ));
437
411
}
@@ -752,9 +726,9 @@ EXPORT_SYMBOL_GPL(dev_fill_forward_path);
752
726
* @net: the applicable net namespace
753
727
* @name: name to find
754
728
*
755
- * Find an interface by name. Must be called under RTNL semaphore
756
- * or @dev_base_lock. If the name is found a pointer to the device
757
- * is returned. If the name is not found then %NULL is returned. The
729
+ * Find an interface by name. Must be called under RTNL semaphore.
730
+ * If the name is found a pointer to the device is returned.
731
+ * If the name is not found then %NULL is returned. The
758
732
* reference counters are not incremented so the caller must be
759
733
* careful with locks.
760
734
*/
@@ -835,8 +809,7 @@ EXPORT_SYMBOL(netdev_get_by_name);
835
809
* Search for an interface by index. Returns %NULL if the device
836
810
* is not found or a pointer to the device. The device has not
837
811
* had its reference counter increased so the caller must be careful
838
- * about locking. The caller must hold either the RTNL semaphore
839
- * or @dev_base_lock.
812
+ * about locking. The caller must hold the RTNL semaphore.
840
813
*/
841
814
842
815
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
1214
1242
1215
netdev_adjacent_rename_links (dev , oldname );
1243
1216
1244
- write_lock (& dev_base_lock );
1245
1217
netdev_name_node_del (dev -> name_node );
1246
- write_unlock (& dev_base_lock );
1247
1218
1248
1219
synchronize_net ();
1249
1220
1250
- write_lock (& dev_base_lock );
1251
1221
netdev_name_node_add (net , dev -> name_node );
1252
- write_unlock (& dev_base_lock );
1253
1222
1254
1223
ret = call_netdevice_notifiers (NETDEV_CHANGENAME , dev );
1255
1224
ret = notifier_to_errno (ret );
0 commit comments