aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-12 16:20:55 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-14 13:42:35 -0400
commit4ccda2cdd8d156b6f49440653d5d6997e0facf97 (patch)
treefd75203f002edfd1657c9ca7bcb5494a7b783cf1
parentaf093835774931de898a9baf7b4041fa0d100f77 (diff)
SUNRPC: Clean up rpcauth_bindcred()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--include/linux/sunrpc/auth.h4
-rw-r--r--net/sunrpc/auth.c28
-rw-r--r--net/sunrpc/sched.c11
3 files changed, 23 insertions, 20 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 012566a6257b..348546c7826c 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -135,9 +135,7 @@ void rpcauth_release(struct rpc_auth *);
135struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); 135struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
136void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); 136void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
137struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); 137struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int);
138void rpcauth_bindcred(struct rpc_task *); 138void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int);
139void rpcauth_bind_root_cred(struct rpc_task *);
140void rpcauth_holdcred(struct rpc_task *);
141void put_rpccred(struct rpc_cred *); 139void put_rpccred(struct rpc_cred *);
142void rpcauth_unbindcred(struct rpc_task *); 140void rpcauth_unbindcred(struct rpc_task *);
143__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); 141__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *);
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index b0f2b2ee7cc0..1cdb163c4f89 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -375,7 +375,15 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
375} 375}
376EXPORT_SYMBOL_GPL(rpcauth_init_cred); 376EXPORT_SYMBOL_GPL(rpcauth_init_cred);
377 377
378void 378static void
379rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred)
380{
381 task->tk_msg.rpc_cred = get_rpccred(cred);
382 dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid,
383 cred->cr_auth->au_ops->au_name, cred);
384}
385
386static void
379rpcauth_bind_root_cred(struct rpc_task *task) 387rpcauth_bind_root_cred(struct rpc_task *task)
380{ 388{
381 struct rpc_auth *auth = task->tk_client->cl_auth; 389 struct rpc_auth *auth = task->tk_client->cl_auth;
@@ -394,8 +402,8 @@ rpcauth_bind_root_cred(struct rpc_task *task)
394 task->tk_status = PTR_ERR(ret); 402 task->tk_status = PTR_ERR(ret);
395} 403}
396 404
397void 405static void
398rpcauth_bindcred(struct rpc_task *task) 406rpcauth_bind_new_cred(struct rpc_task *task)
399{ 407{
400 struct rpc_auth *auth = task->tk_client->cl_auth; 408 struct rpc_auth *auth = task->tk_client->cl_auth;
401 struct rpc_cred *ret; 409 struct rpc_cred *ret;
@@ -410,14 +418,14 @@ rpcauth_bindcred(struct rpc_task *task)
410} 418}
411 419
412void 420void
413rpcauth_holdcred(struct rpc_task *task) 421rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
414{ 422{
415 struct rpc_cred *cred = task->tk_msg.rpc_cred; 423 if (cred != NULL)
416 if (cred != NULL) { 424 rpcauth_generic_bind_cred(task, cred);
417 get_rpccred(cred); 425 else if (flags & RPC_TASK_ROOTCREDS)
418 dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, 426 rpcauth_bind_root_cred(task);
419 cred->cr_auth->au_ops->au_name, cred); 427 else
420 } 428 rpcauth_bind_new_cred(task);
421} 429}
422 430
423void 431void
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 7db956f6e018..6eab9bf94baf 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -817,14 +817,11 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
817 task->tk_action = rpc_prepare_task; 817 task->tk_action = rpc_prepare_task;
818 818
819 if (task_setup_data->rpc_message != NULL) { 819 if (task_setup_data->rpc_message != NULL) {
820 memcpy(&task->tk_msg, task_setup_data->rpc_message, sizeof(task->tk_msg)); 820 task->tk_msg.rpc_proc = task_setup_data->rpc_message->rpc_proc;
821 task->tk_msg.rpc_argp = task_setup_data->rpc_message->rpc_argp;
822 task->tk_msg.rpc_resp = task_setup_data->rpc_message->rpc_resp;
821 /* Bind the user cred */ 823 /* Bind the user cred */
822 if (task->tk_msg.rpc_cred != NULL) 824 rpcauth_bindcred(task, task_setup_data->rpc_message->rpc_cred, task_setup_data->flags);
823 rpcauth_holdcred(task);
824 else if (!(task_setup_data->flags & RPC_TASK_ROOTCREDS))
825 rpcauth_bindcred(task);
826 else
827 rpcauth_bind_root_cred(task);
828 if (task->tk_action == NULL) 825 if (task->tk_action == NULL)
829 rpc_call_start(task); 826 rpc_call_start(task);
830 } 827 }