git: f321956d9806 - main - nfsd.c: Synchronize error handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 29 Sep 2024 20:14:08 UTC
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f321956d9806bf0c171b9097a25b294c1498c9de commit f321956d9806bf0c171b9097a25b294c1498c9de Author: Joyu Liao <joyul@juniper.net> AuthorDate: 2024-09-29 20:11:54 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2024-09-29 20:11:54 +0000 nfsd.c: Synchronize error handling Synchronize the error handling in nfsd. If you check other error handlings in those same condition blocks, it uses nfsd_exit instead, which will call killchildren() and call the rpcbind service to do the service un-mapping. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D46442 --- usr.sbin/nfsd/nfsd.c | 72 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index b6c60ce72834..f1f04af192da 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -550,18 +550,24 @@ main(int argc, char **argv) nfsd_exit(1); } nconf_udp = getnetconfigent("udp"); - if (nconf_udp == NULL) - err(1, "getnetconfigent udp failed"); + if (nconf_udp == NULL) { + syslog(LOG_ERR, "getnetconfigent udp failed"); + nfsd_exit(1); + } nb_udp.buf = ai_udp->ai_addr; nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen; if (nfs_minvers == NFS_VER2) if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp, - &nb_udp)) - err(1, "rpcb_set udp failed"); + &nb_udp)) { + syslog(LOG_ERR, "rpcb_set udp failed"); + nfsd_exit(1); + } if (nfs_minvers <= NFS_VER3) if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp, - &nb_udp)) - err(1, "rpcb_set udp failed"); + &nb_udp)) { + syslog(LOG_ERR, "rpcb_set udp failed"); + nfsd_exit(1); + } freeaddrinfo(ai_udp); } } @@ -624,20 +630,26 @@ main(int argc, char **argv) nfsd_exit(1); } nconf_udp6 = getnetconfigent("udp6"); - if (nconf_udp6 == NULL) - err(1, "getnetconfigent udp6 failed"); + if (nconf_udp6 == NULL) { + syslog(LOG_ERR, "getnetconfigent udp6 failed"); + nfsd_exit(1); + } nb_udp6.buf = ai_udp6->ai_addr; nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen; if (nfs_minvers == NFS_VER2) if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp6, - &nb_udp6)) - err(1, + &nb_udp6)) { + syslog(LOG_ERR, "rpcb_set udp6 failed"); + nfsd_exit(1); + } if (nfs_minvers <= NFS_VER3) if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp6, - &nb_udp6)) - err(1, + &nb_udp6)) { + syslog(LOG_ERR, "rpcb_set udp6 failed"); + nfsd_exit(1); + } freeaddrinfo(ai_udp6); } } @@ -696,18 +708,24 @@ main(int argc, char **argv) nfsd_exit(1); } nconf_tcp = getnetconfigent("tcp"); - if (nconf_tcp == NULL) - err(1, "getnetconfigent tcp failed"); + if (nconf_tcp == NULL) { + syslog(LOG_ERR, "getnetconfigent tcp failed"); + nfsd_exit(1); + } nb_tcp.buf = ai_tcp->ai_addr; nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen; if (nfs_minvers == NFS_VER2) if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp, - &nb_tcp)) - err(1, "rpcb_set tcp failed"); + &nb_tcp)) { + syslog(LOG_ERR, "rpcb_set tcp failed"); + nfsd_exit(1); + } if (nfs_minvers <= NFS_VER3) if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp, - &nb_tcp)) - err(1, "rpcb_set tcp failed"); + &nb_tcp)) { + syslog(LOG_ERR, "rpcb_set tcp failed"); + nfsd_exit(1); + } freeaddrinfo(ai_tcp); } } @@ -774,18 +792,24 @@ main(int argc, char **argv) nfsd_exit(1); } nconf_tcp6 = getnetconfigent("tcp6"); - if (nconf_tcp6 == NULL) - err(1, "getnetconfigent tcp6 failed"); + if (nconf_tcp6 == NULL) { + syslog(LOG_ERR, "getnetconfigent tcp6 failed"); + nfsd_exit(1); + } nb_tcp6.buf = ai_tcp6->ai_addr; nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen; if (nfs_minvers == NFS_VER2) if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp6, - &nb_tcp6)) - err(1, "rpcb_set tcp6 failed"); + &nb_tcp6)) { + syslog(LOG_ERR, "rpcb_set tcp6 failed"); + nfsd_exit(1); + } if (nfs_minvers <= NFS_VER3) if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp6, - &nb_tcp6)) - err(1, "rpcb_set tcp6 failed"); + &nb_tcp6)) { + syslog(LOG_ERR, "rpcb_set tcp6 failed"); + nfsd_exit(1); + } freeaddrinfo(ai_tcp6); } }