Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/nfsd/nfsd.c
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
static int nfsdcnt_set; | static int nfsdcnt_set; | ||||
static int minthreads; | static int minthreads; | ||||
static int maxthreads; | static int maxthreads; | ||||
static int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */ | static int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */ | ||||
static int stablefd = -1; /* Fd for the stable restart file */ | static int stablefd = -1; /* Fd for the stable restart file */ | ||||
static int backupfd; /* Fd for the backup stable restart file */ | static int backupfd; /* Fd for the backup stable restart file */ | ||||
static const char *getopt_shortopts; | static const char *getopt_shortopts; | ||||
static const char *getopt_usage; | static const char *getopt_usage; | ||||
static int nfs_minvers = NFS_VER2; | |||||
static int minthreads_set; | static int minthreads_set; | ||||
static int maxthreads_set; | static int maxthreads_set; | ||||
static struct option longopts[] = { | static struct option longopts[] = { | ||||
{ "debug", no_argument, &debug, 1 }, | { "debug", no_argument, &debug, 1 }, | ||||
{ "minthreads", required_argument, &minthreads_set, 1 }, | { "minthreads", required_argument, &minthreads_set, 1 }, | ||||
{ "maxthreads", required_argument, &maxthreads_set, 1 }, | { "maxthreads", required_argument, &maxthreads_set, 1 }, | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
int ch, connect_type_cnt, i, maxsock, msgsock; | int ch, connect_type_cnt, i, maxsock, msgsock; | ||||
socklen_t len; | socklen_t len; | ||||
int on = 1, unregister, reregister, sock; | int on = 1, unregister, reregister, sock; | ||||
int tcp6sock, ip6flag, tcpflag, tcpsock; | int tcp6sock, ip6flag, tcpflag, tcpsock; | ||||
int udpflag, ecode, error, s; | int udpflag, ecode, error, s; | ||||
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; | int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; | ||||
int nfssvc_addsock; | int nfssvc_addsock; | ||||
int longindex = 0; | int longindex = 0; | ||||
int nfs_minvers = NFS_VER2; | |||||
size_t nfs_minvers_size; | size_t nfs_minvers_size; | ||||
const char *lopt; | const char *lopt; | ||||
char **bindhost = NULL; | char **bindhost = NULL; | ||||
pid_t pid; | pid_t pid; | ||||
struct nfsd_nfsd_args nfsdargs; | struct nfsd_nfsd_args nfsdargs; | ||||
const char *vhostname = NULL; | const char *vhostname = NULL; | ||||
nfsdargs.mirrorcnt = 1; | nfsdargs.mirrorcnt = 1; | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | if (bindhostc == 0 || bindanyflag) { | ||||
bindhost = realloc(bindhost,sizeof(char *)*bindhostc); | bindhost = realloc(bindhost,sizeof(char *)*bindhostc); | ||||
if (bindhost == NULL) | if (bindhost == NULL) | ||||
errx(1, "Out of memory"); | errx(1, "Out of memory"); | ||||
bindhost[bindhostc-1] = strdup("*"); | bindhost[bindhostc-1] = strdup("*"); | ||||
if (bindhost[bindhostc-1] == NULL) | if (bindhost[bindhostc-1] == NULL) | ||||
errx(1, "Out of memory"); | errx(1, "Out of memory"); | ||||
} | } | ||||
if (unregister) { | |||||
/* | |||||
* Unregister before setting nfs_minvers, in case the | |||||
* value of vfs.nfsd.server_min_nfsvers has changed | |||||
freqlabs: Why is this moved above where nfs_minvers gets set? | |||||
Not Done Inline ActionsAh this is how you achieved "still does the rpcb_unset(), freqlabs: Ah this is how you achieved "still does the rpcb_unset(),
assuming that the configuration might… | |||||
* since registering with rpcbind. | |||||
*/ | |||||
unregistration(); | |||||
exit (0); | |||||
} | |||||
nfs_minvers_size = sizeof(nfs_minvers); | nfs_minvers_size = sizeof(nfs_minvers); | ||||
error = sysctlbyname("vfs.nfsd.server_min_nfsvers", &nfs_minvers, | error = sysctlbyname("vfs.nfsd.server_min_nfsvers", &nfs_minvers, | ||||
&nfs_minvers_size, NULL, 0); | &nfs_minvers_size, NULL, 0); | ||||
if (error != 0 || nfs_minvers < NFS_VER2 || nfs_minvers > NFS_VER4) { | if (error != 0 || nfs_minvers < NFS_VER2 || nfs_minvers > NFS_VER4) { | ||||
warnx("sysctlbyname(vfs.nfsd.server_min_nfsvers) failed," | warnx("sysctlbyname(vfs.nfsd.server_min_nfsvers) failed," | ||||
" defaulting to NFSv2"); | " defaulting to NFSv2"); | ||||
nfs_minvers = NFS_VER2; | nfs_minvers = NFS_VER2; | ||||
} | } | ||||
if (unregister) { | |||||
unregistration(); | |||||
exit (0); | |||||
} | |||||
if (reregister) { | if (reregister) { | ||||
if (udpflag) { | if (udpflag) { | ||||
memset(&hints, 0, sizeof hints); | memset(&hints, 0, sizeof hints); | ||||
hints.ai_flags = AI_PASSIVE; | hints.ai_flags = AI_PASSIVE; | ||||
hints.ai_family = AF_INET; | hints.ai_family = AF_INET; | ||||
hints.ai_socktype = SOCK_DGRAM; | hints.ai_socktype = SOCK_DGRAM; | ||||
hints.ai_protocol = IPPROTO_UDP; | hints.ai_protocol = IPPROTO_UDP; | ||||
ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp); | ecode = getaddrinfo(NULL, "nfs", &hints, &ai_udp); | ||||
▲ Show 20 Lines • Show All 599 Lines • ▼ Show 20 Lines | for (i = 0; i < nfsdcnt; i++) | ||||
if (pid == children[i]) | if (pid == children[i]) | ||||
children[i] = -1; | children[i] = -1; | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
unregistration(void) | unregistration(void) | ||||
{ | { | ||||
if ((!rpcb_unset(NFS_PROGRAM, 2, NULL)) || | if ((nfs_minvers == NFS_VER2 && !rpcb_unset(NFS_PROGRAM, 2, NULL)) || | ||||
(!rpcb_unset(NFS_PROGRAM, 3, NULL))) | (nfs_minvers <= NFS_VER3 && !rpcb_unset(NFS_PROGRAM, 3, NULL))) | ||||
syslog(LOG_ERR, "rpcb_unset failed"); | syslog(LOG_ERR, "rpcb_unset failed"); | ||||
} | } | ||||
static void | static void | ||||
killchildren(void) | killchildren(void) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 396 Lines • Show Last 20 Lines |
Why is this moved above where nfs_minvers gets set?