sunrpc_syms.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/net/sunrpc/sunrpc_syms.c
  4. *
  5. * Symbols exported by the sunrpc module.
  6. *
  7. * Copyright (C) 1997 Olaf Kirch <[email protected]>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/types.h>
  11. #include <linux/uio.h>
  12. #include <linux/unistd.h>
  13. #include <linux/init.h>
  14. #include <linux/sunrpc/sched.h>
  15. #include <linux/sunrpc/clnt.h>
  16. #include <linux/sunrpc/svc.h>
  17. #include <linux/sunrpc/svcsock.h>
  18. #include <linux/sunrpc/auth.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/sunrpc/rpc_pipe_fs.h>
  21. #include <linux/sunrpc/xprtsock.h>
  22. #include "sunrpc.h"
  23. #include "sysfs.h"
  24. #include "netns.h"
  25. unsigned int sunrpc_net_id;
  26. EXPORT_SYMBOL_GPL(sunrpc_net_id);
  27. static __net_init int sunrpc_init_net(struct net *net)
  28. {
  29. int err;
  30. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  31. err = rpc_proc_init(net);
  32. if (err)
  33. goto err_proc;
  34. err = ip_map_cache_create(net);
  35. if (err)
  36. goto err_ipmap;
  37. err = unix_gid_cache_create(net);
  38. if (err)
  39. goto err_unixgid;
  40. err = rpc_pipefs_init_net(net);
  41. if (err)
  42. goto err_pipefs;
  43. INIT_LIST_HEAD(&sn->all_clients);
  44. spin_lock_init(&sn->rpc_client_lock);
  45. spin_lock_init(&sn->rpcb_clnt_lock);
  46. return 0;
  47. err_pipefs:
  48. unix_gid_cache_destroy(net);
  49. err_unixgid:
  50. ip_map_cache_destroy(net);
  51. err_ipmap:
  52. rpc_proc_exit(net);
  53. err_proc:
  54. return err;
  55. }
  56. static __net_exit void sunrpc_exit_net(struct net *net)
  57. {
  58. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  59. rpc_pipefs_exit_net(net);
  60. unix_gid_cache_destroy(net);
  61. ip_map_cache_destroy(net);
  62. rpc_proc_exit(net);
  63. WARN_ON_ONCE(!list_empty(&sn->all_clients));
  64. }
  65. static struct pernet_operations sunrpc_net_ops = {
  66. .init = sunrpc_init_net,
  67. .exit = sunrpc_exit_net,
  68. .id = &sunrpc_net_id,
  69. .size = sizeof(struct sunrpc_net),
  70. };
  71. static int __init
  72. init_sunrpc(void)
  73. {
  74. int err = rpc_init_mempool();
  75. if (err)
  76. goto out;
  77. err = rpcauth_init_module();
  78. if (err)
  79. goto out2;
  80. cache_initialize();
  81. err = register_pernet_subsys(&sunrpc_net_ops);
  82. if (err)
  83. goto out3;
  84. err = register_rpc_pipefs();
  85. if (err)
  86. goto out4;
  87. err = rpc_sysfs_init();
  88. if (err)
  89. goto out5;
  90. sunrpc_debugfs_init();
  91. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  92. rpc_register_sysctl();
  93. #endif
  94. svc_init_xprt_sock(); /* svc sock transport */
  95. init_socket_xprt(); /* clnt sock transport */
  96. return 0;
  97. out5:
  98. unregister_rpc_pipefs();
  99. out4:
  100. unregister_pernet_subsys(&sunrpc_net_ops);
  101. out3:
  102. rpcauth_remove_module();
  103. out2:
  104. rpc_destroy_mempool();
  105. out:
  106. return err;
  107. }
  108. static void __exit
  109. cleanup_sunrpc(void)
  110. {
  111. rpc_sysfs_exit();
  112. rpc_cleanup_clids();
  113. xprt_cleanup_ids();
  114. xprt_multipath_cleanup_ids();
  115. rpcauth_remove_module();
  116. cleanup_socket_xprt();
  117. svc_cleanup_xprt_sock();
  118. sunrpc_debugfs_exit();
  119. unregister_rpc_pipefs();
  120. rpc_destroy_mempool();
  121. unregister_pernet_subsys(&sunrpc_net_ops);
  122. auth_domain_cleanup();
  123. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  124. rpc_unregister_sysctl();
  125. #endif
  126. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  127. }
  128. MODULE_LICENSE("GPL");
  129. fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
  130. module_exit(cleanup_sunrpc);