summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/mount_nfs/mount_nfs.816
-rw-r--r--sbin/mount_nfs/mount_nfs.c20
2 files changed, 23 insertions, 13 deletions
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8
index 066f9af78f3..52d44b53a57 100644
--- a/sbin/mount_nfs/mount_nfs.8
+++ b/sbin/mount_nfs/mount_nfs.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mount_nfs.8,v 1.13 1999/05/23 14:11:17 aaron Exp $
+.\" $OpenBSD: mount_nfs.8,v 1.14 1999/05/31 17:26:12 millert Exp $
.\" $NetBSD: mount_nfs.8,v 1.3 1996/02/18 11:59:10 fvdl Exp $
.\"
.\" Copyright (c) 1992, 1993, 1994, 1995
@@ -114,11 +114,12 @@ Set the retry count for doing the mount to the specified value.
.It Fl T
Use TCP transport instead of UDP.
This is recommended for servers that are not on the same LAN cable as
-the client.
-(NB: This is NOT supported by most non-BSD servers.)
+the client. The default for NFS Version 3 mounts is to try TCP transport
+first, and fall back to UDP if the mount fails.
.It Fl U
-Force the mount protocol to use UDP transport, even for TCP NFS mounts.
-(Necessary for some old BSD servers.)
+Force the mount protocol to use UDP transport, even for TCP NFS mounts
+(necessary for some old BSD servers). This is the default for NFS Version
+2 mounts.
.It Fl a Ar maxreadahead
Set the read-ahead count to the specified value.
This may be in the range of 0 - 4, and determines how many blocks
@@ -250,7 +251,4 @@ transport, tuning such mounts is really a black art that can only be expected
to have limited success.
For clients mounting servers that are not on the same
LAN cable or that tend to be overloaded,
-TCP transport is strongly recommended,
-but unfortunately this is restricted to mostly
-.Bx 4.4
-servers.
+TCP transport is strongly recommended.
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 1d703312ecd..0e8599a484a 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_nfs.c,v 1.15 1998/05/16 06:28:00 deraadt Exp $ */
+/* $OpenBSD: mount_nfs.c,v 1.16 1999/05/31 17:26:12 millert Exp $ */
/* $NetBSD: mount_nfs.c,v 1.12.4.1 1996/05/25 22:48:05 fvdl Exp $ */
/*
@@ -168,7 +168,6 @@ struct nfhret {
#define ISBGRND 2
int retrycnt;
int opflags = 0;
-int nfsproto = IPPROTO_UDP;
int mnttcp_ok = 1;
u_short port_no = 0;
int force2 = 0;
@@ -354,7 +353,7 @@ main(argc, argv)
nfsargsp->flags |= NFSMNT_SOFT;
if (altflags & ALTF_TCP) {
nfsargsp->sotype = SOCK_STREAM;
- nfsproto = IPPROTO_TCP;
+ mnttcp_ok = 2;
}
if (altflags & ALTF_PORT)
port_no = atoi(strstr(optarg, "port=") + 5);
@@ -392,7 +391,7 @@ main(argc, argv)
break;
case 'T':
nfsargsp->sotype = SOCK_STREAM;
- nfsproto = IPPROTO_TCP;
+ mnttcp_ok = 2;
break;
case 't':
num = strtol(optarg, &p, 10);
@@ -431,6 +430,10 @@ main(argc, argv)
spec = *argv++;
name = *argv;
+ /* Use TCP for NFSV3 by default */
+ if (mnttcp_ok == 1 && (nfsargsp->flags & NFSMNT_NFSV3))
+ nfsargsp->sotype = SOCK_STREAM;
+
if (!getnfsargs(spec, nfsargsp))
exit(1);
if (mount(MOUNT_NFS, name, mntflags, nfsargsp)) {
@@ -652,6 +655,15 @@ tryagain:
if ((tport = port_no ? port_no : pmap_getport(&saddr,
RPCPROG_NFS, nfsvers, nfsargsp->sotype == SOCK_STREAM ?
IPPROTO_TCP : IPPROTO_UDP)) == 0) {
+ /*
+ * If user didn't specifically request TCP,
+ * fall back to UDP for NFSV3 mounts.
+ */
+ if (nfsvers == NFS_VER3 && mnttcp_ok == 1) {
+ nfsargsp->sotype = SOCK_DGRAM;
+ mnttcp_ok = 0;
+ continue;
+ }
if ((opflags & ISBGRND) == 0)
clnt_pcreateerror("NFS Portmap");
} else {