git: 1cf8e6339e9a - main - mountd startup: enable NFSv4 if needed on restart

From: Mike Karels <karels_at_FreeBSD.org>
Date: Mon, 04 Jul 2022 13:00:37 UTC
The branch main has been updated by karels:

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

commit 1cf8e6339e9add47107a6c9988a0f509225b7ef6
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2022-07-03 23:04:41 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2022-07-04 13:00:10 +0000

    mountd startup: enable NFSv4 if needed on restart
    
    The mountd script in rc.d sets vfs.nfsd.server_max_nfsvers correctly
    when it is run at system startup, relying on the kernel default.
    However, if NFSv4 was enabled in /etc/rc.conf later, and the script
    was re-run to restart mountd, the sysctl was still set to 3.
    Set the sysctl to the right value in all cases.
    
    Reviewed by:    rmacklem
    MFC after:      1 week
---
 libexec/rc/rc.d/mountd | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.d/mountd b/libexec/rc/rc.d/mountd
index 0c6e75f07d64..d75416736245 100755
--- a/libexec/rc/rc.d/mountd
+++ b/libexec/rc/rc.d/mountd
@@ -34,7 +34,9 @@ mountd_precmd()
 		rc_flags="${rc_flags} -R"
 	else
 		force_depend rpcbind || return 1
-		if ! checkyesno nfsv4_server_enable; then
+		if checkyesno nfsv4_server_enable; then
+			sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
+		else
 			sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
 		fi
 	fi