@@ -6416,28 +6416,41 @@ static int __net_init bond_net_init(struct net *net)
6416
6416
return 0 ;
6417
6417
}
6418
6418
6419
- static void __net_exit bond_net_exit_batch (struct list_head * net_list )
6419
+ /* According to commit 69b0216ac255 ("bonding: fix bonding_masters
6420
+ * race condition in bond unloading") we need to remove sysfs files
6421
+ * before we remove our devices (done later in bond_net_exit_batch_rtnl())
6422
+ */
6423
+ static void __net_exit bond_net_pre_exit (struct net * net )
6424
+ {
6425
+ struct bond_net * bn = net_generic (net , bond_net_id );
6426
+
6427
+ bond_destroy_sysfs (bn );
6428
+ }
6429
+
6430
+ static void __net_exit bond_net_exit_batch_rtnl (struct list_head * net_list ,
6431
+ struct list_head * dev_kill_list )
6420
6432
{
6421
6433
struct bond_net * bn ;
6422
6434
struct net * net ;
6423
- LIST_HEAD (list );
6424
-
6425
- list_for_each_entry (net , net_list , exit_list ) {
6426
- bn = net_generic (net , bond_net_id );
6427
- bond_destroy_sysfs (bn );
6428
- }
6429
6435
6430
6436
/* Kill off any bonds created after unregistering bond rtnl ops */
6431
- rtnl_lock ();
6432
6437
list_for_each_entry (net , net_list , exit_list ) {
6433
6438
struct bonding * bond , * tmp_bond ;
6434
6439
6435
6440
bn = net_generic (net , bond_net_id );
6436
6441
list_for_each_entry_safe (bond , tmp_bond , & bn -> dev_list , bond_list )
6437
- unregister_netdevice_queue (bond -> dev , & list );
6442
+ unregister_netdevice_queue (bond -> dev , dev_kill_list );
6438
6443
}
6439
- unregister_netdevice_many (& list );
6440
- rtnl_unlock ();
6444
+ }
6445
+
6446
+ /* According to commit 23fa5c2caae0 ("bonding: destroy proc directory
6447
+ * only after all bonds are gone") bond_destroy_proc_dir() is called
6448
+ * after bond_net_exit_batch_rtnl() has completed.
6449
+ */
6450
+ static void __net_exit bond_net_exit_batch (struct list_head * net_list )
6451
+ {
6452
+ struct bond_net * bn ;
6453
+ struct net * net ;
6441
6454
6442
6455
list_for_each_entry (net , net_list , exit_list ) {
6443
6456
bn = net_generic (net , bond_net_id );
@@ -6447,6 +6460,8 @@ static void __net_exit bond_net_exit_batch(struct list_head *net_list)
6447
6460
6448
6461
static struct pernet_operations bond_net_ops = {
6449
6462
.init = bond_net_init ,
6463
+ .pre_exit = bond_net_pre_exit ,
6464
+ .exit_batch_rtnl = bond_net_exit_batch_rtnl ,
6450
6465
.exit_batch = bond_net_exit_batch ,
6451
6466
.id = & bond_net_id ,
6452
6467
.size = sizeof (struct bond_net ),
0 commit comments