aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r--net/sunrpc/auth.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index add2135d9b01..e7861026b9e5 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -17,6 +17,8 @@
17#include <linux/sunrpc/gss_api.h> 17#include <linux/sunrpc/gss_api.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19 19
20#include <trace/events/sunrpc.h>
21
20#define RPC_CREDCACHE_DEFAULT_HASHBITS (4) 22#define RPC_CREDCACHE_DEFAULT_HASHBITS (4)
21struct rpc_cred_cache { 23struct rpc_cred_cache {
22 struct hlist_head *hashtable; 24 struct hlist_head *hashtable;
@@ -773,14 +775,6 @@ int rpcauth_marshcred(struct rpc_task *task, struct xdr_stream *xdr)
773 return ops->crmarshal(task, xdr); 775 return ops->crmarshal(task, xdr);
774} 776}
775 777
776__be32 *
777rpcauth_checkverf(struct rpc_task *task, __be32 *p)
778{
779 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
780
781 return cred->cr_ops->crvalidate(task, p);
782}
783
784/** 778/**
785 * rpcauth_wrap_req_encode - XDR encode the RPC procedure 779 * rpcauth_wrap_req_encode - XDR encode the RPC procedure
786 * @task: controlling RPC task 780 * @task: controlling RPC task
@@ -814,27 +808,52 @@ int rpcauth_wrap_req(struct rpc_task *task, struct xdr_stream *xdr)
814 return ops->crwrap_req(task, xdr); 808 return ops->crwrap_req(task, xdr);
815} 809}
816 810
817static int 811/**
818rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, 812 * rpcauth_checkverf - Validate verifier in RPC Reply header
819 __be32 *data, void *obj) 813 * @task: controlling RPC task
814 * @xdr: xdr_stream containing RPC Reply header
815 *
816 * On success, @xdr is updated to point past the verifier and
817 * zero is returned. Otherwise, @xdr is in an undefined state
818 * and a negative errno is returned.
819 */
820int
821rpcauth_checkverf(struct rpc_task *task, struct xdr_stream *xdr)
820{ 822{
821 struct xdr_stream xdr; 823 const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops;
822 824
823 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data, rqstp); 825 return ops->crvalidate(task, xdr);
824 return decode(rqstp, &xdr, obj);
825} 826}
826 827
828/**
829 * rpcauth_unwrap_resp_decode - Invoke XDR decode function
830 * @task: controlling RPC task
831 * @xdr: stream where the Reply message resides
832 *
833 * Returns zero on success; otherwise a negative errno is returned.
834 */
827int 835int
828rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, 836rpcauth_unwrap_resp_decode(struct rpc_task *task, struct xdr_stream *xdr)
829 __be32 *data, void *obj)
830{ 837{
831 struct rpc_cred *cred = task->tk_rqstp->rq_cred; 838 kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode;
839
840 return decode(task->tk_rqstp, xdr, task->tk_msg.rpc_resp);
841}
842EXPORT_SYMBOL_GPL(rpcauth_unwrap_resp_decode);
843
844/**
845 * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred
846 * @task: controlling RPC task
847 * @xdr: stream where the Reply message resides
848 *
849 * Returns zero on success; otherwise a negative errno is returned.
850 */
851int
852rpcauth_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr)
853{
854 const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops;
832 855
833 if (cred->cr_ops->crunwrap_resp) 856 return ops->crunwrap_resp(task, xdr);
834 return cred->cr_ops->crunwrap_resp(task, decode, rqstp,
835 data, obj);
836 /* By default, we decode the arguments normally. */
837 return rpcauth_unwrap_req_decode(decode, rqstp, data, obj);
838} 857}
839 858
840bool 859bool