aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mountd
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2021-03-09 00:08:02 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2021-03-27 19:52:15 +0000
commit85ad493677a28725505834f61f7ba2230bbb19b3 (patch)
treee7378c6f798cea5f70e0d7e31b4eb76ae9fd14b2 /usr.sbin/mountd
parent0e9d4b8b75748064d0c8603304a4309e5b5645ca (diff)
downloadsrc-85ad493677a28725505834f61f7ba2230bbb19b3.tar.gz
src-85ad493677a28725505834f61f7ba2230bbb19b3.zip
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)
Diffstat (limited to 'usr.sbin/mountd')
-rw-r--r--usr.sbin/mountd/mountd.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 76972c66a6ed..c66ac13b3016 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -1888,10 +1888,11 @@ get_exportlist(int passno)
struct iovec *iov;
struct statfs *mntbufp;
char errmsg[255];
- int num, i;
+ int error, i, nfs_maxvers, num;
int iovlen;
struct nfsex_args eargs;
FILE *debug_file;
+ size_t nfs_maxvers_size;
if ((debug_file = fopen(_PATH_MOUNTDDEBUG, "r")) != NULL) {
fclose(debug_file);
@@ -2015,6 +2016,21 @@ get_exportlist(int passno)
read_exportfile(0);
}
+ if (strlen(v4root_dirpath) == 0) {
+ /* Check to see if a V4: line is needed. */
+ nfs_maxvers_size = sizeof(nfs_maxvers);
+ error = sysctlbyname("vfs.nfsd.server_max_nfsvers",
+ &nfs_maxvers, &nfs_maxvers_size, NULL, 0);
+ if (error != 0 || nfs_maxvers < NFS_VER2 || nfs_maxvers >
+ NFS_VER4) {
+ syslog(LOG_ERR, "sysctlbyname(vfs.nfsd."
+ "server_max_nfsvers) failed, defaulting to NFSv3");
+ nfs_maxvers = NFS_VER3;
+ }
+ if (nfs_maxvers == NFS_VER4)
+ syslog(LOG_ERR, "NFSv4 requires at least one V4: line");
+ }
+
if (iov != NULL) {
/* Free strings allocated by strdup() in getmntopts.c */
free(iov[0].iov_base); /* fstype */