git: 57014f21e754 - main - nfscl: Fix NFSv4.1/4.2 Lookup+Open RPC

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sun, 13 Mar 2022 20:16:29 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=57014f21e754db70e4811f9d064303cd8608f164

commit 57014f21e754db70e4811f9d064303cd8608f164
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-03-13 20:15:12 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-03-13 20:15:12 +0000

    nfscl: Fix NFSv4.1/4.2 Lookup+Open RPC
    
    Use of the Lookup+Open RPC is currently disabled,
    due to a problem detected during testing.  This
    patch fixes this problem.  The problem was that
    nfscl_postop_attr() does not parse the attributes
    if nd_repstat != 0.  It also would parse the
    return status for the operation, where the
    Lookup+Open code had already parsed it.
    
    The first change in the patch does not make any
    semantics change, but makes the code identical
    to what is done later in the function, so that
    it is apparent that the semantics should be the
    same in both places.
    
    Lookup+Open remains disabled while further
    testing is being done, so this patch has no
    effect at this time.
---
 sys/fs/nfsclient/nfs_clrpcops.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 8886ccc8429e..cc4899af1c90 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -1499,10 +1499,9 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred,
 		    ND_NFSV4) {
 			/* Load the directory attributes. */
 			error = nfsm_loadattr(nd, dnap);
-			if (error == 0)
-				*dattrflagp = 1;
-			else
+			if (error != 0)
 				goto nfsmout;
+			*dattrflagp = 1;
 		}
 		/* Check Lookup operation reply status. */
 		if (openmode != 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) {
@@ -1524,10 +1523,15 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred,
 			NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
 			if (*++tl != 0)
 				goto nfsmout;
-			error = nfscl_postop_attr(nd, nap, attrflagp, stuff);
-			if (error == 0)
-				/* Successfully got Lookup done. */
+			error = nfsm_loadattr(nd, nap);
+			if (error == 0) {
+				/*
+				 * We have now successfully completed the
+				 * lookup, so set nd_repstat to 0.
+				 */
 				nd->nd_repstat = 0;
+				*attrflagp = 1;
+			}
 		}
 		goto nfsmout;
 	}