From 9183a2a33e1a5974ecd0c35681b9f4a09d285386 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Tue, 26 May 2009 01:16:09 +0000 Subject: [PATCH] Fix the handling of NFSv4 Illegal Operation number to conform to RFC3530 (the operation number in the reply must be set to the value for OP_ILLEGAL). Also cleaned up some indentation. Approved by: kib (mentor) --- sys/fs/nfs/nfsport.h | 3 +++ sys/fs/nfsserver/nfs_nfsdsocket.c | 25 ++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index c1aa06140fb9..71b6cb470bb0 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -235,6 +235,9 @@ */ #define NFSV4OP_NOPS 40 +/* Quirky case if the illegal op code */ +#define NFSV4OP_OPILLEGAL 10044 + /* * Fake NFSV4OP_xxx used for nfsstat. Start at NFSV4OP_NOPS. */ diff --git a/sys/fs/nfsserver/nfs_nfsdsocket.c b/sys/fs/nfsserver/nfs_nfsdsocket.c index 54307bc38e43..fc6e39e63cfd 100644 --- a/sys/fs/nfsserver/nfs_nfsdsocket.c +++ b/sys/fs/nfsserver/nfs_nfsdsocket.c @@ -639,13 +639,16 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, for (i = 0; i < numops; i++) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); NFSM_BUILD(repp, u_int32_t *, 2 * NFSX_UNSIGNED); - *repp++ = *tl; + *repp = *tl; op = fxdr_unsigned(int, *tl); if (op < NFSV4OP_ACCESS || op >= NFSV4OP_NOPS) { - nd->nd_repstat = NFSERR_OPILLEGAL; - *repp = nfsd_errmap(nd); - retops++; - break; + nd->nd_repstat = NFSERR_OPILLEGAL; + *repp++ = txdr_unsigned(NFSV4OP_OPILLEGAL); + *repp = nfsd_errmap(nd); + retops++; + break; + } else { + repp++; } /* @@ -682,12 +685,12 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, nd->nd_repstat = NFSERR_RESOURCE; *repp = nfsd_errmap(nd); if (op == NFSV4OP_SETATTR) { - /* - * Setattr replies require a bitmap. - * even for errors like these. - */ - NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); - *tl = 0; + /* + * Setattr replies require a bitmap. + * even for errors like these. + */ + NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = 0; } retops++; break;