Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Default NFS mounts to using TCP transport instead of UDP.



details:   https://anonhg.NetBSD.org/src/rev/7fc5039a30f3
branches:  trunk
changeset: 322776:7fc5039a30f3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu May 17 02:34:31 2018 +0000

description:
Default NFS mounts to using TCP transport instead of UDP.
PR kern/53166

diffstat:

 sbin/mount_nfs/mount_nfs.8 |  20 +++++++++++++-------
 sbin/mount_nfs/mount_nfs.c |  22 +++++++++++++++++-----
 sys/nfs/files.nfs          |   4 ++--
 sys/nfs/nfs_boot.c         |  14 +++++++++-----
 4 files changed, 41 insertions(+), 19 deletions(-)

diffs (198 lines):

diff -r 5b33e0e78b4c -r 7fc5039a30f3 sbin/mount_nfs/mount_nfs.8
--- a/sbin/mount_nfs/mount_nfs.8        Wed May 16 21:54:38 2018 +0000
+++ b/sbin/mount_nfs/mount_nfs.8        Thu May 17 02:34:31 2018 +0000
@@ -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 @@
 .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 @@
 .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 @@
 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
diff -r 5b33e0e78b4c -r 7fc5039a30f3 sbin/mount_nfs/mount_nfs.c
--- a/sbin/mount_nfs/mount_nfs.c        Wed May 16 21:54:38 2018 +0000
+++ b/sbin/mount_nfs/mount_nfs.c        Thu May 17 02:34:31 2018 +0000
@@ -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 @@
 #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 @@
 #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 @@
        { "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 @@
        .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 @@
        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 @@
                                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 @@
                case 'X':
                        nfsargsp->flags |= NFSMNT_XLATECOOKIE;
                        break;
+               case 'u':
+                       nfsargsp->sotype = SOCK_DGRAM;
+                       break;
                case 'U':
                        mnttcp_ok = 0;
                        break;
@@ -500,7 +512,7 @@
 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]",
diff -r 5b33e0e78b4c -r 7fc5039a30f3 sys/nfs/files.nfs
--- a/sys/nfs/files.nfs Wed May 16 21:54:38 2018 +0000
+++ b/sys/nfs/files.nfs Thu May 17 02:34:31 2018 +0000
@@ -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
diff -r 5b33e0e78b4c -r 7fc5039a30f3 sys/nfs/nfs_boot.c
--- a/sys/nfs/nfs_boot.c        Wed May 16 21:54:38 2018 +0000
+++ b/sys/nfs/nfs_boot.c        Thu May 17 02:34:31 2018 +0000
@@ -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 @@
 #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 @@
        memset((void *) args, 0, sizeof(*args));
        args->addr     = &ndm->ndm_saddr;
        args->addrlen  = args->addr->sa_len;
-#ifdef NFS_BOOT_TCP
+#ifdef NFS_BOOT_UDP
+       args->sotype   = SOCK_DGRAM;
+#else
        args->sotype   = SOCK_STREAM;
-#else
-       args->sotype   = SOCK_DGRAM;
 #endif
        args->fh       = ndm->ndm_fh;
        args->hostname = ndm->ndm_host;



Home | Main Index | Thread Index | Old Index