diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2019-02-11 11:24:48 -0500 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-02-13 13:45:17 -0500 |
commit | e8680a24a269bd6dcb533f4e4a5faba9ae58925c (patch) | |
tree | 04b8b8e697090b86f314c5ae1e024122c240d3a4 /net/sunrpc/auth.c | |
parent | fe9a270519c72bccb3af524db7ea6c7b67700d50 (diff) |
SUNRPC: Use struct xdr_stream when constructing RPC Call header
Modernize and harden the code path that constructs each RPC Call
message.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r-- | net/sunrpc/auth.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 275e84e817b7..add2135d9b01 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -756,12 +756,21 @@ destroy: | |||
756 | } | 756 | } |
757 | EXPORT_SYMBOL_GPL(put_rpccred); | 757 | EXPORT_SYMBOL_GPL(put_rpccred); |
758 | 758 | ||
759 | __be32 * | 759 | /** |
760 | rpcauth_marshcred(struct rpc_task *task, __be32 *p) | 760 | * rpcauth_marshcred - Append RPC credential to end of @xdr |
761 | * @task: controlling RPC task | ||
762 | * @xdr: xdr_stream containing initial portion of RPC Call header | ||
763 | * | ||
764 | * On success, an appropriate verifier is added to @xdr, @xdr is | ||
765 | * updated to point past the verifier, and zero is returned. | ||
766 | * Otherwise, @xdr is in an undefined state and a negative errno | ||
767 | * is returned. | ||
768 | */ | ||
769 | int rpcauth_marshcred(struct rpc_task *task, struct xdr_stream *xdr) | ||
761 | { | 770 | { |
762 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; | 771 | const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; |
763 | 772 | ||
764 | return cred->cr_ops->crmarshal(task, p); | 773 | return ops->crmarshal(task, xdr); |
765 | } | 774 | } |
766 | 775 | ||
767 | __be32 * | 776 | __be32 * |
@@ -772,26 +781,37 @@ rpcauth_checkverf(struct rpc_task *task, __be32 *p) | |||
772 | return cred->cr_ops->crvalidate(task, p); | 781 | return cred->cr_ops->crvalidate(task, p); |
773 | } | 782 | } |
774 | 783 | ||
775 | static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, | 784 | /** |
776 | __be32 *data, void *obj) | 785 | * rpcauth_wrap_req_encode - XDR encode the RPC procedure |
786 | * @task: controlling RPC task | ||
787 | * @xdr: stream where on-the-wire bytes are to be marshalled | ||
788 | * | ||
789 | * On success, @xdr contains the encoded and wrapped message. | ||
790 | * Otherwise, @xdr is in an undefined state. | ||
791 | */ | ||
792 | int rpcauth_wrap_req_encode(struct rpc_task *task, struct xdr_stream *xdr) | ||
777 | { | 793 | { |
778 | struct xdr_stream xdr; | 794 | kxdreproc_t encode = task->tk_msg.rpc_proc->p_encode; |
779 | 795 | ||
780 | xdr_init_encode(&xdr, &rqstp->rq_snd_buf, data, rqstp); | 796 | encode(task->tk_rqstp, xdr, task->tk_msg.rpc_argp); |
781 | encode(rqstp, &xdr, obj); | 797 | return 0; |
782 | } | 798 | } |
799 | EXPORT_SYMBOL_GPL(rpcauth_wrap_req_encode); | ||
783 | 800 | ||
784 | int | 801 | /** |
785 | rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, | 802 | * rpcauth_wrap_req - XDR encode and wrap the RPC procedure |
786 | __be32 *data, void *obj) | 803 | * @task: controlling RPC task |
804 | * @xdr: stream where on-the-wire bytes are to be marshalled | ||
805 | * | ||
806 | * On success, @xdr contains the encoded and wrapped message, | ||
807 | * and zero is returned. Otherwise, @xdr is in an undefined | ||
808 | * state and a negative errno is returned. | ||
809 | */ | ||
810 | int rpcauth_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | ||
787 | { | 811 | { |
788 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; | 812 | const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; |
789 | 813 | ||
790 | if (cred->cr_ops->crwrap_req) | 814 | return ops->crwrap_req(task, xdr); |
791 | return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); | ||
792 | /* By default, we encode the arguments normally. */ | ||
793 | rpcauth_wrap_req_encode(encode, rqstp, data, obj); | ||
794 | return 0; | ||
795 | } | 815 | } |
796 | 816 | ||
797 | static int | 817 | static int |