blob: 6c320623cdcd7c715dbc74a63bb6779212bf97aa [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/module.h>
11
12#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#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>
\"Talpey, Thomas\49c36fc2007-09-10 13:47:31 -040024#include <linux/sunrpc/xprtsock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
NeilBrownf45db2b2020-05-22 12:01:32 +100026#include "sunrpc.h"
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040027#include "netns.h"
28
Alexey Dobriyanc7d03a02016-11-17 04:58:21 +030029unsigned int sunrpc_net_id;
Stanislav Kinsburskya1db4102012-01-19 21:42:37 +040030EXPORT_SYMBOL_GPL(sunrpc_net_id);
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040031
32static __net_init int sunrpc_init_net(struct net *net)
33{
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040034 int err;
Stanislav Kinsbursky70abc492012-01-12 22:07:51 +040035 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040036
37 err = rpc_proc_init(net);
38 if (err)
39 goto err_proc;
40
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040041 err = ip_map_cache_create(net);
42 if (err)
43 goto err_ipmap;
44
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040045 err = unix_gid_cache_create(net);
46 if (err)
47 goto err_unixgid;
48
Jeff Layton4b9a4452013-11-14 07:25:17 -050049 err = rpc_pipefs_init_net(net);
50 if (err)
51 goto err_pipefs;
52
Stanislav Kinsbursky70abc492012-01-12 22:07:51 +040053 INIT_LIST_HEAD(&sn->all_clients);
54 spin_lock_init(&sn->rpc_client_lock);
Stanislav Kinsbursky1d96e802012-02-16 17:42:12 +040055 spin_lock_init(&sn->rpcb_clnt_lock);
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040056 return 0;
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040057
Jeff Layton4b9a4452013-11-14 07:25:17 -050058err_pipefs:
59 unix_gid_cache_destroy(net);
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040060err_unixgid:
61 ip_map_cache_destroy(net);
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040062err_ipmap:
63 rpc_proc_exit(net);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040064err_proc:
65 return err;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040066}
67
68static __net_exit void sunrpc_exit_net(struct net *net)
69{
Vasily Averin4112be72017-11-12 11:48:43 +030070 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
71
Jeff Layton4b9a4452013-11-14 07:25:17 -050072 rpc_pipefs_exit_net(net);
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040073 unix_gid_cache_destroy(net);
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040074 ip_map_cache_destroy(net);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040075 rpc_proc_exit(net);
Vasily Averin4112be72017-11-12 11:48:43 +030076 WARN_ON_ONCE(!list_empty(&sn->all_clients));
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040077}
78
79static struct pernet_operations sunrpc_net_ops = {
80 .init = sunrpc_init_net,
81 .exit = sunrpc_exit_net,
82 .id = &sunrpc_net_id,
83 .size = sizeof(struct sunrpc_net),
84};
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static int __init
87init_sunrpc(void)
88{
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +040089 int err = rpc_init_mempool();
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 if (err)
91 goto out;
Trond Myklebust5d8d9a42010-07-31 14:29:07 -040092 err = rpcauth_init_module();
93 if (err)
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +040094 goto out2;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040095
96 cache_initialize();
97
98 err = register_pernet_subsys(&sunrpc_net_ops);
99 if (err)
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400100 goto out3;
101
102 err = register_rpc_pipefs();
103 if (err)
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400104 goto out4;
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -0500105
Jeff Laytonf9c72d12015-03-31 12:03:28 -0400106 sunrpc_debugfs_init();
Jeff Laytonf895b252014-11-17 16:58:04 -0500107#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 rpc_register_sysctl();
109#endif
Tom Tucker360d87382007-12-30 21:07:17 -0600110 svc_init_xprt_sock(); /* svc sock transport */
111 init_socket_xprt(); /* clnt sock transport */
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400112 return 0;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400113
114out4:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400115 unregister_pernet_subsys(&sunrpc_net_ops);
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400116out3:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400117 rpcauth_remove_module();
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400118out2:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400119 rpc_destroy_mempool();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120out:
121 return err;
122}
123
124static void __exit
125cleanup_sunrpc(void)
126{
Kinglong Meec929ea02017-01-20 16:48:39 +0800127 rpc_cleanup_clids();
Trond Myklebustf5c21872007-06-25 17:11:20 -0400128 rpcauth_remove_module();
Chuck Lever282b32e2006-12-05 16:35:51 -0500129 cleanup_socket_xprt();
Tom Tucker360d87382007-12-30 21:07:17 -0600130 svc_cleanup_xprt_sock();
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -0500131 sunrpc_debugfs_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 unregister_rpc_pipefs();
133 rpc_destroy_mempool();
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400134 unregister_pernet_subsys(&sunrpc_net_ops);
NeilBrownf45db2b2020-05-22 12:01:32 +1000135 auth_domain_cleanup();
Jeff Laytonf895b252014-11-17 16:58:04 -0500136#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 rpc_unregister_sysctl();
138#endif
Jesper Dangaard Brouer75de8742009-06-26 10:45:58 +0000139 rcu_barrier(); /* Wait for completion of call_rcu()'s */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140}
141MODULE_LICENSE("GPL");
Greg Kroah-Hartmand483eed2020-07-02 12:51:03 +0200142MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
Trond Myklebust405d8f82009-08-21 08:17:56 -0400143fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144module_exit(cleanup_sunrpc);