Default NFS mounts to using TCP transport instead of UDP.

PR kern/53166
This commit is contained in:
thorpej 2018-05-17 02:34:31 +00:00
parent 6f84763bba
commit e832c294bb
4 changed files with 41 additions and 19 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: mount_nfs.8,v 1.46 2017/07/03 21:33:41 wiz Exp $
.\" $NetBSD: mount_nfs.8,v 1.47 2018/05/17 02:34:31 thorpej Exp $
.\"
.\" Copyright (c) 1992, 1993, 1994, 1995
.\" The Regents of the University of California. All rights reserved.
@ -37,7 +37,7 @@
.Nd mount NFS file systems
.Sh SYNOPSIS
.Nm
.Op Fl 23bCcdilPpqsTUX
.Op Fl 23bCcdilPpqsTUuX
.Op Fl a Ar maxreadahead
.Op Fl D Ar deadthresh
.Op Fl g Ar maxgroups
@ -241,6 +241,9 @@ Same as
.It Cm tcp
Same as
.Fl T .
.It Cm udp
Same as
.Fl u .
.It Cm timeo Ns = Ns Aq Ar timeout
Same as
.Fl t Ar timeout .
@ -294,11 +297,8 @@ Use
.Tn TCP
transport instead of
.Tn UDP .
This is recommended for servers that are not on the same physical network as
the client.
Not all
.Tn NFS
servers, especially not old ones, support this.
This is the default;
the flag is maintained for backwards compatibility.
.It Fl t Ar timeout
Set the initial retransmit timeout to the specified value in 0.1 seconds.
May be useful for fine tuning
@ -323,6 +323,12 @@ mounts.
This is necessary for some old
.Bx
servers.
.It Fl u
Use
.Tn UDP
transport instead of
.Tn TCP .
This may be necessary for some very old servers.
.It Fl w Ar writesize
Set the write data size to the specified value in bytes.
.Pp

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_nfs.c,v 1.71 2013/06/29 22:56:26 christos Exp $ */
/* $NetBSD: mount_nfs.c,v 1.72 2018/05/17 02:34:31 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: mount_nfs.c,v 1.71 2013/06/29 22:56:26 christos Exp $");
__RCSID("$NetBSD: mount_nfs.c,v 1.72 2018/05/17 02:34:31 thorpej Exp $");
#endif
#endif /* not lint */
@ -98,6 +98,7 @@ __RCSID("$NetBSD: mount_nfs.c,v 1.71 2013/06/29 22:56:26 christos Exp $");
#define ALTF_DEADTHRESH 0x00200000
#define ALTF_TIMEO 0x00400000
#define ALTF_RETRANS 0x00800000
#define ALTF_UDP 0x01000000
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
@ -115,6 +116,7 @@ static const struct mntopt mopts[] = {
{ "nqnfs", 0, ALTF_NQNFS, 1 },
{ "soft", 0, ALTF_SOFT, 1 },
{ "tcp", 0, ALTF_TCP, 1 },
{ "udp", 0, ALTF_UDP, 1 },
{ "nfsv2", 0, ALTF_NFSV2, 1 },
{ "port", 0, ALTF_PORT, 1 },
{ "rsize", 0, ALTF_RSIZE, 1 },
@ -133,7 +135,7 @@ struct nfs_args nfsdefargs = {
.version = NFS_ARGSVERSION,
.addr = NULL,
.addrlen = sizeof(struct sockaddr_in),
.sotype = SOCK_DGRAM,
.sotype = SOCK_STREAM,
.proto = 0,
.fh = NULL,
.fhsize = 0,
@ -201,7 +203,7 @@ mount_nfs_parseargs(int argc, char *argv[],
memset(nfsargsp, 0, sizeof(*nfsargsp));
*nfsargsp = nfsdefargs;
while ((c = getopt(argc, argv,
"23a:bcCdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:UX")) != -1)
"23a:bcCdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:UuX")) != -1)
switch (c) {
case '3':
case 'q':
@ -298,6 +300,13 @@ mount_nfs_parseargs(int argc, char *argv[],
nfsargsp->flags &= ~NFSMNT_RESVPORT;
if (altflags & ALTF_SOFT)
nfsargsp->flags |= NFSMNT_SOFT;
if (altflags & ALTF_UDP) {
nfsargsp->sotype = SOCK_DGRAM;
}
/*
* After UDP, because TCP overrides if both
* are present.
*/
if (altflags & ALTF_TCP) {
nfsargsp->sotype = SOCK_STREAM;
}
@ -404,6 +413,9 @@ mount_nfs_parseargs(int argc, char *argv[],
case 'X':
nfsargsp->flags |= NFSMNT_XLATECOOKIE;
break;
case 'u':
nfsargsp->sotype = SOCK_DGRAM;
break;
case 'U':
mnttcp_ok = 0;
break;
@ -500,7 +512,7 @@ static void
usage(void)
{
(void)fprintf(stderr, "usage: %s %s\n%s\n%s\n%s\n%s\n", getprogname(),
"[-23bCcdilPpqsTUX] [-a maxreadahead] [-D deadthresh]",
"[-23bCcdilPpqsTUuX] [-a maxreadahead] [-D deadthresh]",
"\t[-g maxgroups] [-I readdirsize] [-L leaseterm]",
"\t[-o options] [-R retrycnt] [-r readsize] [-t timeout]",
"\t[-w writesize] [-x retrans]",

View File

@ -1,9 +1,9 @@
# $NetBSD: files.nfs,v 1.14 2014/10/11 06:42:20 uebayasi Exp $
# $NetBSD: files.nfs,v 1.15 2018/05/17 02:34:31 thorpej Exp $
deffs NFS
defflag opt_nfs_boot.h NFS_BOOT_BOOTP NFS_BOOT_BOOTPARAM NFS_BOOT_DHCP
NFS_BOOT_GATEWAY NFS_BOOT_TCP
NFS_BOOT_GATEWAY NFS_BOOT_TCP NFS_BOOT_UDP
NFS_BOOT_BOOTSTATIC
defparam opt_nfs_boot.h NFS_BOOT_BOOTP_REQFILE NFS_BOOT_OPTIONS

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_boot.c,v 1.87 2016/11/15 01:50:06 ozaki-r Exp $ */
/* $NetBSD: nfs_boot.c,v 1.88 2018/05/17 02:34:31 thorpej Exp $ */
/*-
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.87 2016/11/15 01:50:06 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.88 2018/05/17 02:34:31 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@ -43,6 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.87 2016/11/15 01:50:06 ozaki-r Exp $"
#include "opt_nfs_boot.h"
#endif
#ifdef NFS_BOOT_TCP
#undef NFS_BOOT_UDP
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -597,10 +601,10 @@ nfs_boot_getfh(struct nfs_dlmount *ndm, struct lwp *l)
memset((void *) args, 0, sizeof(*args));
args->addr = &ndm->ndm_saddr;
args->addrlen = args->addr->sa_len;
#ifdef NFS_BOOT_TCP
args->sotype = SOCK_STREAM;
#else
#ifdef NFS_BOOT_UDP
args->sotype = SOCK_DGRAM;
#else
args->sotype = SOCK_STREAM;
#endif
args->fh = ndm->ndm_fh;
args->hostname = ndm->ndm_host;