From 5f7313a10b63da796d5cd79c01db1e097d4a6bf1 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 14 Jul 2009 16:29:11 -0400 Subject: [PATCH] mount.nfs: If port= specifies an unregistered port, retry, then fail Suppose a port= option is specified on the mount command line, but not enough other mount options are specified to avoid an rpcbind query to discover the NFS service. If the NFS service isn't registered on [100003, 3, "tcp", port] (even if the server is listening on the specified port), the legacy mount.nfs command fails immediately with: mount.nfs: mount to NFS server 'server' failed: RPC Error: Success What's more, this mount request should succeeded if an NFS service is registered on the specified port for another version and/or protocol. So instead, let's retry the rpcbind query with the other versions and transport protocols to be absolutely sure that port won't work with either version or transport. Then, if all fails, report: mount.nfs: mount to NFS server 'server' failed: RPC Error: Program not registered This change also affects text-based mounts that require negotiation by the mount.nfs command. Note that if the mount options specify all four pmap parameters for NFS, the rpcbind query for the NFS service is skipped entirely. The mount command then hangs and times out later if NFS service is not listening on the requested tuple. This is unchanged from previous behavior. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/mount/network.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/mount/network.c b/utils/mount/network.c index 9661995..73d64a2 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -567,7 +567,8 @@ static int nfs_probe_port(const struct sockaddr *sap, const socklen_t salen, if (nfs_rpc_ping(saddr, salen, prog, *p_vers, *p_prot, NULL)) goto out_ok; - } + } else + rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; } if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED && rpc_createerr.cf_stat != RPC_TIMEDOUT && -- 2.39.5