Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/net/sunrpc/sunrpc_syms.c
0004  *
0005  * Symbols exported by the sunrpc module.
0006  *
0007  * Copyright (C) 1997 Olaf Kirch <okir@monad.swb.de>
0008  */
0009 
0010 #include <linux/module.h>
0011 
0012 #include <linux/types.h>
0013 #include <linux/uio.h>
0014 #include <linux/unistd.h>
0015 #include <linux/init.h>
0016 
0017 #include <linux/sunrpc/sched.h>
0018 #include <linux/sunrpc/clnt.h>
0019 #include <linux/sunrpc/svc.h>
0020 #include <linux/sunrpc/svcsock.h>
0021 #include <linux/sunrpc/auth.h>
0022 #include <linux/workqueue.h>
0023 #include <linux/sunrpc/rpc_pipe_fs.h>
0024 #include <linux/sunrpc/xprtsock.h>
0025 
0026 #include "sunrpc.h"
0027 #include "sysfs.h"
0028 #include "netns.h"
0029 
0030 unsigned int sunrpc_net_id;
0031 EXPORT_SYMBOL_GPL(sunrpc_net_id);
0032 
0033 static __net_init int sunrpc_init_net(struct net *net)
0034 {
0035     int err;
0036     struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
0037 
0038     err = rpc_proc_init(net);
0039     if (err)
0040         goto err_proc;
0041 
0042     err = ip_map_cache_create(net);
0043     if (err)
0044         goto err_ipmap;
0045 
0046     err = unix_gid_cache_create(net);
0047     if (err)
0048         goto err_unixgid;
0049 
0050     err = rpc_pipefs_init_net(net);
0051     if (err)
0052         goto err_pipefs;
0053 
0054     INIT_LIST_HEAD(&sn->all_clients);
0055     spin_lock_init(&sn->rpc_client_lock);
0056     spin_lock_init(&sn->rpcb_clnt_lock);
0057     return 0;
0058 
0059 err_pipefs:
0060     unix_gid_cache_destroy(net);
0061 err_unixgid:
0062     ip_map_cache_destroy(net);
0063 err_ipmap:
0064     rpc_proc_exit(net);
0065 err_proc:
0066     return err;
0067 }
0068 
0069 static __net_exit void sunrpc_exit_net(struct net *net)
0070 {
0071     struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
0072 
0073     rpc_pipefs_exit_net(net);
0074     unix_gid_cache_destroy(net);
0075     ip_map_cache_destroy(net);
0076     rpc_proc_exit(net);
0077     WARN_ON_ONCE(!list_empty(&sn->all_clients));
0078 }
0079 
0080 static struct pernet_operations sunrpc_net_ops = {
0081     .init = sunrpc_init_net,
0082     .exit = sunrpc_exit_net,
0083     .id = &sunrpc_net_id,
0084     .size = sizeof(struct sunrpc_net),
0085 };
0086 
0087 static int __init
0088 init_sunrpc(void)
0089 {
0090     int err = rpc_init_mempool();
0091     if (err)
0092         goto out;
0093     err = rpcauth_init_module();
0094     if (err)
0095         goto out2;
0096 
0097     cache_initialize();
0098 
0099     err = register_pernet_subsys(&sunrpc_net_ops);
0100     if (err)
0101         goto out3;
0102 
0103     err = register_rpc_pipefs();
0104     if (err)
0105         goto out4;
0106 
0107     err = rpc_sysfs_init();
0108     if (err)
0109         goto out5;
0110 
0111     sunrpc_debugfs_init();
0112 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
0113     rpc_register_sysctl();
0114 #endif
0115     svc_init_xprt_sock();   /* svc sock transport */
0116     init_socket_xprt(); /* clnt sock transport */
0117     return 0;
0118 
0119 out5:
0120     unregister_rpc_pipefs();
0121 out4:
0122     unregister_pernet_subsys(&sunrpc_net_ops);
0123 out3:
0124     rpcauth_remove_module();
0125 out2:
0126     rpc_destroy_mempool();
0127 out:
0128     return err;
0129 }
0130 
0131 static void __exit
0132 cleanup_sunrpc(void)
0133 {
0134     rpc_sysfs_exit();
0135     rpc_cleanup_clids();
0136     xprt_cleanup_ids();
0137     xprt_multipath_cleanup_ids();
0138     rpcauth_remove_module();
0139     cleanup_socket_xprt();
0140     svc_cleanup_xprt_sock();
0141     sunrpc_debugfs_exit();
0142     unregister_rpc_pipefs();
0143     rpc_destroy_mempool();
0144     unregister_pernet_subsys(&sunrpc_net_ops);
0145     auth_domain_cleanup();
0146 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
0147     rpc_unregister_sysctl();
0148 #endif
0149     rcu_barrier(); /* Wait for completion of call_rcu()'s */
0150 }
0151 MODULE_LICENSE("GPL");
0152 fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
0153 module_exit(cleanup_sunrpc);