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 10 #include <linux/module.h> 11 12 #include <linux/types.h> 13 #include <linux/uio.h> 14 #include <linux/unistd.h> 15 #include <linux/init.h> 16 17 #include <linux/sunrpc/sched.h> 18 #include <linux/sunrpc/clnt.h> 19 #include <linux/sunrpc/svc.h> 20 #include <linux/sunrpc/svcsock.h> 21 #include <linux/sunrpc/auth.h> 22 #include <linux/workqueue.h> 23 #include <linux/sunrpc/rpc_pipe_fs.h> 24 #include <linux/sunrpc/xprtsock.h> 25 26 #include <net/genetlink.h> 27 28 #include "sunrpc.h" 29 #include "sysfs.h" 30 #include "netns.h" 31 #include "netlink.h" 32 33 unsigned int sunrpc_net_id; 34 EXPORT_SYMBOL_GPL(sunrpc_net_id); 35 36 static __net_init int sunrpc_init_net(struct net *net) 37 { 38 int err; 39 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 40 41 err = rpc_proc_init(net); 42 if (err) 43 goto err_proc; 44 45 err = ip_map_cache_create(net); 46 if (err) 47 goto err_ipmap; 48 49 err = unix_gid_cache_create(net); 50 if (err) 51 goto err_unixgid; 52 53 err = rpc_pipefs_init_net(net); 54 if (err) 55 goto err_pipefs; 56 57 INIT_LIST_HEAD(&sn->all_clients); 58 spin_lock_init(&sn->rpc_client_lock); 59 spin_lock_init(&sn->rpcb_clnt_lock); 60 return 0; 61 62 err_pipefs: 63 unix_gid_cache_destroy(net); 64 err_unixgid: 65 ip_map_cache_destroy(net); 66 err_ipmap: 67 rpc_proc_exit(net); 68 err_proc: 69 return err; 70 } 71 72 static __net_exit void sunrpc_exit_net(struct net *net) 73 { 74 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 75 76 rpc_pipefs_exit_net(net); 77 unix_gid_cache_destroy(net); 78 ip_map_cache_destroy(net); 79 rpc_proc_exit(net); 80 WARN_ON_ONCE(!list_empty(&sn->all_clients)); 81 } 82 83 static struct pernet_operations sunrpc_net_ops = { 84 .init = sunrpc_init_net, 85 .exit = sunrpc_exit_net, 86 .id = &sunrpc_net_id, 87 .size = sizeof(struct sunrpc_net), 88 }; 89 90 static int __init 91 init_sunrpc(void) 92 { 93 int err = rpc_init_mempool(); 94 if (err) 95 goto out; 96 err = rpcauth_init_module(); 97 if (err) 98 goto out2; 99 100 cache_initialize(); 101 102 err = register_pernet_subsys(&sunrpc_net_ops); 103 if (err) 104 goto out3; 105 106 err = register_rpc_pipefs(); 107 if (err) 108 goto out4; 109 110 err = rpc_sysfs_init(); 111 if (err) 112 goto out5; 113 114 err = genl_register_family(&sunrpc_nl_family); 115 if (err) 116 goto out6; 117 118 sunrpc_debugfs_init(); 119 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 120 rpc_register_sysctl(); 121 #endif 122 svc_init_xprt_sock(); /* svc sock transport */ 123 init_socket_xprt(); /* clnt sock transport */ 124 return 0; 125 126 out6: 127 rpc_sysfs_exit(); 128 out5: 129 unregister_rpc_pipefs(); 130 out4: 131 unregister_pernet_subsys(&sunrpc_net_ops); 132 out3: 133 rpcauth_remove_module(); 134 out2: 135 rpc_destroy_mempool(); 136 out: 137 return err; 138 } 139 140 static void __exit 141 cleanup_sunrpc(void) 142 { 143 genl_unregister_family(&sunrpc_nl_family); 144 rpc_sysfs_exit(); 145 rpc_cleanup_clids(); 146 xprt_cleanup_ids(); 147 xprt_multipath_cleanup_ids(); 148 rpcauth_remove_module(); 149 cleanup_socket_xprt(); 150 svc_cleanup_xprt_sock(); 151 sunrpc_debugfs_exit(); 152 unregister_rpc_pipefs(); 153 rpc_destroy_mempool(); 154 unregister_pernet_subsys(&sunrpc_net_ops); 155 auth_domain_cleanup(); 156 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 157 rpc_unregister_sysctl(); 158 #endif 159 rcu_barrier(); /* Wait for completion of call_rcu()'s */ 160 } 161 MODULE_DESCRIPTION("Sun RPC core"); 162 MODULE_LICENSE("GPL"); 163 fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */ 164 module_exit(cleanup_sunrpc); 165