blob: f9edaa9174a439ae598a4d9fa501a7c998ac8951 [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
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040026#include "netns.h"
27
Alexey Dobriyanc7d03a02016-11-17 04:58:21 +030028unsigned int sunrpc_net_id;
Stanislav Kinsburskya1db4102012-01-19 21:42:37 +040029EXPORT_SYMBOL_GPL(sunrpc_net_id);
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040030
31static __net_init int sunrpc_init_net(struct net *net)
32{
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040033 int err;
Stanislav Kinsbursky70abc492012-01-12 22:07:51 +040034 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040035
36 err = rpc_proc_init(net);
37 if (err)
38 goto err_proc;
39
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040040 err = ip_map_cache_create(net);
41 if (err)
42 goto err_ipmap;
43
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040044 err = unix_gid_cache_create(net);
45 if (err)
46 goto err_unixgid;
47
Jeff Layton4b9a4452013-11-14 07:25:17 -050048 err = rpc_pipefs_init_net(net);
49 if (err)
50 goto err_pipefs;
51
Stanislav Kinsbursky70abc492012-01-12 22:07:51 +040052 INIT_LIST_HEAD(&sn->all_clients);
53 spin_lock_init(&sn->rpc_client_lock);
Stanislav Kinsbursky1d96e802012-02-16 17:42:12 +040054 spin_lock_init(&sn->rpcb_clnt_lock);
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040055 return 0;
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040056
Jeff Layton4b9a4452013-11-14 07:25:17 -050057err_pipefs:
58 unix_gid_cache_destroy(net);
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040059err_unixgid:
60 ip_map_cache_destroy(net);
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040061err_ipmap:
62 rpc_proc_exit(net);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040063err_proc:
64 return err;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040065}
66
67static __net_exit void sunrpc_exit_net(struct net *net)
68{
Vasily Averin4112be72017-11-12 11:48:43 +030069 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
70
Jeff Layton4b9a4452013-11-14 07:25:17 -050071 rpc_pipefs_exit_net(net);
Stanislav Kinsbursky73393232012-01-19 21:42:29 +040072 unix_gid_cache_destroy(net);
Pavel Emelyanov90d51b02010-09-27 14:02:29 +040073 ip_map_cache_destroy(net);
Pavel Emelyanov4f42d0d2010-09-27 14:01:58 +040074 rpc_proc_exit(net);
Vasily Averin4112be72017-11-12 11:48:43 +030075 WARN_ON_ONCE(!list_empty(&sn->all_clients));
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040076}
77
78static struct pernet_operations sunrpc_net_ops = {
79 .init = sunrpc_init_net,
80 .exit = sunrpc_exit_net,
81 .id = &sunrpc_net_id,
82 .size = sizeof(struct sunrpc_net),
83};
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085static int __init
86init_sunrpc(void)
87{
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +040088 int err = rpc_init_mempool();
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 if (err)
90 goto out;
Trond Myklebust5d8d9a42010-07-31 14:29:07 -040091 err = rpcauth_init_module();
92 if (err)
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +040093 goto out2;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +040094
95 cache_initialize();
96
97 err = register_pernet_subsys(&sunrpc_net_ops);
98 if (err)
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +040099 goto out3;
100
101 err = register_rpc_pipefs();
102 if (err)
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400103 goto out4;
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -0500104
Jeff Laytonf9c72d12015-03-31 12:03:28 -0400105 sunrpc_debugfs_init();
Jeff Laytonf895b252014-11-17 16:58:04 -0500106#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 rpc_register_sysctl();
108#endif
Tom Tucker360d87382007-12-30 21:07:17 -0600109 svc_init_xprt_sock(); /* svc sock transport */
110 init_socket_xprt(); /* clnt sock transport */
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400111 return 0;
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400112
113out4:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400114 unregister_pernet_subsys(&sunrpc_net_ops);
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400115out3:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400116 rpcauth_remove_module();
Trond Myklebust5d8d9a42010-07-31 14:29:07 -0400117out2:
Stanislav Kinsburskyadae0fe2012-04-05 21:04:37 +0400118 rpc_destroy_mempool();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119out:
120 return err;
121}
122
123static void __exit
124cleanup_sunrpc(void)
125{
Kinglong Meec929ea02017-01-20 16:48:39 +0800126 rpc_cleanup_clids();
Trond Myklebustf5c21872007-06-25 17:11:20 -0400127 rpcauth_remove_module();
Chuck Lever282b32e2006-12-05 16:35:51 -0500128 cleanup_socket_xprt();
Tom Tucker360d87382007-12-30 21:07:17 -0600129 svc_cleanup_xprt_sock();
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -0500130 sunrpc_debugfs_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 unregister_rpc_pipefs();
132 rpc_destroy_mempool();
Pavel Emelyanov2f72c9b2010-09-27 14:01:27 +0400133 unregister_pernet_subsys(&sunrpc_net_ops);
Jeff Laytonf895b252014-11-17 16:58:04 -0500134#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 rpc_unregister_sysctl();
136#endif
Jesper Dangaard Brouer75de8742009-06-26 10:45:58 +0000137 rcu_barrier(); /* Wait for completion of call_rcu()'s */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138}
139MODULE_LICENSE("GPL");
Trond Myklebust405d8f82009-08-21 08:17:56 -0400140fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141module_exit(cleanup_sunrpc);