@@ -558,39 +558,6 @@ static __net_init int rds_tcp_init_net(struct net *net)
558
558
return err ;
559
559
}
560
560
561
- static void __net_exit rds_tcp_exit_net (struct net * net )
562
- {
563
- struct rds_tcp_net * rtn = net_generic (net , rds_tcp_netid );
564
-
565
- if (rtn -> rds_tcp_sysctl )
566
- unregister_net_sysctl_table (rtn -> rds_tcp_sysctl );
567
-
568
- if (net != & init_net && rtn -> ctl_table )
569
- kfree (rtn -> ctl_table );
570
-
571
- /* If rds_tcp_exit_net() is called as a result of netns deletion,
572
- * the rds_tcp_kill_sock() device notifier would already have cleaned
573
- * up the listen socket, thus there is no work to do in this function.
574
- *
575
- * If rds_tcp_exit_net() is called as a result of module unload,
576
- * i.e., due to rds_tcp_exit() -> unregister_pernet_subsys(), then
577
- * we do need to clean up the listen socket here.
578
- */
579
- if (rtn -> rds_tcp_listen_sock ) {
580
- struct socket * lsock = rtn -> rds_tcp_listen_sock ;
581
-
582
- rtn -> rds_tcp_listen_sock = NULL ;
583
- rds_tcp_listen_stop (lsock , & rtn -> rds_tcp_accept_w );
584
- }
585
- }
586
-
587
- static struct pernet_operations rds_tcp_net_ops = {
588
- .init = rds_tcp_init_net ,
589
- .exit = rds_tcp_exit_net ,
590
- .id = & rds_tcp_netid ,
591
- .size = sizeof (struct rds_tcp_net ),
592
- };
593
-
594
561
/* explicitly send a RST on each socket, thereby releasing any socket refcnts
595
562
* that may otherwise hold up netns deletion.
596
563
*/
@@ -637,40 +604,37 @@ static void rds_tcp_kill_sock(struct net *net)
637
604
}
638
605
}
639
606
640
- void * rds_tcp_listen_sock_def_readable (struct net * net )
607
+ static void __net_exit rds_tcp_exit_net (struct net * net )
641
608
{
642
609
struct rds_tcp_net * rtn = net_generic (net , rds_tcp_netid );
643
- struct socket * lsock = rtn -> rds_tcp_listen_sock ;
644
610
645
- if (!lsock )
646
- return NULL ;
611
+ rds_tcp_kill_sock (net );
647
612
648
- return lsock -> sk -> sk_user_data ;
613
+ if (rtn -> rds_tcp_sysctl )
614
+ unregister_net_sysctl_table (rtn -> rds_tcp_sysctl );
615
+
616
+ if (net != & init_net && rtn -> ctl_table )
617
+ kfree (rtn -> ctl_table );
649
618
}
650
619
651
- static int rds_tcp_dev_event (struct notifier_block * this ,
652
- unsigned long event , void * ptr )
620
+ static struct pernet_operations rds_tcp_net_ops = {
621
+ .init = rds_tcp_init_net ,
622
+ .exit = rds_tcp_exit_net ,
623
+ .id = & rds_tcp_netid ,
624
+ .size = sizeof (struct rds_tcp_net ),
625
+ };
626
+
627
+ void * rds_tcp_listen_sock_def_readable (struct net * net )
653
628
{
654
- struct net_device * dev = netdev_notifier_info_to_dev (ptr );
629
+ struct rds_tcp_net * rtn = net_generic (net , rds_tcp_netid );
630
+ struct socket * lsock = rtn -> rds_tcp_listen_sock ;
655
631
656
- /* rds-tcp registers as a pernet subys, so the ->exit will only
657
- * get invoked after network acitivity has quiesced. We need to
658
- * clean up all sockets to quiesce network activity, and use
659
- * the unregistration of the per-net loopback device as a trigger
660
- * to start that cleanup.
661
- */
662
- if (event == NETDEV_UNREGISTER_FINAL &&
663
- dev -> ifindex == LOOPBACK_IFINDEX )
664
- rds_tcp_kill_sock (dev_net (dev ));
632
+ if (!lsock )
633
+ return NULL ;
665
634
666
- return NOTIFY_DONE ;
635
+ return lsock -> sk -> sk_user_data ;
667
636
}
668
637
669
- static struct notifier_block rds_tcp_dev_notifier = {
670
- .notifier_call = rds_tcp_dev_event ,
671
- .priority = -10 , /* must be called after other network notifiers */
672
- };
673
-
674
638
/* when sysctl is used to modify some kernel socket parameters,this
675
639
* function resets the RDS connections in that netns so that we can
676
640
* restart with new parameters. The assumption is that such reset
@@ -717,9 +681,7 @@ static void __exit rds_tcp_exit(void)
717
681
#if IS_ENABLED (CONFIG_IPV6 )
718
682
rds_info_deregister_func (RDS6_INFO_TCP_SOCKETS , rds6_tcp_tc_info );
719
683
#endif
720
- unregister_pernet_subsys (& rds_tcp_net_ops );
721
- if (unregister_netdevice_notifier (& rds_tcp_dev_notifier ))
722
- pr_warn ("could not unregister rds_tcp_dev_notifier\n" );
684
+ unregister_pernet_device (& rds_tcp_net_ops );
723
685
rds_tcp_destroy_conns ();
724
686
rds_trans_unregister (& rds_tcp_transport );
725
687
rds_tcp_recv_exit ();
@@ -743,16 +705,10 @@ static int __init rds_tcp_init(void)
743
705
if (ret )
744
706
goto out_slab ;
745
707
746
- ret = register_pernet_subsys (& rds_tcp_net_ops );
708
+ ret = register_pernet_device (& rds_tcp_net_ops );
747
709
if (ret )
748
710
goto out_recv ;
749
711
750
- ret = register_netdevice_notifier (& rds_tcp_dev_notifier );
751
- if (ret ) {
752
- pr_warn ("could not register rds_tcp_dev_notifier\n" );
753
- goto out_pernet ;
754
- }
755
-
756
712
ret = rds_trans_register (& rds_tcp_transport );
757
713
758
714
rds_info_register_func (RDS_INFO_TCP_SOCKETS , rds_tcp_tc_info );
@@ -762,8 +718,6 @@ static int __init rds_tcp_init(void)
762
718
763
719
goto out ;
764
720
765
- out_pernet :
766
- unregister_pernet_subsys (& rds_tcp_net_ops );
767
721
out_recv :
768
722
rds_tcp_recv_exit ();
769
723
out_slab :
0 commit comments