aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-07-31 14:29:07 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-04 08:52:57 -0400
commit5d8d9a4d9ff74c55901642b4e2ac5124830ddafe (patch)
tree9f171aa61048cf5c154597466af21ea7c4d701a2 /net
parentd05dd4e98f0dd30ee933e05ac9363614c47df83a (diff)
NFS: Ensure the AUTH_UNIX credcache is allocated dynamically
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth.c19
-rw-r--r--net/sunrpc/auth_generic.c12
-rw-r--r--net/sunrpc/auth_unix.c15
-rw-r--r--net/sunrpc/sunrpc_syms.c15
4 files changed, 36 insertions, 25 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 73affb8624fa..db135543d21e 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -587,14 +587,27 @@ static struct shrinker rpc_cred_shrinker = {
587 .seeks = DEFAULT_SEEKS, 587 .seeks = DEFAULT_SEEKS,
588}; 588};
589 589
590void __init rpcauth_init_module(void) 590int __init rpcauth_init_module(void)
591{ 591{
592 rpc_init_authunix(); 592 int err;
593 rpc_init_generic_auth(); 593
594 err = rpc_init_authunix();
595 if (err < 0)
596 goto out1;
597 err = rpc_init_generic_auth();
598 if (err < 0)
599 goto out2;
594 register_shrinker(&rpc_cred_shrinker); 600 register_shrinker(&rpc_cred_shrinker);
601 return 0;
602out2:
603 rpc_destroy_authunix();
604out1:
605 return err;
595} 606}
596 607
597void __exit rpcauth_remove_module(void) 608void __exit rpcauth_remove_module(void)
598{ 609{
610 rpc_destroy_authunix();
611 rpc_destroy_generic_auth();
599 unregister_shrinker(&rpc_cred_shrinker); 612 unregister_shrinker(&rpc_cred_shrinker);
600} 613}
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 8f623b0f03dd..8bae33b36cc6 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -27,7 +27,6 @@ struct generic_cred {
27}; 27};
28 28
29static struct rpc_auth generic_auth; 29static struct rpc_auth generic_auth;
30static struct rpc_cred_cache generic_cred_cache;
31static const struct rpc_credops generic_credops; 30static const struct rpc_credops generic_credops;
32 31
33/* 32/*
@@ -159,20 +158,16 @@ out_nomatch:
159 return 0; 158 return 0;
160} 159}
161 160
162void __init rpc_init_generic_auth(void) 161int __init rpc_init_generic_auth(void)
163{ 162{
164 spin_lock_init(&generic_cred_cache.lock); 163 return rpcauth_init_credcache(&generic_auth);
165} 164}
166 165
167void __exit rpc_destroy_generic_auth(void) 166void __exit rpc_destroy_generic_auth(void)
168{ 167{
169 rpcauth_clear_credcache(&generic_cred_cache); 168 rpcauth_destroy_credcache(&generic_auth);
170} 169}
171 170
172static struct rpc_cred_cache generic_cred_cache = {
173 {{ NULL, },},
174};
175
176static const struct rpc_authops generic_auth_ops = { 171static const struct rpc_authops generic_auth_ops = {
177 .owner = THIS_MODULE, 172 .owner = THIS_MODULE,
178 .au_name = "Generic", 173 .au_name = "Generic",
@@ -183,7 +178,6 @@ static const struct rpc_authops generic_auth_ops = {
183static struct rpc_auth generic_auth = { 178static struct rpc_auth generic_auth = {
184 .au_ops = &generic_auth_ops, 179 .au_ops = &generic_auth_ops,
185 .au_count = ATOMIC_INIT(0), 180 .au_count = ATOMIC_INIT(0),
186 .au_credcache = &generic_cred_cache,
187}; 181};
188 182
189static const struct rpc_credops generic_credops = { 183static const struct rpc_credops generic_credops = {
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index aac2f8b4ee21..d5e37dbf207b 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -29,7 +29,6 @@ struct unx_cred {
29#endif 29#endif
30 30
31static struct rpc_auth unix_auth; 31static struct rpc_auth unix_auth;
32static struct rpc_cred_cache unix_cred_cache;
33static const struct rpc_credops unix_credops; 32static const struct rpc_credops unix_credops;
34 33
35static struct rpc_auth * 34static struct rpc_auth *
@@ -203,9 +202,14 @@ unx_validate(struct rpc_task *task, __be32 *p)
203 return p; 202 return p;
204} 203}
205 204
206void __init rpc_init_authunix(void) 205int __init rpc_init_authunix(void)
207{ 206{
208 spin_lock_init(&unix_cred_cache.lock); 207 return rpcauth_init_credcache(&unix_auth);
208}
209
210void rpc_destroy_authunix(void)
211{
212 rpcauth_destroy_credcache(&unix_auth);
209} 213}
210 214
211const struct rpc_authops authunix_ops = { 215const struct rpc_authops authunix_ops = {
@@ -219,17 +223,12 @@ const struct rpc_authops authunix_ops = {
219}; 223};
220 224
221static 225static
222struct rpc_cred_cache unix_cred_cache = {
223};
224
225static
226struct rpc_auth unix_auth = { 226struct rpc_auth unix_auth = {
227 .au_cslack = UNX_WRITESLACK, 227 .au_cslack = UNX_WRITESLACK,
228 .au_rslack = 2, /* assume AUTH_NULL verf */ 228 .au_rslack = 2, /* assume AUTH_NULL verf */
229 .au_ops = &authunix_ops, 229 .au_ops = &authunix_ops,
230 .au_flavor = RPC_AUTH_UNIX, 230 .au_flavor = RPC_AUTH_UNIX,
231 .au_count = ATOMIC_INIT(0), 231 .au_count = ATOMIC_INIT(0),
232 .au_credcache = &unix_cred_cache,
233}; 232};
234 233
235static 234static
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index f438347d817b..34b58f9e704a 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -33,10 +33,11 @@ init_sunrpc(void)
33 if (err) 33 if (err)
34 goto out; 34 goto out;
35 err = rpc_init_mempool(); 35 err = rpc_init_mempool();
36 if (err) { 36 if (err)
37 unregister_rpc_pipefs(); 37 goto out2;
38 goto out; 38 err = rpcauth_init_module();
39 } 39 if (err)
40 goto out3;
40#ifdef RPC_DEBUG 41#ifdef RPC_DEBUG
41 rpc_register_sysctl(); 42 rpc_register_sysctl();
42#endif 43#endif
@@ -47,7 +48,11 @@ init_sunrpc(void)
47 cache_register(&unix_gid_cache); 48 cache_register(&unix_gid_cache);
48 svc_init_xprt_sock(); /* svc sock transport */ 49 svc_init_xprt_sock(); /* svc sock transport */
49 init_socket_xprt(); /* clnt sock transport */ 50 init_socket_xprt(); /* clnt sock transport */
50 rpcauth_init_module(); 51 return 0;
52out3:
53 rpc_destroy_mempool();
54out2:
55 unregister_rpc_pipefs();
51out: 56out:
52 return err; 57 return err;
53} 58}