Date: Thu, 1 Apr 2021 22:12:35 GMT From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: b43fe9eb4b33 - main - nfsd: silence rpcb_unset noise for NFSv4 only servers Message-ID: <202104012212.131MCZsK038659@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b43fe9eb4b3365156016ae3477747a46fc094bb8 commit b43fe9eb4b3365156016ae3477747a46fc094bb8 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2021-04-01 22:09:03 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2021-04-01 22:09:03 +0000 nfsd: silence rpcb_unset noise for NFSv4 only servers An NFSv4 only configuration does not register with rpcbind(). Without this patch a failure to rpcb_unset() is reported when the daemon is terminated for this case. This is harmless noise, but this patch avoids calling rpcb_unset() for the NFSv4 only case, avoiding the noise. When called with "-d", it still does the rpcb_unset(), assuming that the configuration might have been changed to NFSv4 only and unregistering with rpcbind() might still be needed. Reviewed by: freqlabs MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D29449 --- usr.sbin/nfsd/nfsd.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index 0eb9c2560cf1..0222d23f2312 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -101,6 +101,7 @@ static int stablefd = -1; /* Fd for the stable restart file */ static int backupfd; /* Fd for the backup stable restart file */ static const char *getopt_shortopts; static const char *getopt_usage; +static int nfs_minvers = NFS_VER2; static int minthreads_set; static int maxthreads_set; @@ -170,7 +171,6 @@ main(int argc, char **argv) int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; int nfssvc_addsock; int longindex = 0; - int nfs_minvers = NFS_VER2; size_t nfs_minvers_size; const char *lopt; char **bindhost = NULL; @@ -307,6 +307,16 @@ main(int argc, char **argv) errx(1, "Out of memory"); } + if (unregister) { + /* + * Unregister before setting nfs_minvers, in case the + * value of vfs.nfsd.server_min_nfsvers has changed + * since registering with rpcbind. + */ + unregistration(); + exit (0); + } + nfs_minvers_size = sizeof(nfs_minvers); error = sysctlbyname("vfs.nfsd.server_min_nfsvers", &nfs_minvers, &nfs_minvers_size, NULL, 0); @@ -316,10 +326,6 @@ main(int argc, char **argv) nfs_minvers = NFS_VER2; } - if (unregister) { - unregistration(); - exit (0); - } if (reregister) { if (udpflag) { memset(&hints, 0, sizeof hints); @@ -935,8 +941,8 @@ reapchild(__unused int signo) static void unregistration(void) { - if ((!rpcb_unset(NFS_PROGRAM, 2, NULL)) || - (!rpcb_unset(NFS_PROGRAM, 3, NULL))) + if ((nfs_minvers == NFS_VER2 && !rpcb_unset(NFS_PROGRAM, 2, NULL)) || + (nfs_minvers <= NFS_VER3 && !rpcb_unset(NFS_PROGRAM, 3, NULL))) syslog(LOG_ERR, "rpcb_unset failed"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104012212.131MCZsK038659>