From owner-svn-src-stable@freebsd.org Tue Jul 10 19:37:54 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 718EF104A137; Tue, 10 Jul 2018 19:37:54 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2412E8854B; Tue, 10 Jul 2018 19:37:54 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 00D983F9; Tue, 10 Jul 2018 19:37:53 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6AJbrqA061766; Tue, 10 Jul 2018 19:37:53 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6AJbrtA061762; Tue, 10 Jul 2018 19:37:53 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807101937.w6AJbrtA061762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 10 Jul 2018 19:37:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336179 - in stable/10/sys/fs: nfs nfsserver X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/10/sys/fs: nfs nfsserver X-SVN-Commit-Revision: 336179 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2018 19:37:54 -0000 Author: rmacklem Date: Tue Jul 10 19:37:52 2018 New Revision: 336179 URL: https://svnweb.freebsd.org/changeset/base/336179 Log: MFC: r333508 Add support for the TestStateID operation to the NFSv4.1 server. The Linux client now uses the TestStateID operation, so this patch adds support for it to the NFSv4.1 server. The FreeBSD client never uses this operation, so it should not be affected. Modified: stable/10/sys/fs/nfs/nfs_var.h stable/10/sys/fs/nfsserver/nfs_nfsdserv.c stable/10/sys/fs/nfsserver/nfs_nfsdsocket.c stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfs/nfs_var.h ============================================================================== --- stable/10/sys/fs/nfs/nfs_var.h Tue Jul 10 19:28:16 2018 (r336178) +++ stable/10/sys/fs/nfs/nfs_var.h Tue Jul 10 19:37:52 2018 (r336179) @@ -96,6 +96,7 @@ int nfsrv_getclient(nfsquad_t, int, struct nfsclient * int nfsrv_destroyclient(nfsquad_t, NFSPROC_T *); int nfsrv_destroysession(struct nfsrv_descript *, uint8_t *); int nfsrv_freestateid(struct nfsrv_descript *, nfsv4stateid_t *, NFSPROC_T *); +int nfsrv_teststateid(struct nfsrv_descript *, nfsv4stateid_t *, NFSPROC_T *); int nfsrv_adminrevoke(struct nfsd_clid *, NFSPROC_T *); void nfsrv_dumpclients(struct nfsd_dumpclients *, int); void nfsrv_dumplocks(vnode_t, struct nfsd_dumplocks *, int, NFSPROC_T *); @@ -233,6 +234,8 @@ int nfsrvd_destroyclientid(struct nfsrv_descript *, in int nfsrvd_destroysession(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); int nfsrvd_freestateid(struct nfsrv_descript *, int, + vnode_t, NFSPROC_T *, struct nfsexstuff *); +int nfsrvd_teststateid(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); int nfsrvd_notsupp(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); Modified: stable/10/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Tue Jul 10 19:28:16 2018 (r336178) +++ stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Tue Jul 10 19:37:52 2018 (r336179) @@ -4066,6 +4066,50 @@ nfsmout: } /* + * nfsv4 test stateid service + */ +APPLESTATIC int +nfsrvd_teststateid(struct nfsrv_descript *nd, __unused int isdgram, + __unused vnode_t vp, NFSPROC_T *p, __unused struct nfsexstuff *exp) +{ + uint32_t *tl; + nfsv4stateid_t *stateidp = NULL, *tstateidp; + int cnt, error = 0, i, ret; + + if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { + nd->nd_repstat = NFSERR_WRONGSEC; + goto nfsmout; + } + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); + cnt = fxdr_unsigned(int, *tl); + if (cnt <= 0 || cnt > 1024) { + nd->nd_repstat = NFSERR_BADXDR; + goto nfsmout; + } + stateidp = mallocarray(cnt, sizeof(nfsv4stateid_t), M_TEMP, M_WAITOK); + tstateidp = stateidp; + for (i = 0; i < cnt; i++) { + NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID); + tstateidp->seqid = fxdr_unsigned(uint32_t, *tl++); + NFSBCOPY(tl, tstateidp->other, NFSX_STATEIDOTHER); + tstateidp++; + } + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(cnt); + tstateidp = stateidp; + for (i = 0; i < cnt; i++) { + ret = nfsrv_teststateid(nd, tstateidp, p); + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(ret); + tstateidp++; + } +nfsmout: + free(stateidp, M_TEMP); + NFSEXITCODE2(error, nd); + return (error); +} + +/* * nfsv4 service not supported */ APPLESTATIC int Modified: stable/10/sys/fs/nfsserver/nfs_nfsdsocket.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdsocket.c Tue Jul 10 19:28:16 2018 (r336178) +++ stable/10/sys/fs/nfsserver/nfs_nfsdsocket.c Tue Jul 10 19:37:52 2018 (r336179) @@ -190,7 +190,7 @@ int (*nfsrv4_ops0[NFSV41_NOPS])(struct nfsrv_descript nfsrvd_notsupp, nfsrvd_sequence, nfsrvd_notsupp, - nfsrvd_notsupp, + nfsrvd_teststateid, nfsrvd_notsupp, nfsrvd_destroyclientid, nfsrvd_reclaimcomplete, Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Tue Jul 10 19:28:16 2018 (r336178) +++ stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Tue Jul 10 19:37:52 2018 (r336179) @@ -6070,6 +6070,32 @@ nfsrv_freestateid(struct nfsrv_descript *nd, nfsv4stat } /* + * Test a stateid. + */ +int +nfsrv_teststateid(struct nfsrv_descript *nd, nfsv4stateid_t *stateidp, + NFSPROC_T *p) +{ + struct nfsclient *clp; + struct nfsstate *stp; + int error; + + NFSLOCKSTATE(); + /* + * Look up the stateid + */ + error = nfsrv_getclient((nfsquad_t)((u_quad_t)0), CLOPS_RENEW, &clp, + NULL, (nfsquad_t)((u_quad_t)0), 0, nd, p); + if (error == 0) + error = nfsrv_getstate(clp, stateidp, 0, &stp); + if (error == 0 && stateidp->seqid != 0 && + SEQ_LT(stateidp->seqid, stp->ls_stateid.seqid)) + error = NFSERR_OLDSTATEID; + NFSUNLOCKSTATE(); + return (error); +} + +/* * Generate the xdr for an NFSv4.1 CBSequence Operation. */ static int