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
This commit is contained in:
Joyu Liao 2024-09-29 13:11:54 -07:00 committed by Rick Macklem
parent 52b3514052
commit f321956d98

View File

@ -550,18 +550,24 @@ main(int argc, char **argv)
nfsd_exit(1); nfsd_exit(1);
} }
nconf_udp = getnetconfigent("udp"); nconf_udp = getnetconfigent("udp");
if (nconf_udp == NULL) if (nconf_udp == NULL) {
err(1, "getnetconfigent udp failed"); syslog(LOG_ERR, "getnetconfigent udp failed");
nfsd_exit(1);
}
nb_udp.buf = ai_udp->ai_addr; nb_udp.buf = ai_udp->ai_addr;
nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen; nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
if (nfs_minvers == NFS_VER2) if (nfs_minvers == NFS_VER2)
if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp, if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp,
&nb_udp)) &nb_udp)) {
err(1, "rpcb_set udp failed"); syslog(LOG_ERR, "rpcb_set udp failed");
nfsd_exit(1);
}
if (nfs_minvers <= NFS_VER3) if (nfs_minvers <= NFS_VER3)
if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp, if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp,
&nb_udp)) &nb_udp)) {
err(1, "rpcb_set udp failed"); syslog(LOG_ERR, "rpcb_set udp failed");
nfsd_exit(1);
}
freeaddrinfo(ai_udp); freeaddrinfo(ai_udp);
} }
} }
@ -624,20 +630,26 @@ main(int argc, char **argv)
nfsd_exit(1); nfsd_exit(1);
} }
nconf_udp6 = getnetconfigent("udp6"); nconf_udp6 = getnetconfigent("udp6");
if (nconf_udp6 == NULL) if (nconf_udp6 == NULL) {
err(1, "getnetconfigent udp6 failed"); syslog(LOG_ERR, "getnetconfigent udp6 failed");
nfsd_exit(1);
}
nb_udp6.buf = ai_udp6->ai_addr; nb_udp6.buf = ai_udp6->ai_addr;
nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen; nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen;
if (nfs_minvers == NFS_VER2) if (nfs_minvers == NFS_VER2)
if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp6, if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp6,
&nb_udp6)) &nb_udp6)) {
err(1, syslog(LOG_ERR,
"rpcb_set udp6 failed"); "rpcb_set udp6 failed");
nfsd_exit(1);
}
if (nfs_minvers <= NFS_VER3) if (nfs_minvers <= NFS_VER3)
if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp6, if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp6,
&nb_udp6)) &nb_udp6)) {
err(1, syslog(LOG_ERR,
"rpcb_set udp6 failed"); "rpcb_set udp6 failed");
nfsd_exit(1);
}
freeaddrinfo(ai_udp6); freeaddrinfo(ai_udp6);
} }
} }
@ -696,18 +708,24 @@ main(int argc, char **argv)
nfsd_exit(1); nfsd_exit(1);
} }
nconf_tcp = getnetconfigent("tcp"); nconf_tcp = getnetconfigent("tcp");
if (nconf_tcp == NULL) if (nconf_tcp == NULL) {
err(1, "getnetconfigent tcp failed"); syslog(LOG_ERR, "getnetconfigent tcp failed");
nfsd_exit(1);
}
nb_tcp.buf = ai_tcp->ai_addr; nb_tcp.buf = ai_tcp->ai_addr;
nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen; nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen;
if (nfs_minvers == NFS_VER2) if (nfs_minvers == NFS_VER2)
if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp, if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp,
&nb_tcp)) &nb_tcp)) {
err(1, "rpcb_set tcp failed"); syslog(LOG_ERR, "rpcb_set tcp failed");
nfsd_exit(1);
}
if (nfs_minvers <= NFS_VER3) if (nfs_minvers <= NFS_VER3)
if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp, if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp,
&nb_tcp)) &nb_tcp)) {
err(1, "rpcb_set tcp failed"); syslog(LOG_ERR, "rpcb_set tcp failed");
nfsd_exit(1);
}
freeaddrinfo(ai_tcp); freeaddrinfo(ai_tcp);
} }
} }
@ -774,18 +792,24 @@ main(int argc, char **argv)
nfsd_exit(1); nfsd_exit(1);
} }
nconf_tcp6 = getnetconfigent("tcp6"); nconf_tcp6 = getnetconfigent("tcp6");
if (nconf_tcp6 == NULL) if (nconf_tcp6 == NULL) {
err(1, "getnetconfigent tcp6 failed"); syslog(LOG_ERR, "getnetconfigent tcp6 failed");
nfsd_exit(1);
}
nb_tcp6.buf = ai_tcp6->ai_addr; nb_tcp6.buf = ai_tcp6->ai_addr;
nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen; nb_tcp6.len = nb_tcp6.maxlen = ai_tcp6->ai_addrlen;
if (nfs_minvers == NFS_VER2) if (nfs_minvers == NFS_VER2)
if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp6, if (!rpcb_set(NFS_PROGRAM, 2, nconf_tcp6,
&nb_tcp6)) &nb_tcp6)) {
err(1, "rpcb_set tcp6 failed"); syslog(LOG_ERR, "rpcb_set tcp6 failed");
nfsd_exit(1);
}
if (nfs_minvers <= NFS_VER3) if (nfs_minvers <= NFS_VER3)
if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp6, if (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp6,
&nb_tcp6)) &nb_tcp6)) {
err(1, "rpcb_set tcp6 failed"); syslog(LOG_ERR, "rpcb_set tcp6 failed");
nfsd_exit(1);
}
freeaddrinfo(ai_tcp6); freeaddrinfo(ai_tcp6);
} }
} }