NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/53166: NFS default to UDP; it should really default to TCP
>Number: 53166
>Category: kern
>Synopsis: NFS default to UDP; it should really default to TCP
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Apr 08 00:45:00 +0000 2018
>Originator: Jason Thorpe
>Release: NetBSD 8.99.12
>Organization:
>Environment:
NetBSD nixie-dev 8.99.12 NetBSD 8.99.12 (thorpej-RPI-NixieClock) #1: Fri Apr 6 12:34:23 PDT 2018 thorpej@BigMac.local:/Volumes/Data0/Users/thorpej/hack/NetBSD/current/src/sys/arch/evbarm/compile/thorpej-RPI-NixieClock evbarm
>Description:
NFS defaults to using UDP as a transport. It really should default to using TCP. There's really no reason to default to UDP anymore (servers that don't properly support TCP are ancient, at this point).
>How-To-Repeat:
Mount an NFS file system and observe the connection on the wire.
>Fix:
Index: sys/nfs/files.nfs
===================================================================
RCS file: /cvsroot/src/sys/nfs/files.nfs,v
retrieving revision 1.14
diff -u -p -r1.14 files.nfs
--- sys/nfs/files.nfs 11 Oct 2014 06:42:20 -0000 1.14
+++ sys/nfs/files.nfs 8 Apr 2018 00:24:12 -0000
@@ -3,7 +3,7 @@
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
Index: sys/nfs/nfs_boot.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_boot.c,v
retrieving revision 1.87
diff -u -p -r1.87 nfs_boot.c
--- sys/nfs/nfs_boot.c 15 Nov 2016 01:50:06 -0000 1.87
+++ sys/nfs/nfs_boot.c 8 Apr 2018 00:24:12 -0000
@@ -43,6 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v
#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,
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;
Index: sbin/mount_nfs/mount_nfs.8
===================================================================
RCS file: /cvsroot/src/sbin/mount_nfs/mount_nfs.8,v
retrieving revision 1.46
diff -u -p -r1.46 mount_nfs.8
--- sbin/mount_nfs/mount_nfs.8 3 Jul 2017 21:33:41 -0000 1.46
+++ sbin/mount_nfs/mount_nfs.8 8 Apr 2018 00:24:12 -0000
@@ -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
Index: sbin/mount_nfs/mount_nfs.c
===================================================================
RCS file: /cvsroot/src/sbin/mount_nfs/mount_nfs.c,v
retrieving revision 1.71
diff -u -p -r1.71 mount_nfs.c
--- sbin/mount_nfs/mount_nfs.c 29 Jun 2013 22:56:26 -0000 1.71
+++ sbin/mount_nfs/mount_nfs.c 8 Apr 2018 00:24:12 -0000
@@ -98,6 +98,7 @@ __RCSID("$NetBSD: mount_nfs.c,v 1.71 201
#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]",
Home |
Main Index |
Thread Index |
Old Index