git: 4adb28c0abfa - main - nfscl: Fix support for doing Null RPCs

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 07 Apr 2023 19:58:36 UTC
The branch main has been updated by rmacklem:

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

commit 4adb28c0abfa3b8d076c7249f61a093c6eb9dac2
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2023-04-07 19:57:26 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2023-04-07 19:57:26 +0000

    nfscl: Fix support for doing Null RPCs
    
    Although the NFS client does not currently perform Null RPCs,
    this fix is needed if/when it might do so.
    Found during testing of experimental code that uses Null RPCs
    to maintain/monitor TCP connections for "nconnect" mounts.
    
    MFC after:      3 months
---
 sys/fs/nfs/nfs_commonsubs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 81bd2beba749..cb12f5a59a6e 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -375,6 +375,10 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp,
 	nd->nd_mreq = nd->nd_mb = mb;
 	nd->nd_bpos = mtod(mb, char *);
 
+	/* For NFSPROC_NULL, there are no arguments. */
+	if (procnum == NFSPROC_NULL)
+		goto out;
+
 	/*
 	 * And fill the first file handle into the request.
 	 */
@@ -470,6 +474,7 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp,
 	} else {
 		(void)nfsm_fhtom(NULL, nd, nfhp, fhlen, 0);
 	}
+out:
 	if (procnum < NFSV42_NPROCS)
 		NFSINCRGLOBAL(nfsstatsv1.rpccnt[procnum]);
 }