Commit 378e5f26 authored by Trond Myklebust's avatar Trond Myklebust

RPC: kill cr_auth

 The cr_auth field is currently used only in order to figure out the name
 of the credential's flavour in debugging printks. Replace with a dedicated
 pointer in the statically allocated rpc_credops instead.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 2fc8c6f3
...@@ -36,7 +36,6 @@ struct auth_cred { ...@@ -36,7 +36,6 @@ struct auth_cred {
*/ */
struct rpc_cred { struct rpc_cred {
struct list_head cr_hash; /* hash chain */ struct list_head cr_hash; /* hash chain */
struct rpc_auth * cr_auth;
struct rpc_credops * cr_ops; struct rpc_credops * cr_ops;
unsigned long cr_expire; /* when to gc */ unsigned long cr_expire; /* when to gc */
atomic_t cr_count; /* ref count */ atomic_t cr_count; /* ref count */
...@@ -96,6 +95,7 @@ struct rpc_authops { ...@@ -96,6 +95,7 @@ struct rpc_authops {
}; };
struct rpc_credops { struct rpc_credops {
const char * cr_name; /* Name of the auth flavour */
void (*crdestroy)(struct rpc_cred *); void (*crdestroy)(struct rpc_cred *);
int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
......
...@@ -129,7 +129,6 @@ rpcauth_free_credcache(struct rpc_auth *auth) ...@@ -129,7 +129,6 @@ rpcauth_free_credcache(struct rpc_auth *auth)
for (i = 0; i < RPC_CREDCACHE_NR; i++) { for (i = 0; i < RPC_CREDCACHE_NR; i++) {
list_for_each_safe(pos, next, &auth->au_credcache[i]) { list_for_each_safe(pos, next, &auth->au_credcache[i]) {
cred = list_entry(pos, struct rpc_cred, cr_hash); cred = list_entry(pos, struct rpc_cred, cr_hash);
cred->cr_auth = NULL;
list_move(&cred->cr_hash, &free); list_move(&cred->cr_hash, &free);
} }
} }
...@@ -138,16 +137,14 @@ rpcauth_free_credcache(struct rpc_auth *auth) ...@@ -138,16 +137,14 @@ rpcauth_free_credcache(struct rpc_auth *auth)
} }
static void static void
rpcauth_prune_expired(struct rpc_cred *cred, struct list_head *free) rpcauth_prune_expired(struct rpc_auth *auth, struct rpc_cred *cred, struct list_head *free)
{ {
if (atomic_read(&cred->cr_count) != 1) if (atomic_read(&cred->cr_count) != 1)
return; return;
if (time_after(jiffies, cred->cr_expire + cred->cr_auth->au_expire)) if (time_after(jiffies, cred->cr_expire + auth->au_expire))
cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE)) { if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE))
cred->cr_auth = NULL;
list_move(&cred->cr_hash, free); list_move(&cred->cr_hash, free);
}
} }
/* /*
...@@ -164,7 +161,7 @@ rpcauth_gc_credcache(struct rpc_auth *auth, struct list_head *free) ...@@ -164,7 +161,7 @@ rpcauth_gc_credcache(struct rpc_auth *auth, struct list_head *free)
for (i = 0; i < RPC_CREDCACHE_NR; i++) { for (i = 0; i < RPC_CREDCACHE_NR; i++) {
list_for_each_safe(pos, next, &auth->au_credcache[i]) { list_for_each_safe(pos, next, &auth->au_credcache[i]) {
cred = list_entry(pos, struct rpc_cred, cr_hash); cred = list_entry(pos, struct rpc_cred, cr_hash);
rpcauth_prune_expired(cred, free); rpcauth_prune_expired(auth, cred, free);
} }
} }
auth->au_nextgc = jiffies + auth->au_expire; auth->au_nextgc = jiffies + auth->au_expire;
...@@ -197,7 +194,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred, ...@@ -197,7 +194,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
cred = entry; cred = entry;
break; break;
} }
rpcauth_prune_expired(entry, &free); rpcauth_prune_expired(auth, entry, &free);
} }
if (new) { if (new) {
if (cred) if (cred)
...@@ -207,7 +204,6 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred, ...@@ -207,7 +204,6 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
} }
if (cred) { if (cred) {
list_add(&cred->cr_hash, &auth->au_credcache[nr]); list_add(&cred->cr_hash, &auth->au_credcache[nr]);
cred->cr_auth = auth;
get_rpccred(cred); get_rpccred(cred);
} }
spin_unlock(&rpc_credcache_lock); spin_unlock(&rpc_credcache_lock);
...@@ -328,7 +324,7 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, ...@@ -328,7 +324,7 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp,
struct rpc_cred *cred = task->tk_msg.rpc_cred; struct rpc_cred *cred = task->tk_msg.rpc_cred;
dprintk("RPC: %4d using %s cred %p to wrap rpc data\n", dprintk("RPC: %4d using %s cred %p to wrap rpc data\n",
task->tk_pid, cred->cr_auth->au_ops->au_name, cred); task->tk_pid, cred->cr_ops->cr_name, cred);
if (cred->cr_ops->crwrap_req) if (cred->cr_ops->crwrap_req)
return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj);
/* By default, we encode the arguments normally. */ /* By default, we encode the arguments normally. */
...@@ -342,7 +338,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, ...@@ -342,7 +338,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
struct rpc_cred *cred = task->tk_msg.rpc_cred; struct rpc_cred *cred = task->tk_msg.rpc_cred;
dprintk("RPC: %4d using %s cred %p to unwrap rpc data\n", dprintk("RPC: %4d using %s cred %p to unwrap rpc data\n",
task->tk_pid, cred->cr_auth->au_ops->au_name, cred); task->tk_pid, cred->cr_ops->cr_name, cred);
if (cred->cr_ops->crunwrap_resp) if (cred->cr_ops->crunwrap_resp)
return cred->cr_ops->crunwrap_resp(task, decode, rqstp, return cred->cr_ops->crunwrap_resp(task, decode, rqstp,
data, obj); data, obj);
......
...@@ -1018,6 +1018,7 @@ static struct rpc_authops authgss_ops = { ...@@ -1018,6 +1018,7 @@ static struct rpc_authops authgss_ops = {
}; };
static struct rpc_credops gss_credops = { static struct rpc_credops gss_credops = {
.cr_name = "AUTH_GSS",
.crdestroy = gss_destroy_cred, .crdestroy = gss_destroy_cred,
.crmatch = gss_match, .crmatch = gss_match,
.crmarshal = gss_marshal, .crmarshal = gss_marshal,
......
...@@ -150,6 +150,7 @@ struct rpc_authops authnull_ops = { ...@@ -150,6 +150,7 @@ struct rpc_authops authnull_ops = {
static static
struct rpc_credops null_credops = { struct rpc_credops null_credops = {
.cr_name = "AUTH_NULL",
.crdestroy = nul_destroy_cred, .crdestroy = nul_destroy_cred,
.crmatch = nul_match, .crmatch = nul_match,
.crmarshal = nul_marshal, .crmarshal = nul_marshal,
......
...@@ -240,6 +240,7 @@ struct rpc_authops authunix_ops = { ...@@ -240,6 +240,7 @@ struct rpc_authops authunix_ops = {
static static
struct rpc_credops unix_credops = { struct rpc_credops unix_credops = {
.cr_name = "AUTH_UNIX",
.crdestroy = unx_destroy_cred, .crdestroy = unx_destroy_cred,
.crmatch = unx_match, .crmatch = unx_match,
.crmarshal = unx_marshal, .crmarshal = unx_marshal,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment