Refactor for clarity. Also, remove a stale comment. Commit ed94164398c9 ("nfsd: implement machine credential support for some operations") added support for SP4_MACH_CRED, so state_protect_a is no longer completely ignored. Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/nfs4xdr.c | 51 +++++++++++++++++++++++++++++++++------------------ fs/nfsd/xdr4.h | 2 +- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index d7f27ed6b794..be6dcc4c2ab0 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3066,7 +3066,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, rpc_ntop(sa, addr_str, sizeof(addr_str)); dprintk("%s rqstp=%p exid=%p clname.len=%u clname.data=%p " - "ip_addr=%s flags %x, spa_how %d\n", + "ip_addr=%s flags %x, spa_how %u\n", __func__, rqstp, exid, exid->clname.len, exid->clname.data, addr_str, exid->flags, exid->spa_how); diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 4d666e2f8583..d3e238b538d0 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1528,26 +1528,13 @@ static __be32 nfsd4_decode_ssv_sp_parms(struct nfsd4_compoundargs *argp) return nfserr_bad_xdr; } -static __be32 -nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, - struct nfsd4_exchange_id *exid) +static __be32 nfsd4_decode_state_protect4_a(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) { - DECODE_HEAD; - int dummy; - - READ_BUF(NFS4_VERIFIER_SIZE); - COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); - - status = nfsd4_decode_opaque(argp, &exid->clname); - if (status) - return nfserr_bad_xdr; - - READ_BUF(4); - exid->flags = be32_to_cpup(p++); + __be32 status; - /* Ignore state_protect4_a */ - READ_BUF(4); - exid->spa_how = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &exid->spa_how) < 0) + goto xdr_error; switch (exid->spa_how) { case SP4_NONE: break; @@ -1569,6 +1556,34 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, goto xdr_error; } + status = nfs_ok; +out: + return status; +xdr_error: + return nfserr_bad_xdr; +} + +static __be32 +nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) +{ + DECODE_HEAD; + int dummy; + + status = nfsd4_decode_verifier4(argp, &exid->verifier); + if (status) + goto out; + status = nfsd4_decode_opaque(argp, &exid->clname); + if (status) + goto out; + + READ_BUF(4); + exid->flags = be32_to_cpup(p++); + + status = nfsd4_decode_state_protect4_a(argp, exid); + if (status) + goto out; + READ_BUF(4); /* nfs_impl_id4 array length */ dummy = be32_to_cpup(p++); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 6245004a9993..232529bc1b79 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -433,7 +433,7 @@ struct nfsd4_exchange_id { u32 flags; clientid_t clientid; u32 seqid; - int spa_how; + u32 spa_how; u32 spo_must_enforce[3]; u32 spo_must_allow[3]; struct xdr_netobj nii_domain;