Commit bf269551 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: New xdr_streams XDR decoder API

Now that all client-side XDR decoder routines use xdr_streams, there
should be no need to support the legacy calling sequence [rpc_rqst *,
__be32 *, RPC res *] anywhere.  We can construct an xdr_stream in the
generic RPC code, instead of in each decoder function.

This is a refactoring change.  It should not cause different behavior.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Tested-by: default avatarJ. Bruce Fields <bfields@redhat.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 9f06c719
...@@ -529,17 +529,16 @@ static int decode_nlm4_testrply(struct xdr_stream *xdr, ...@@ -529,17 +529,16 @@ static int decode_nlm4_testrply(struct xdr_stream *xdr,
return error; return error;
} }
static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, static int nlm4_xdr_dec_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result) struct nlm_res *result)
{ {
struct xdr_stream xdr;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_cookie(xdr, &result->cookie);
error = decode_cookie(&xdr, &result->cookie);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = decode_nlm4_testrply(&xdr, result); error = decode_nlm4_testrply(xdr, result);
out: out:
return error; return error;
} }
...@@ -550,17 +549,16 @@ static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, ...@@ -550,17 +549,16 @@ static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
* nlm4_stat stat; * nlm4_stat stat;
* }; * };
*/ */
static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p, static int nlm4_xdr_dec_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result) struct nlm_res *result)
{ {
struct xdr_stream xdr;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_cookie(xdr, &result->cookie);
error = decode_cookie(&xdr, &result->cookie);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = decode_nlm4_stat(&xdr, &result->status); error = decode_nlm4_stat(xdr, &result->status);
out: out:
return error; return error;
} }
...@@ -575,7 +573,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p, ...@@ -575,7 +573,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
[NLMPROC_##proc] = { \ [NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \ .p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \ .p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \ .p_decode = (kxdrdproc_t)nlm4_xdr_dec_##restype, \
.p_arglen = NLM4_##argtype##_sz, \ .p_arglen = NLM4_##argtype##_sz, \
.p_replen = NLM4_##restype##_sz, \ .p_replen = NLM4_##restype##_sz, \
.p_statidx = NLMPROC_##proc, \ .p_statidx = NLMPROC_##proc, \
......
...@@ -527,17 +527,16 @@ static int decode_nlm_testrply(struct xdr_stream *xdr, ...@@ -527,17 +527,16 @@ static int decode_nlm_testrply(struct xdr_stream *xdr,
return error; return error;
} }
static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, static int nlm_xdr_dec_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result) struct nlm_res *result)
{ {
struct xdr_stream xdr;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_cookie(xdr, &result->cookie);
error = decode_cookie(&xdr, &result->cookie);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = decode_nlm_testrply(&xdr, result); error = decode_nlm_testrply(xdr, result);
out: out:
return error; return error;
} }
...@@ -548,17 +547,16 @@ static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, ...@@ -548,17 +547,16 @@ static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
* nlm_stat stat; * nlm_stat stat;
* }; * };
*/ */
static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p, static int nlm_xdr_dec_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result) struct nlm_res *result)
{ {
struct xdr_stream xdr;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_cookie(xdr, &result->cookie);
error = decode_cookie(&xdr, &result->cookie);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = decode_nlm_stat(&xdr, &result->status); error = decode_nlm_stat(xdr, &result->status);
out: out:
return error; return error;
} }
...@@ -573,7 +571,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p, ...@@ -573,7 +571,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
[NLMPROC_##proc] = { \ [NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \ .p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \ .p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm_xdr_dec_##restype, \ .p_decode = (kxdrdproc_t)nlm_xdr_dec_##restype, \
.p_arglen = NLM_##argtype##_sz, \ .p_arglen = NLM_##argtype##_sz, \
.p_replen = NLM_##restype##_sz, \ .p_replen = NLM_##restype##_sz, \
.p_statidx = NLMPROC_##proc, \ .p_statidx = NLMPROC_##proc, \
......
...@@ -472,35 +472,35 @@ static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -472,35 +472,35 @@ static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr,
encode_mon_id(xdr, argp); encode_mon_id(xdr, argp);
} }
static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp,
struct nsm_res *resp) struct xdr_stream *xdr,
struct nsm_res *resp)
{ {
struct xdr_stream xdr; __be32 *p;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); p = xdr_inline_decode(xdr, 4 + 4);
p = xdr_inline_decode(&xdr, 4 + 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return -EIO; return -EIO;
resp->status = be32_to_cpup(p++); resp->status = be32_to_cpup(p++);
resp->state = be32_to_cpup(p); resp->state = be32_to_cpup(p);
dprintk("lockd: xdr_dec_stat_res status %d state %d\n", dprintk("lockd: %s status %d state %d\n",
resp->status, resp->state); __func__, resp->status, resp->state);
return 0; return 0;
} }
static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p, static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp,
struct nsm_res *resp) struct xdr_stream *xdr,
struct nsm_res *resp)
{ {
struct xdr_stream xdr; __be32 *p;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); p = xdr_inline_decode(xdr, 4);
p = xdr_inline_decode(&xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return -EIO; return -EIO;
resp->state = be32_to_cpup(p); resp->state = be32_to_cpup(p);
dprintk("lockd: xdr_dec_stat state %d\n", resp->state); dprintk("lockd: %s state %d\n", __func__, resp->state);
return 0; return 0;
} }
...@@ -517,7 +517,7 @@ static struct rpc_procinfo nsm_procedures[] = { ...@@ -517,7 +517,7 @@ static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_MON] = { [NSMPROC_MON] = {
.p_proc = NSMPROC_MON, .p_proc = NSMPROC_MON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_mon, .p_encode = (kxdreproc_t)nsm_xdr_enc_mon,
.p_decode = (kxdrproc_t)xdr_dec_stat_res, .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat_res,
.p_arglen = SM_mon_sz, .p_arglen = SM_mon_sz,
.p_replen = SM_monres_sz, .p_replen = SM_monres_sz,
.p_statidx = NSMPROC_MON, .p_statidx = NSMPROC_MON,
...@@ -526,7 +526,7 @@ static struct rpc_procinfo nsm_procedures[] = { ...@@ -526,7 +526,7 @@ static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_UNMON] = { [NSMPROC_UNMON] = {
.p_proc = NSMPROC_UNMON, .p_proc = NSMPROC_UNMON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_unmon, .p_encode = (kxdreproc_t)nsm_xdr_enc_unmon,
.p_decode = (kxdrproc_t)xdr_dec_stat, .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat,
.p_arglen = SM_mon_id_sz, .p_arglen = SM_mon_id_sz,
.p_replen = SM_unmonres_sz, .p_replen = SM_unmonres_sz,
.p_statidx = NSMPROC_UNMON, .p_statidx = NSMPROC_UNMON,
......
...@@ -340,18 +340,16 @@ static int decode_fhandle(struct xdr_stream *xdr, struct mountres *res) ...@@ -340,18 +340,16 @@ static int decode_fhandle(struct xdr_stream *xdr, struct mountres *res)
return 0; return 0;
} }
static int mnt_dec_mountres(struct rpc_rqst *req, __be32 *p, static int mnt_xdr_dec_mountres(struct rpc_rqst *req,
struct mountres *res) struct xdr_stream *xdr,
struct mountres *res)
{ {
struct xdr_stream xdr;
int status; int status;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); status = decode_status(xdr, res);
status = decode_status(&xdr, res);
if (unlikely(status != 0 || res->errno != 0)) if (unlikely(status != 0 || res->errno != 0))
return status; return status;
return decode_fhandle(&xdr, res); return decode_fhandle(xdr, res);
} }
static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res)
...@@ -434,30 +432,28 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) ...@@ -434,30 +432,28 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res)
return 0; return 0;
} }
static int mnt_dec_mountres3(struct rpc_rqst *req, __be32 *p, static int mnt_xdr_dec_mountres3(struct rpc_rqst *req,
struct mountres *res) struct xdr_stream *xdr,
struct mountres *res)
{ {
struct xdr_stream xdr;
int status; int status;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); status = decode_fhs_status(xdr, res);
status = decode_fhs_status(&xdr, res);
if (unlikely(status != 0 || res->errno != 0)) if (unlikely(status != 0 || res->errno != 0))
return status; return status;
status = decode_fhandle3(&xdr, res); status = decode_fhandle3(xdr, res);
if (unlikely(status != 0)) { if (unlikely(status != 0)) {
res->errno = -EBADHANDLE; res->errno = -EBADHANDLE;
return 0; return 0;
} }
return decode_auth_flavors(&xdr, res); return decode_auth_flavors(xdr, res);
} }
static struct rpc_procinfo mnt_procedures[] = { static struct rpc_procinfo mnt_procedures[] = {
[MOUNTPROC_MNT] = { [MOUNTPROC_MNT] = {
.p_proc = MOUNTPROC_MNT, .p_proc = MOUNTPROC_MNT,
.p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
.p_decode = (kxdrproc_t)mnt_dec_mountres, .p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres,
.p_arglen = MNT_enc_dirpath_sz, .p_arglen = MNT_enc_dirpath_sz,
.p_replen = MNT_dec_mountres_sz, .p_replen = MNT_dec_mountres_sz,
.p_statidx = MOUNTPROC_MNT, .p_statidx = MOUNTPROC_MNT,
...@@ -476,7 +472,7 @@ static struct rpc_procinfo mnt3_procedures[] = { ...@@ -476,7 +472,7 @@ static struct rpc_procinfo mnt3_procedures[] = {
[MOUNTPROC3_MNT] = { [MOUNTPROC3_MNT] = {
.p_proc = MOUNTPROC3_MNT, .p_proc = MOUNTPROC3_MNT,
.p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath, .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
.p_decode = (kxdrproc_t)mnt_dec_mountres3, .p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres3,
.p_arglen = MNT_enc_dirpath_sz, .p_arglen = MNT_enc_dirpath_sz,
.p_replen = MNT_dec_mountres3_sz, .p_replen = MNT_dec_mountres3_sz,
.p_statidx = MOUNTPROC3_MNT, .p_statidx = MOUNTPROC3_MNT,
......
...@@ -783,15 +783,13 @@ static void nfs2_xdr_enc_readdirargs(struct rpc_rqst *req, ...@@ -783,15 +783,13 @@ static void nfs2_xdr_enc_readdirargs(struct rpc_rqst *req,
* "NFS: Network File System Protocol Specification". * "NFS: Network File System Protocol Specification".
*/ */
static int nfs2_xdr_dec_stat(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_stat(struct rpc_rqst *req, struct xdr_stream *xdr,
void *__unused) void *__unused)
{ {
struct xdr_stream xdr;
enum nfs_stat status; enum nfs_stat status;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_stat(xdr, &status);
error = decode_stat(&xdr, &status);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
if (status != NFS_OK) if (status != NFS_OK)
...@@ -802,22 +800,16 @@ static int nfs2_xdr_dec_stat(struct rpc_rqst *req, __be32 *p, ...@@ -802,22 +800,16 @@ static int nfs2_xdr_dec_stat(struct rpc_rqst *req, __be32 *p,
return nfs_stat_to_errno(status); return nfs_stat_to_errno(status);
} }
static int nfs2_xdr_dec_attrstat(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_attrstat(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_fattr *result) struct nfs_fattr *result)
{ {
struct xdr_stream xdr; return decode_attrstat(xdr, result);
xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
return decode_attrstat(&xdr, result);
} }
static int nfs2_xdr_dec_diropres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_diropres(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_diropok *result) struct nfs_diropok *result)
{ {
struct xdr_stream xdr; return decode_diropres(xdr, result);
xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
return decode_diropres(&xdr, result);
} }
/* /*
...@@ -830,20 +822,18 @@ static int nfs2_xdr_dec_diropres(struct rpc_rqst *req, __be32 *p, ...@@ -830,20 +822,18 @@ static int nfs2_xdr_dec_diropres(struct rpc_rqst *req, __be32 *p,
* void; * void;
* }; * };
*/ */
static int nfs2_xdr_dec_readlinkres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_readlinkres(struct rpc_rqst *req,
void *__unused) struct xdr_stream *xdr, void *__unused)
{ {
struct xdr_stream xdr;
enum nfs_stat status; enum nfs_stat status;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_stat(xdr, &status);
error = decode_stat(&xdr, &status);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
if (status != NFS_OK) if (status != NFS_OK)
goto out_default; goto out_default;
error = decode_path(&xdr); error = decode_path(xdr);
out: out:
return error; return error;
out_default: out_default:
...@@ -861,39 +851,33 @@ static int nfs2_xdr_dec_readlinkres(struct rpc_rqst *req, __be32 *p, ...@@ -861,39 +851,33 @@ static int nfs2_xdr_dec_readlinkres(struct rpc_rqst *req, __be32 *p,
* void; * void;
* }; * };
*/ */
static int nfs2_xdr_dec_readres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_readres(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_readres *result) struct nfs_readres *result)
{ {
struct xdr_stream xdr;
enum nfs_stat status; enum nfs_stat status;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_stat(xdr, &status);
error = decode_stat(&xdr, &status);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
if (status != NFS_OK) if (status != NFS_OK)
goto out_default; goto out_default;
error = decode_fattr(&xdr, result->fattr); error = decode_fattr(xdr, result->fattr);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
error = decode_nfsdata(&xdr, result); error = decode_nfsdata(xdr, result);
out: out:
return error; return error;
out_default: out_default:
return nfs_stat_to_errno(status); return nfs_stat_to_errno(status);
} }
static int nfs2_xdr_dec_writeres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_writeres(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_writeres *result) struct nfs_writeres *result)
{ {
struct xdr_stream xdr;
/* All NFSv2 writes are "file sync" writes */ /* All NFSv2 writes are "file sync" writes */
result->verf->committed = NFS_FILE_SYNC; result->verf->committed = NFS_FILE_SYNC;
return decode_attrstat(xdr, result->fattr);
xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
return decode_attrstat(&xdr, result->fattr);
} }
/** /**
...@@ -1008,20 +992,18 @@ static int decode_readdirok(struct xdr_stream *xdr) ...@@ -1008,20 +992,18 @@ static int decode_readdirok(struct xdr_stream *xdr)
goto out; goto out;
} }
static int nfs2_xdr_dec_readdirres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_readdirres(struct rpc_rqst *req,
void *__unused) struct xdr_stream *xdr, void *__unused)
{ {
struct xdr_stream xdr;
enum nfs_stat status; enum nfs_stat status;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_stat(xdr, &status);
error = decode_stat(&xdr, &status);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
if (status != NFS_OK) if (status != NFS_OK)
goto out_default; goto out_default;
error = decode_readdirok(&xdr); error = decode_readdirok(xdr);
out: out:
return error; return error;
out_default: out_default:
...@@ -1062,20 +1044,18 @@ static int decode_info(struct xdr_stream *xdr, struct nfs2_fsstat *result) ...@@ -1062,20 +1044,18 @@ static int decode_info(struct xdr_stream *xdr, struct nfs2_fsstat *result)
return -EIO; return -EIO;
} }
static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, __be32 *p, static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs2_fsstat *result) struct nfs2_fsstat *result)
{ {
struct xdr_stream xdr;
enum nfs_stat status; enum nfs_stat status;
int error; int error;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); error = decode_stat(xdr, &status);
error = decode_stat(&xdr, &status);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
if (status != NFS_OK) if (status != NFS_OK)
goto out_default; goto out_default;
error = decode_info(&xdr, result); error = decode_info(xdr, result);
out: out:
return error; return error;
out_default: out_default:
...@@ -1150,7 +1130,7 @@ int nfs_stat_to_errno(enum nfs_stat status) ...@@ -1150,7 +1130,7 @@ int nfs_stat_to_errno(enum nfs_stat status)
[NFSPROC_##proc] = { \ [NFSPROC_##proc] = { \
.p_proc = NFSPROC_##proc, \ .p_proc = NFSPROC_##proc, \
.p_encode = (kxdreproc_t)nfs2_xdr_enc_##argtype, \ .p_encode = (kxdreproc_t)nfs2_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nfs2_xdr_dec_##restype, \ .p_decode = (kxdrdproc_t)nfs2_xdr_dec_##restype, \
.p_arglen = NFS_##argtype##_sz, \ .p_arglen = NFS_##argtype##_sz, \
.p_replen = NFS_##restype##_sz, \ .p_replen = NFS_##restype##_sz, \
.p_timer = timer, \ .p_timer = timer, \
......
This diff is collapsed.
This diff is collapsed.
...@@ -533,7 +533,8 @@ static void nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -533,7 +533,8 @@ static void nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, struct xdr_stream *xdr,
* Protocol". * Protocol".
*/ */
static int nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p, void *__unused) static int nfs4_xdr_dec_cb_null(struct rpc_rqst *req, struct xdr_stream *xdr,
void *__unused)
{ {
return 0; return 0;
} }
...@@ -541,26 +542,25 @@ static int nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p, void *__unused) ...@@ -541,26 +542,25 @@ static int nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p, void *__unused)
/* /*
* 20.2. Operation 4: CB_RECALL - Recall a Delegation * 20.2. Operation 4: CB_RECALL - Recall a Delegation
*/ */
static int nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p, static int nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp,
struct xdr_stream *xdr,
struct nfsd4_callback *cb) struct nfsd4_callback *cb)
{ {
struct xdr_stream xdr;
struct nfs4_cb_compound_hdr hdr; struct nfs4_cb_compound_hdr hdr;
enum nfsstat4 nfserr; enum nfsstat4 nfserr;
int status; int status;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); status = decode_cb_compound4res(xdr, &hdr);
status = decode_cb_compound4res(&xdr, &hdr);
if (unlikely(status)) if (unlikely(status))
goto out; goto out;
if (cb != NULL) { if (cb != NULL) {
status = decode_cb_sequence4res(&xdr, cb); status = decode_cb_sequence4res(xdr, cb);
if (unlikely(status)) if (unlikely(status))
goto out; goto out;
} }
status = decode_cb_op_status(&xdr, OP_CB_RECALL, &nfserr); status = decode_cb_op_status(xdr, OP_CB_RECALL, &nfserr);
if (unlikely(status)) if (unlikely(status))
goto out; goto out;
if (unlikely(nfserr != NFS4_OK)) if (unlikely(nfserr != NFS4_OK))
...@@ -578,7 +578,7 @@ static int nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p, ...@@ -578,7 +578,7 @@ static int nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p,
[NFSPROC4_CLNT_##proc] = { \ [NFSPROC4_CLNT_##proc] = { \
.p_proc = NFSPROC4_CB_##call, \ .p_proc = NFSPROC4_CB_##call, \
.p_encode = (kxdreproc_t)nfs4_xdr_enc_##argtype, \ .p_encode = (kxdreproc_t)nfs4_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nfs4_xdr_dec_##restype, \ .p_decode = (kxdrdproc_t)nfs4_xdr_dec_##restype, \
.p_arglen = NFS4_enc_##argtype##_sz, \ .p_arglen = NFS4_enc_##argtype##_sz, \
.p_replen = NFS4_dec_##restype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \
.p_statidx = NFSPROC4_CB_##call, \ .p_statidx = NFSPROC4_CB_##call, \
......
...@@ -112,7 +112,7 @@ struct rpc_credops { ...@@ -112,7 +112,7 @@ struct rpc_credops {
__be32 * (*crvalidate)(struct rpc_task *, __be32 *); __be32 * (*crvalidate)(struct rpc_task *, __be32 *);
int (*crwrap_req)(struct rpc_task *, kxdreproc_t, int (*crwrap_req)(struct rpc_task *, kxdreproc_t,
void *, __be32 *, void *); void *, __be32 *, void *);
int (*crunwrap_resp)(struct rpc_task *, kxdrproc_t, int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t,
void *, __be32 *, void *); void *, __be32 *, void *);
}; };
...@@ -140,7 +140,7 @@ void put_rpccred(struct rpc_cred *); ...@@ -140,7 +140,7 @@ void put_rpccred(struct rpc_cred *);
__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *);
__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *); __be32 * rpcauth_checkverf(struct rpc_task *, __be32 *);
int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj); int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj);
int rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, __be32 *data, void *obj); int rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, __be32 *data, void *obj);
int rpcauth_refreshcred(struct rpc_task *); int rpcauth_refreshcred(struct rpc_task *);
void rpcauth_invalcred(struct rpc_task *); void rpcauth_invalcred(struct rpc_task *);
int rpcauth_uptodatecred(struct rpc_task *); int rpcauth_uptodatecred(struct rpc_task *);
......
...@@ -90,7 +90,7 @@ struct rpc_version { ...@@ -90,7 +90,7 @@ struct rpc_version {
struct rpc_procinfo { struct rpc_procinfo {
u32 p_proc; /* RPC procedure number */ u32 p_proc; /* RPC procedure number */
kxdreproc_t p_encode; /* XDR encode function */ kxdreproc_t p_encode; /* XDR encode function */
kxdrproc_t p_decode; /* XDR decode function */ kxdrdproc_t p_decode; /* XDR decode function */
unsigned int p_arglen; /* argument hdr length (u32) */ unsigned int p_arglen; /* argument hdr length (u32) */
unsigned int p_replen; /* reply hdr length (u32) */ unsigned int p_replen; /* reply hdr length (u32) */
unsigned int p_count; /* call count */ unsigned int p_count; /* call count */
......
...@@ -204,9 +204,10 @@ struct xdr_stream { ...@@ -204,9 +204,10 @@ struct xdr_stream {
}; };
/* /*
* This is the xdr_stream style generic XDR function. * These are the xdr_stream style generic XDR encode and decode functions.
*/ */
typedef void (*kxdreproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj); typedef void (*kxdreproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj);
typedef int (*kxdrdproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj);
extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
......
...@@ -587,8 +587,18 @@ rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, ...@@ -587,8 +587,18 @@ rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp,
return 0; return 0;
} }
static int
rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
__be32 *data, void *obj)
{
struct xdr_stream xdr;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data);
return decode(rqstp, &xdr, obj);
}
int int
rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp,
__be32 *data, void *obj) __be32 *data, void *obj)
{ {
struct rpc_cred *cred = task->tk_rqstp->rq_cred; struct rpc_cred *cred = task->tk_rqstp->rq_cred;
...@@ -599,7 +609,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, ...@@ -599,7 +609,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
return cred->cr_ops->crunwrap_resp(task, decode, rqstp, return cred->cr_ops->crunwrap_resp(task, decode, rqstp,
data, obj); data, obj);
/* By default, we decode the arguments normally. */ /* By default, we decode the arguments normally. */
return decode(rqstp, data, obj); return rpcauth_unwrap_req_decode(decode, rqstp, data, obj);
} }
int int
......
...@@ -1503,10 +1503,19 @@ gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, ...@@ -1503,10 +1503,19 @@ gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
return 0; return 0;
} }
static int
gss_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
__be32 *p, void *obj)
{
struct xdr_stream xdr;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
return decode(rqstp, &xdr, obj);
}
static int static int
gss_unwrap_resp(struct rpc_task *task, gss_unwrap_resp(struct rpc_task *task,
kxdrproc_t decode, void *rqstp, __be32 *p, void *obj) kxdrdproc_t decode, void *rqstp, __be32 *p, void *obj)
{ {
struct rpc_cred *cred = task->tk_rqstp->rq_cred; struct rpc_cred *cred = task->tk_rqstp->rq_cred;
struct gss_cred *gss_cred = container_of(cred, struct gss_cred, struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
...@@ -1537,7 +1546,7 @@ gss_unwrap_resp(struct rpc_task *task, ...@@ -1537,7 +1546,7 @@ gss_unwrap_resp(struct rpc_task *task,
cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp)
+ (savedlen - head->iov_len); + (savedlen - head->iov_len);
out_decode: out_decode:
status = decode(rqstp, p, obj); status = gss_unwrap_req_decode(decode, rqstp, p, obj);
out: out:
gss_put_ctx(ctx); gss_put_ctx(ctx);
dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid, dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid,
......
...@@ -1535,7 +1535,7 @@ call_decode(struct rpc_task *task) ...@@ -1535,7 +1535,7 @@ call_decode(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client; struct rpc_clnt *clnt = task->tk_client;
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode; kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode;
__be32 *p; __be32 *p;
dprintk("RPC: %5u call_decode (status %d)\n", dprintk("RPC: %5u call_decode (status %d)\n",
...@@ -1780,7 +1780,7 @@ static void rpcproc_encode_null(void *rqstp, struct xdr_stream *xdr, void *obj) ...@@ -1780,7 +1780,7 @@ static void rpcproc_encode_null(void *rqstp, struct xdr_stream *xdr, void *obj)
{ {
} }
static int rpcproc_decode_null(void *rqstp, __be32 *data, void *obj) static int rpcproc_decode_null(void *rqstp, struct xdr_stream *xdr, void *obj)
{ {
return 0; return 0;
} }
......
...@@ -706,18 +706,16 @@ static void rpcb_enc_mapping(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -706,18 +706,16 @@ static void rpcb_enc_mapping(struct rpc_rqst *req, struct xdr_stream *xdr,
*p = cpu_to_be32(rpcb->r_port); *p = cpu_to_be32(rpcb->r_port);
} }
static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p, static int rpcb_dec_getport(struct rpc_rqst *req, struct xdr_stream *xdr,
struct rpcbind_args *rpcb) struct rpcbind_args *rpcb)
{ {
struct rpc_task *task = req->rq_task; struct rpc_task *task = req->rq_task;
struct xdr_stream xdr;
unsigned long port; unsigned long port;
__be32 *p;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
rpcb->r_port = 0; rpcb->r_port = 0;
p = xdr_inline_decode(&xdr, 4); p = xdr_inline_decode(xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return -EIO; return -EIO;
...@@ -731,20 +729,18 @@ static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p, ...@@ -731,20 +729,18 @@ static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p,
return 0; return 0;
} }
static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p, static int rpcb_dec_set(struct rpc_rqst *req, struct xdr_stream *xdr,
unsigned int *boolp) unsigned int *boolp)
{ {
struct rpc_task *task = req->rq_task; struct rpc_task *task = req->rq_task;
struct xdr_stream xdr; __be32 *p;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
p = xdr_inline_decode(&xdr, 4); p = xdr_inline_decode(xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return -EIO; return -EIO;
*boolp = 0; *boolp = 0;
if (*p) if (*p != xdr_zero)
*boolp = 1; *boolp = 1;
dprintk("RPC: %5u RPCB_%s call %s\n", dprintk("RPC: %5u RPCB_%s call %s\n",
...@@ -785,20 +781,18 @@ static void rpcb_enc_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -785,20 +781,18 @@ static void rpcb_enc_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
encode_rpcb_string(xdr, rpcb->r_owner, RPCB_MAXOWNERLEN); encode_rpcb_string(xdr, rpcb->r_owner, RPCB_MAXOWNERLEN);
} }
static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p, static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
struct rpcbind_args *rpcb) struct rpcbind_args *rpcb)
{ {
struct sockaddr_storage address; struct sockaddr_storage address;
struct sockaddr *sap = (struct sockaddr *)&address; struct sockaddr *sap = (struct sockaddr *)&address;
struct rpc_task *task = req->rq_task; struct rpc_task *task = req->rq_task;
struct xdr_stream xdr; __be32 *p;
u32 len; u32 len;
rpcb->r_port = 0; rpcb->r_port = 0;
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); p = xdr_inline_decode(xdr, 4);
p = xdr_inline_decode(&xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
goto out_fail; goto out_fail;
len = be32_to_cpup(p); len = be32_to_cpup(p);
...@@ -816,7 +810,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p, ...@@ -816,7 +810,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p,
if (unlikely(len > RPCBIND_MAXUADDRLEN)) if (unlikely(len > RPCBIND_MAXUADDRLEN))
goto out_fail; goto out_fail;
p = xdr_inline_decode(&xdr, len); p = xdr_inline_decode(xdr, len);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
goto out_fail; goto out_fail;
dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid, dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid,
...@@ -843,7 +837,7 @@ static struct rpc_procinfo rpcb_procedures2[] = { ...@@ -843,7 +837,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = (kxdreproc_t)rpcb_enc_mapping, .p_encode = (kxdreproc_t)rpcb_enc_mapping,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_mappingargs_sz, .p_arglen = RPCB_mappingargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_SET, .p_statidx = RPCBPROC_SET,
...@@ -853,7 +847,7 @@ static struct rpc_procinfo rpcb_procedures2[] = { ...@@ -853,7 +847,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
[RPCBPROC_UNSET] = { [RPCBPROC_UNSET] = {
.p_proc = RPCBPROC_UNSET, .p_proc = RPCBPROC_UNSET,
.p_encode = (kxdreproc_t)rpcb_enc_mapping, .p_encode = (kxdreproc_t)rpcb_enc_mapping,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_mappingargs_sz, .p_arglen = RPCB_mappingargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_UNSET, .p_statidx = RPCBPROC_UNSET,
...@@ -863,7 +857,7 @@ static struct rpc_procinfo rpcb_procedures2[] = { ...@@ -863,7 +857,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
[RPCBPROC_GETPORT] = { [RPCBPROC_GETPORT] = {
.p_proc = RPCBPROC_GETPORT, .p_proc = RPCBPROC_GETPORT,
.p_encode = (kxdreproc_t)rpcb_enc_mapping, .p_encode = (kxdreproc_t)rpcb_enc_mapping,
.p_decode = (kxdrproc_t)rpcb_dec_getport, .p_decode = (kxdrdproc_t)rpcb_dec_getport,
.p_arglen = RPCB_mappingargs_sz, .p_arglen = RPCB_mappingargs_sz,
.p_replen = RPCB_getportres_sz, .p_replen = RPCB_getportres_sz,
.p_statidx = RPCBPROC_GETPORT, .p_statidx = RPCBPROC_GETPORT,
...@@ -876,7 +870,7 @@ static struct rpc_procinfo rpcb_procedures3[] = { ...@@ -876,7 +870,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_SET, .p_statidx = RPCBPROC_SET,
...@@ -886,7 +880,7 @@ static struct rpc_procinfo rpcb_procedures3[] = { ...@@ -886,7 +880,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
[RPCBPROC_UNSET] = { [RPCBPROC_UNSET] = {
.p_proc = RPCBPROC_UNSET, .p_proc = RPCBPROC_UNSET,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_UNSET, .p_statidx = RPCBPROC_UNSET,
...@@ -896,7 +890,7 @@ static struct rpc_procinfo rpcb_procedures3[] = { ...@@ -896,7 +890,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
[RPCBPROC_GETADDR] = { [RPCBPROC_GETADDR] = {
.p_proc = RPCBPROC_GETADDR, .p_proc = RPCBPROC_GETADDR,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_getaddr, .p_decode = (kxdrdproc_t)rpcb_dec_getaddr,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_getaddrres_sz, .p_replen = RPCB_getaddrres_sz,
.p_statidx = RPCBPROC_GETADDR, .p_statidx = RPCBPROC_GETADDR,
...@@ -909,7 +903,7 @@ static struct rpc_procinfo rpcb_procedures4[] = { ...@@ -909,7 +903,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
[RPCBPROC_SET] = { [RPCBPROC_SET] = {
.p_proc = RPCBPROC_SET, .p_proc = RPCBPROC_SET,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_SET, .p_statidx = RPCBPROC_SET,
...@@ -919,7 +913,7 @@ static struct rpc_procinfo rpcb_procedures4[] = { ...@@ -919,7 +913,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
[RPCBPROC_UNSET] = { [RPCBPROC_UNSET] = {
.p_proc = RPCBPROC_UNSET, .p_proc = RPCBPROC_UNSET,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_set, .p_decode = (kxdrdproc_t)rpcb_dec_set,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_setres_sz, .p_replen = RPCB_setres_sz,
.p_statidx = RPCBPROC_UNSET, .p_statidx = RPCBPROC_UNSET,
...@@ -929,7 +923,7 @@ static struct rpc_procinfo rpcb_procedures4[] = { ...@@ -929,7 +923,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
[RPCBPROC_GETADDR] = { [RPCBPROC_GETADDR] = {
.p_proc = RPCBPROC_GETADDR, .p_proc = RPCBPROC_GETADDR,
.p_encode = (kxdreproc_t)rpcb_enc_getaddr, .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
.p_decode = (kxdrproc_t)rpcb_dec_getaddr, .p_decode = (kxdrdproc_t)rpcb_dec_getaddr,
.p_arglen = RPCB_getaddrargs_sz, .p_arglen = RPCB_getaddrargs_sz,
.p_replen = RPCB_getaddrres_sz, .p_replen = RPCB_getaddrres_sz,
.p_statidx = RPCBPROC_GETADDR, .p_statidx = RPCBPROC_GETADDR,
......
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