git: e647a222a1a7 - main - nfs_clrpcops.c: Fix handling of a CreateLayGet reply

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 16 May 2025 19:39:12 UTC
The branch main has been updated by rmacklem:

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

commit e647a222a1a74bd3b2bbdd7903fb30e4e30b6b09
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-05-16 19:36:39 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-05-16 19:36:39 +0000

    nfs_clrpcops.c: Fix handling of a CreateLayGet reply
    
    Without this patch, the CreateLayGet RPC did not handle a NFSv4.1/4.2
    reply for a pNFS server that also issued delegations.
    
    This patch fixes the problem.
    
    Detected at the recent NFSv4 Bakeathon testing event.
    
    This bug would only affect the rare case where the FreeBSD client
    is mounted to a pNFS server that issues delegations, where the
    "pnfs" mount option is specified.
    
    MFC after:      2 weeks
---
 sys/fs/nfsclient/nfs_clrpcops.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index c1f94a65e506..4ff56f75123c 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -8590,6 +8590,13 @@ nfsrpc_createlayout(vnode_t dvp, char *name, int namelen, struct vattr *vap,
 			    &ret, &acesize, p);
 			if (error != 0)
 				goto nfsmout;
+		} else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+		    NFSHASNFSV4N(nmp)) {
+			NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+			deleg = fxdr_unsigned(uint32_t, *tl);
+			if (deleg == NFSV4OPEN_CONTENTION ||
+			    deleg == NFSV4OPEN_RESOURCE)
+				NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
 		} else if (deleg != NFSV4OPEN_DELEGATENONE) {
 			error = NFSERR_BADXDR;
 			goto nfsmout;