diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-07-31 14:29:08 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-08-04 08:54:09 -0400 |
commit | a17c2153d2e271b0cbacae9bed83b0eaa41db7e1 (patch) | |
tree | 3c5a73090987278e51aee1a9f185ebe40a00bd65 /net/sunrpc/auth.c | |
parent | 8572b8e2e3c5f3d990122348c4d2c64dad338611 (diff) |
SUNRPC: Move the bound cred to struct rpc_rqst
This will allow us to save the original generic cred in rpc_message, so
that if we migrate from one server to another, we can generate a new bound
cred without having to punt back to the NFS layer.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r-- | net/sunrpc/auth.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index d8968faf5ccf..95721426296d 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -477,9 +477,10 @@ rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) | |||
477 | return rpcauth_lookupcred(auth, lookupflags); | 477 | return rpcauth_lookupcred(auth, lookupflags); |
478 | } | 478 | } |
479 | 479 | ||
480 | int | 480 | static int |
481 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | 481 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) |
482 | { | 482 | { |
483 | struct rpc_rqst *req = task->tk_rqstp; | ||
483 | struct rpc_cred *new; | 484 | struct rpc_cred *new; |
484 | int lookupflags = 0; | 485 | int lookupflags = 0; |
485 | 486 | ||
@@ -493,9 +494,9 @@ rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | |||
493 | new = rpcauth_bind_new_cred(task, lookupflags); | 494 | new = rpcauth_bind_new_cred(task, lookupflags); |
494 | if (IS_ERR(new)) | 495 | if (IS_ERR(new)) |
495 | return PTR_ERR(new); | 496 | return PTR_ERR(new); |
496 | if (task->tk_msg.rpc_cred != NULL) | 497 | if (req->rq_cred != NULL) |
497 | put_rpccred(task->tk_msg.rpc_cred); | 498 | put_rpccred(req->rq_cred); |
498 | task->tk_msg.rpc_cred = new; | 499 | req->rq_cred = new; |
499 | return 0; | 500 | return 0; |
500 | } | 501 | } |
501 | 502 | ||
@@ -535,22 +536,10 @@ out_nodestroy: | |||
535 | } | 536 | } |
536 | EXPORT_SYMBOL_GPL(put_rpccred); | 537 | EXPORT_SYMBOL_GPL(put_rpccred); |
537 | 538 | ||
538 | void | ||
539 | rpcauth_unbindcred(struct rpc_task *task) | ||
540 | { | ||
541 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | ||
542 | |||
543 | dprintk("RPC: %5u releasing %s cred %p\n", | ||
544 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | ||
545 | |||
546 | put_rpccred(cred); | ||
547 | task->tk_msg.rpc_cred = NULL; | ||
548 | } | ||
549 | |||
550 | __be32 * | 539 | __be32 * |
551 | rpcauth_marshcred(struct rpc_task *task, __be32 *p) | 540 | rpcauth_marshcred(struct rpc_task *task, __be32 *p) |
552 | { | 541 | { |
553 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 542 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
554 | 543 | ||
555 | dprintk("RPC: %5u marshaling %s cred %p\n", | 544 | dprintk("RPC: %5u marshaling %s cred %p\n", |
556 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 545 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -561,7 +550,7 @@ rpcauth_marshcred(struct rpc_task *task, __be32 *p) | |||
561 | __be32 * | 550 | __be32 * |
562 | rpcauth_checkverf(struct rpc_task *task, __be32 *p) | 551 | rpcauth_checkverf(struct rpc_task *task, __be32 *p) |
563 | { | 552 | { |
564 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 553 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
565 | 554 | ||
566 | dprintk("RPC: %5u validating %s cred %p\n", | 555 | dprintk("RPC: %5u validating %s cred %p\n", |
567 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 556 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -573,7 +562,7 @@ int | |||
573 | rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, | 562 | rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, |
574 | __be32 *data, void *obj) | 563 | __be32 *data, void *obj) |
575 | { | 564 | { |
576 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 565 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
577 | 566 | ||
578 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", | 567 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", |
579 | task->tk_pid, cred->cr_ops->cr_name, cred); | 568 | task->tk_pid, cred->cr_ops->cr_name, cred); |
@@ -587,7 +576,7 @@ int | |||
587 | rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | 576 | rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, |
588 | __be32 *data, void *obj) | 577 | __be32 *data, void *obj) |
589 | { | 578 | { |
590 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 579 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
591 | 580 | ||
592 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", | 581 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", |
593 | task->tk_pid, cred->cr_ops->cr_name, cred); | 582 | task->tk_pid, cred->cr_ops->cr_name, cred); |
@@ -601,13 +590,21 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | |||
601 | int | 590 | int |
602 | rpcauth_refreshcred(struct rpc_task *task) | 591 | rpcauth_refreshcred(struct rpc_task *task) |
603 | { | 592 | { |
604 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 593 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
605 | int err; | 594 | int err; |
606 | 595 | ||
596 | cred = task->tk_rqstp->rq_cred; | ||
597 | if (cred == NULL) { | ||
598 | err = rpcauth_bindcred(task, task->tk_msg.rpc_cred, task->tk_flags); | ||
599 | if (err < 0) | ||
600 | goto out; | ||
601 | cred = task->tk_rqstp->rq_cred; | ||
602 | }; | ||
607 | dprintk("RPC: %5u refreshing %s cred %p\n", | 603 | dprintk("RPC: %5u refreshing %s cred %p\n", |
608 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 604 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
609 | 605 | ||
610 | err = cred->cr_ops->crrefresh(task); | 606 | err = cred->cr_ops->crrefresh(task); |
607 | out: | ||
611 | if (err < 0) | 608 | if (err < 0) |
612 | task->tk_status = err; | 609 | task->tk_status = err; |
613 | return err; | 610 | return err; |
@@ -616,7 +613,7 @@ rpcauth_refreshcred(struct rpc_task *task) | |||
616 | void | 613 | void |
617 | rpcauth_invalcred(struct rpc_task *task) | 614 | rpcauth_invalcred(struct rpc_task *task) |
618 | { | 615 | { |
619 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 616 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
620 | 617 | ||
621 | dprintk("RPC: %5u invalidating %s cred %p\n", | 618 | dprintk("RPC: %5u invalidating %s cred %p\n", |
622 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 619 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -627,7 +624,7 @@ rpcauth_invalcred(struct rpc_task *task) | |||
627 | int | 624 | int |
628 | rpcauth_uptodatecred(struct rpc_task *task) | 625 | rpcauth_uptodatecred(struct rpc_task *task) |
629 | { | 626 | { |
630 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 627 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
631 | 628 | ||
632 | return cred == NULL || | 629 | return cred == NULL || |
633 | test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; | 630 | test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; |