diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-07-31 14:29:07 -0400 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-08-04 08:52:57 -0400 |
| commit | 5d8d9a4d9ff74c55901642b4e2ac5124830ddafe (patch) | |
| tree | 9f171aa61048cf5c154597466af21ea7c4d701a2 | |
| parent | d05dd4e98f0dd30ee933e05ac9363614c47df83a (diff) | |
NFS: Ensure the AUTH_UNIX credcache is allocated dynamically
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
| -rw-r--r-- | include/linux/sunrpc/auth.h | 7 | ||||
| -rw-r--r-- | net/sunrpc/auth.c | 19 | ||||
| -rw-r--r-- | net/sunrpc/auth_generic.c | 12 | ||||
| -rw-r--r-- | net/sunrpc/auth_unix.c | 15 | ||||
| -rw-r--r-- | net/sunrpc/sunrpc_syms.c | 15 |
5 files changed, 40 insertions, 28 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 87d7ec0bf779..784e78c73ec5 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h | |||
| @@ -125,11 +125,12 @@ struct rpc_credops { | |||
| 125 | extern const struct rpc_authops authunix_ops; | 125 | extern const struct rpc_authops authunix_ops; |
| 126 | extern const struct rpc_authops authnull_ops; | 126 | extern const struct rpc_authops authnull_ops; |
| 127 | 127 | ||
| 128 | void __init rpc_init_authunix(void); | 128 | int __init rpc_init_authunix(void); |
| 129 | void __init rpc_init_generic_auth(void); | 129 | int __init rpc_init_generic_auth(void); |
| 130 | void __init rpcauth_init_module(void); | 130 | int __init rpcauth_init_module(void); |
| 131 | void __exit rpcauth_remove_module(void); | 131 | void __exit rpcauth_remove_module(void); |
| 132 | void __exit rpc_destroy_generic_auth(void); | 132 | void __exit rpc_destroy_generic_auth(void); |
| 133 | void rpc_destroy_authunix(void); | ||
| 133 | 134 | ||
| 134 | struct rpc_cred * rpc_lookup_cred(void); | 135 | struct rpc_cred * rpc_lookup_cred(void); |
| 135 | struct rpc_cred * rpc_lookup_machine_cred(void); | 136 | struct rpc_cred * rpc_lookup_machine_cred(void); |
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 | ||
| 590 | void __init rpcauth_init_module(void) | 590 | int __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; | ||
| 602 | out2: | ||
| 603 | rpc_destroy_authunix(); | ||
| 604 | out1: | ||
| 605 | return err; | ||
| 595 | } | 606 | } |
| 596 | 607 | ||
| 597 | void __exit rpcauth_remove_module(void) | 608 | void __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 | ||
| 29 | static struct rpc_auth generic_auth; | 29 | static struct rpc_auth generic_auth; |
| 30 | static struct rpc_cred_cache generic_cred_cache; | ||
| 31 | static const struct rpc_credops generic_credops; | 30 | static 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 | ||
| 162 | void __init rpc_init_generic_auth(void) | 161 | int __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 | ||
| 167 | void __exit rpc_destroy_generic_auth(void) | 166 | void __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 | ||
| 172 | static struct rpc_cred_cache generic_cred_cache = { | ||
| 173 | {{ NULL, },}, | ||
| 174 | }; | ||
| 175 | |||
| 176 | static const struct rpc_authops generic_auth_ops = { | 171 | static 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 = { | |||
| 183 | static struct rpc_auth generic_auth = { | 178 | static 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 | ||
| 189 | static const struct rpc_credops generic_credops = { | 183 | static 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 | ||
| 31 | static struct rpc_auth unix_auth; | 31 | static struct rpc_auth unix_auth; |
| 32 | static struct rpc_cred_cache unix_cred_cache; | ||
| 33 | static const struct rpc_credops unix_credops; | 32 | static const struct rpc_credops unix_credops; |
| 34 | 33 | ||
| 35 | static struct rpc_auth * | 34 | static 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 | ||
| 206 | void __init rpc_init_authunix(void) | 205 | int __init rpc_init_authunix(void) |
| 207 | { | 206 | { |
| 208 | spin_lock_init(&unix_cred_cache.lock); | 207 | return rpcauth_init_credcache(&unix_auth); |
| 208 | } | ||
| 209 | |||
| 210 | void rpc_destroy_authunix(void) | ||
| 211 | { | ||
| 212 | rpcauth_destroy_credcache(&unix_auth); | ||
| 209 | } | 213 | } |
| 210 | 214 | ||
| 211 | const struct rpc_authops authunix_ops = { | 215 | const struct rpc_authops authunix_ops = { |
| @@ -219,17 +223,12 @@ const struct rpc_authops authunix_ops = { | |||
| 219 | }; | 223 | }; |
| 220 | 224 | ||
| 221 | static | 225 | static |
| 222 | struct rpc_cred_cache unix_cred_cache = { | ||
| 223 | }; | ||
| 224 | |||
| 225 | static | ||
| 226 | struct rpc_auth unix_auth = { | 226 | struct 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 | ||
| 235 | static | 234 | static |
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; |
| 52 | out3: | ||
| 53 | rpc_destroy_mempool(); | ||
| 54 | out2: | ||
| 55 | unregister_rpc_pipefs(); | ||
| 51 | out: | 56 | out: |
| 52 | return err; | 57 | return err; |
| 53 | } | 58 | } |
