I tried configuring NFSv4 with TCP by setting the following in /etc/rc.conf: mountd_enable="YES" nfs_server_enable="YES" nfsv4_server_only="YES" nfsv4_server_enable="YES" nfsuserd_enable="YES" nfs_server_flags="-t --minthreads 1 --maxthreads 8" [SNIP] However, `mount_nfs -o nfsv4 -o tcp ...` on the client would fail with: mount_nfs: nmount: /mnt/test: Permission denied [SNIP] It kept doing this irrespective of any field values added to the sharenfs property until I added "V4: /" to /etc/exports So I think the nfsv4_server_* values in /etc/defaults/rc.conf might not be working as intended? Also, as an aside, mountd complains if /etc/exports doesn't exist, even if /etc/zfs/exports does when using the sharenfs property - this is mostly a nit, but it might as well be fixed if it's not intended to work like that.
Yes, the documentation about V4 exports is a bit confusing.
It looks like it was added with base r367423, and vfs.nfsd.server_min_nfsvers is indeed set to 4, but it doesn't seem like this is respected by nfsd? Hopefully rmacklem@ sees this bug report, otherwise, I might take the liberty of sending a quick email when some time has passed.
Not sure what you think the bug is? The "V4:" line is required for NFSv4 mounts. It tells the system where the root of the NFSv4 tree is. (NFSv4 does not use the mount protocol.) Is your concern that mountd did not log a message noting that "V4:" line is missing for the "-R" option case? (nfsv4_server_only="YES".) I can probably add a check for that to mountd. Not sure about the "no /etc/exports" file warning. As you can now see, /usr/zfs/exports is not a replacement for /etc/exports. Oh, and I recommend using "minorversion=1 or 2 on the nfsv4 mounts. Much better protocol than NFS v4.0.
(In reply to Rick Macklem from comment #3) I thought nfsv4_server_only=YES in /etc/rc.conf was meant to do the same as "V4: /" in /etc/exports, but from what you're saying, it sounds like this isn't the case, and nfsv4_server_only instead just adds the -R flag to nfsd? If that's the case, you're welcome to close this as Not A Bug, when you respond - that way, it won't generate multiple notifications. ;) I think NFSv4.2 isn't in 12.2-RELEASE, which is what my laptop uses. Once 13.0-RELEASE is out and I upgrade, I'll be using minorversion=2, as well.
I think adding a warning about the "V4:" line being missing is reasonable, when NFSv4 is enabled.
Created attachment 223005 [details] make mountd syslog that a V4: line is needed for NFSv4 service This patch makes mountd generate a syslog message when NFSv4 is enabled for the NFS server and there is no "V4:" line in any exports file. Hopefully this will clarify that one is required.
Would it be better to `grep "V4\:" /etc/exports"` ? Also, do you want this tested?
Technically a list of exports files can be given to mountd's command line and the "V4:" line(s) can exist in any one of them. /etc/exports is just the default and, for the case of zfs enabled, /usr/zfs/exports is specified after /etc/exports. Just look at /etc/rc.d/mountd You are welcome to test it. I am testing it to-day.
Also, the exports files get reloaded whenever a SIGHUP is posted to mountd, so the check needs to be in mountd when it does a (re)load.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=09673fc0f36dd1cca74940a240a9ed0f62228084 commit 09673fc0f36dd1cca74940a240a9ed0f62228084 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2021-03-09 00:08:02 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2021-03-09 00:08:02 +0000 mountd(8): generate a syslog message when the "V4:" line is missing Daniel reported that NFSv4 mounts were not working despite having set "nfsv4_server_enable=YES" in /etc/rc.conf. Mountd was logging a message that there was no /etc/exports file. He noted that creating a /etc/exports file with a "V4:" line in it was needed make NFSv4 mounts work. At least one "V4:" line in one of the exports(5) file(s) is needed to make NFSv4 mounts work. This patch fixes mountd.c so that it logs a message indicting that there is no "V4:" line in any exports(5) file when NFSv4 mounts are enabled. To avoid this message being generated erroneously, /etc/rc.d/mountd is updated to make sure vfs.nfsd.server_max_nfsvers is properly set before mountd(8) is started. Reported by: debdrup PR: 253901 MFC after: 2 weeks libexec/rc/rc.d/mountd | 3 +++ usr.sbin/mountd/mountd.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=85ad493677a28725505834f61f7ba2230bbb19b3 commit 85ad493677a28725505834f61f7ba2230bbb19b3 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2021-03-09 00:08:02 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2021-03-27 19:52:15 +0000 mountd(8): generate a syslog message when the "V4:" line is missing Daniel reported that NFSv4 mounts were not working despite having set "nfsv4_server_enable=YES" in /etc/rc.conf. Mountd was logging a message that there was no /etc/exports file. He noted that creating a /etc/exports file with a "V4:" line in it was needed make NFSv4 mounts work. At least one "V4:" line in one of the exports(5) file(s) is needed to make NFSv4 mounts work. This patch fixes mountd.c so that it logs a message indicting that there is no "V4:" line in any exports(5) file when NFSv4 mounts are enabled. To avoid this message being generated erroneously, /etc/rc.d/mountd is updated to make sure vfs.nfsd.server_max_nfsvers is properly set before mountd(8) is started. PR: 253901 (cherry picked from commit 09673fc0f36dd1cca74940a240a9ed0f62228084) libexec/rc/rc.d/mountd | 3 +++ usr.sbin/mountd/mountd.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5cc4e912e031c717e6ee6c2a0fd92137cc2dcefc commit 5cc4e912e031c717e6ee6c2a0fd92137cc2dcefc Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2021-03-09 00:08:02 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2021-03-27 20:03:51 +0000 mountd(8): generate a syslog message when the "V4:" line is missing Daniel reported that NFSv4 mounts were not working despite having set "nfsv4_server_enable=YES" in /etc/rc.conf. Mountd was logging a message that there was no /etc/exports file. He noted that creating a /etc/exports file with a "V4:" line in it was needed make NFSv4 mounts work. At least one "V4:" line in one of the exports(5) file(s) is needed to make NFSv4 mounts work. This patch fixes mountd.c so that it logs a message indicting that there is no "V4:" line in any exports(5) file when NFSv4 mounts are enabled. To avoid this message being generated erroneously, /etc/rc.d/mountd is updated to make sure vfs.nfsd.server_max_nfsvers is properly set before mountd(8) is started. PR: 253901 (cherry picked from commit 09673fc0f36dd1cca74940a240a9ed0f62228084) libexec/rc/rc.d/mountd | 3 +++ usr.sbin/mountd/mountd.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
Patch has been committed and MFC'd.