sunrpc_syms.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 <okir@monad.swb.de>
  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 "netns.h"
  24. unsigned int sunrpc_net_id;
  25. EXPORT_SYMBOL_GPL(sunrpc_net_id);
  26. static __net_init int sunrpc_init_net(struct net *net)
  27. {
  28. int err;
  29. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  30. err = rpc_proc_init(net);
  31. if (err)
  32. goto err_proc;
  33. err = ip_map_cache_create(net);
  34. if (err)
  35. goto err_ipmap;
  36. err = unix_gid_cache_create(net);
  37. if (err)
  38. goto err_unixgid;
  39. err = rpc_pipefs_init_net(net);
  40. if (err)
  41. goto err_pipefs;
  42. INIT_LIST_HEAD(&sn->all_clients);
  43. spin_lock_init(&sn->rpc_client_lock);
  44. spin_lock_init(&sn->rpcb_clnt_lock);
  45. return 0;
  46. err_pipefs:
  47. unix_gid_cache_destroy(net);
  48. err_unixgid:
  49. ip_map_cache_destroy(net);
  50. err_ipmap:
  51. rpc_proc_exit(net);
  52. err_proc:
  53. return err;
  54. }
  55. static __net_exit void sunrpc_exit_net(struct net *net)
  56. {
  57. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  58. rpc_pipefs_exit_net(net);
  59. unix_gid_cache_destroy(net);
  60. ip_map_cache_destroy(net);
  61. rpc_proc_exit(net);
  62. WARN_ON_ONCE(!list_empty(&sn->all_clients));
  63. }
  64. static struct pernet_operations sunrpc_net_ops = {
  65. .init = sunrpc_init_net,
  66. .exit = sunrpc_exit_net,
  67. .id = &sunrpc_net_id,
  68. .size = sizeof(struct sunrpc_net),
  69. };
  70. static int __init
  71. init_sunrpc(void)
  72. {
  73. int err = rpc_init_mempool();
  74. if (err)
  75. goto out;
  76. err = rpcauth_init_module();
  77. if (err)
  78. goto out2;
  79. cache_initialize();
  80. err = register_pernet_subsys(&sunrpc_net_ops);
  81. if (err)
  82. goto out3;
  83. err = register_rpc_pipefs();
  84. if (err)
  85. goto out4;
  86. sunrpc_debugfs_init();
  87. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  88. rpc_register_sysctl();
  89. #endif
  90. svc_init_xprt_sock(); /* svc sock transport */
  91. init_socket_xprt(); /* clnt sock transport */
  92. return 0;
  93. out4:
  94. unregister_pernet_subsys(&sunrpc_net_ops);
  95. out3:
  96. rpcauth_remove_module();
  97. out2:
  98. rpc_destroy_mempool();
  99. out:
  100. return err;
  101. }
  102. static void __exit
  103. cleanup_sunrpc(void)
  104. {
  105. rpc_cleanup_clids();
  106. rpcauth_remove_module();
  107. cleanup_socket_xprt();
  108. svc_cleanup_xprt_sock();
  109. sunrpc_debugfs_exit();
  110. unregister_rpc_pipefs();
  111. rpc_destroy_mempool();
  112. unregister_pernet_subsys(&sunrpc_net_ops);
  113. auth_domain_cleanup();
  114. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  115. rpc_unregister_sysctl();
  116. #endif
  117. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  118. }
  119. MODULE_LICENSE("GPL");
  120. MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
  121. fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
  122. module_exit(cleanup_sunrpc);