diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 17e27a3860f4..3d5f5793d85c 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -522,15 +522,19 @@ getnfsargs(spec, nfsargsp) 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 RPC"); } else {