Subject: bin/480: Cannot mount NFS filesystem from hosts that only support NFS/TCP
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: None <kenh@entropic.com>
List: netbsd-bugs
Date: 09/16/1994 21:35:04
>Number:         480
>Category:       bin
>Synopsis:       Cannot mount NFS filesystem from hosts that only support NFS/TCP
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 16 21:35:03 1994
>Originator:     Ken Hornstein
>Organization:
"	"
>Release:        
>Environment:
	
System: NetBSD excalibur 1.0_BETA NetBSD 1.0_BETA (EXCALIBUR) #1: Sun Sep 4 00:05:14 EDT 1994 kenh@excalibur:/usr/src/sys/arch/i386/compile/EXCALIBUR i386


>Description:
Even if you give the -T option to mount_nfs, it still uses UDP to get the
initial filehandle for the mount system call.  This fails if the remote host
only supports NFS/TCP.  Mount_nfs should use the same transport type to get
the initial filehandle as it uses for the mount.
	
>How-To-Repeat:
mount -t nfs -o rdonly,-T playground.sun.com:/export/home/ftp /mnt

(playground.sun.com is a machine at Sun which exports that filesystem to the
world, but only for NFS/TCP mounts)
	
>Fix:
	
This seems to solve the problem, but the code itself is a bit ugly -- but you
get the idea.

--- src/sbin/mount_nfs/mount_nfs.c.old	Fri Sep 16 16:28:01 1994
+++ src/sbin/mount_nfs/mount_nfs.c	Sat Sep 17 00:13:01 1994
@@ -454,15 +454,19 @@
 		saddr.sin_family = AF_INET;
 		saddr.sin_port = htons(PMAPPORT);
 		if ((tport = pmap_getport(&saddr, RPCPROG_NFS,
-		    NFS_VER2, IPPROTO_UDP)) == 0) {
+		    NFS_VER2, nfsargsp->sotype == SOCK_STREAM ? IPPROTO_TCP :
+		    IPPROTO_UDP)) == 0) {
 			if ((opflags & ISBGRND) == 0)
 				clnt_pcreateerror("NFS Portmap");
 		} else {
 			saddr.sin_port = 0;
 			pertry.tv_sec = 10;
 			pertry.tv_usec = 0;
-			if ((clp = clntudp_create(&saddr, RPCPROG_MNT,
-			    RPCMNT_VER1, pertry, &so)) == NULL) {
+			if ((clp = (nfsargsp->sotype == SOCK_STREAM ?
+			    clnttcp_create(&saddr, RPCPROG_MNT, RPCMNT_VER1,
+					   &so, 0, 0) :
+			    clntudp_create(&saddr, RPCPROG_MNT, RPCMNT_VER1,
+					   pertry, &so))) == NULL) {
 				if ((opflags & ISBGRND) == 0)
 					clnt_pcreateerror("Cannot MNT PRC");
 			} else {
>Audit-Trail:
>Unformatted: