Blame SOURCES/autofs-5.1.3-add-port-parameter-to-rpc_ping.patch

7f6688
autofs-5.1.3 - add port parameter to rpc_ping()
7f6688
7f6688
From: Ian Kent <raven@themaw.net>
7f6688
7f6688
Commit 4914be96 introduced an NFS ping probe to check availability on
7f6688
fallback from bind mount failure but failed to take into account the
7f6688
case where the port option had been given to avoid bind mounting.
7f6688
7f6688
Change rpc_ping() and __rpc_ping() to take a port parameter and don't
7f6688
contact the portmapper or rpcbind if it is valid.
7f6688
7f6688
Signed-off-by: Ian Kent <raven@themaw.net>
7f6688
---
7f6688
 CHANGELOG           |    1 +
7f6688
 include/rpc_subs.h  |    2 +-
7f6688
 lib/rpc_subs.c      |   43 +++++++++++++++++++++++++++----------------
7f6688
 modules/mount_nfs.c |    2 +-
7f6688
 4 files changed, 30 insertions(+), 18 deletions(-)
7f6688
7f6688
--- autofs-5.0.7.orig/CHANGELOG
7f6688
+++ autofs-5.0.7/CHANGELOG
7f6688
@@ -304,6 +304,7 @@
7f6688
 - fix update_negative_cache() map source usage.
7f6688
 - mark removed cache entry negative.
7f6688
 - remove some redundant rpc library code.
7f6688
+- add port parameter to rpc_ping().
7f6688
 
7f6688
 25/07/2012 autofs-5.0.7
7f6688
 =======================
7f6688
--- autofs-5.0.7.orig/include/rpc_subs.h
7f6688
+++ autofs-5.0.7/include/rpc_subs.h
7f6688
@@ -69,7 +69,7 @@ void rpc_destroy_tcp_client(struct conn_
7f6688
 int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, int, unsigned int);
7f6688
 int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *);
7f6688
 int rpc_ping_proto(struct conn_info *);
7f6688
-int rpc_ping(const char *, long, long, unsigned int);
7f6688
+int rpc_ping(const char *, int, long, long, unsigned int);
7f6688
 double elapsed(struct timeval, struct timeval);
7f6688
 const char *get_addr_string(struct sockaddr *, char *, socklen_t);
7f6688
 
7f6688
--- autofs-5.0.7.orig/lib/rpc_subs.c
7f6688
+++ autofs-5.0.7/lib/rpc_subs.c
7f6688
@@ -1010,12 +1010,11 @@ int rpc_ping_proto(struct conn_info *inf
7f6688
 }
7f6688
 
7f6688
 static int __rpc_ping(const char *host,
7f6688
-		      unsigned long version, int proto,
7f6688
+		      unsigned long version, int proto, int port,
7f6688
 		      long seconds, long micros, unsigned int option)
7f6688
 {
7f6688
 	int status;
7f6688
 	struct conn_info info;
7f6688
-	struct pmap parms;
7f6688
 
7f6688
 	info.proto = proto;
7f6688
 	info.host = host;
7f6688
@@ -1032,32 +1031,41 @@ static int __rpc_ping(const char *host,
7f6688
 
7f6688
 	status = RPC_PING_FAIL;
7f6688
 
7f6688
-	parms.pm_prog = NFS_PROGRAM;
7f6688
-	parms.pm_vers = version;
7f6688
-	parms.pm_prot = info.proto;
7f6688
-	parms.pm_port = 0;
7f6688
-
7f6688
-	status = rpc_portmap_getport(&info, &parms, &info.port);
7f6688
-	if (status < 0)
7f6688
-		return status;
7f6688
+
7f6688
+	if (port > 0)
7f6688
+		info.port = port;
7f6688
+	else {
7f6688
+		struct pmap parms;
7f6688
+
7f6688
+		parms.pm_prog = NFS_PROGRAM;
7f6688
+		parms.pm_vers = version;
7f6688
+		parms.pm_prot = info.proto;
7f6688
+		parms.pm_port = 0;
7f6688
+		status = rpc_portmap_getport(&info, &parms, &info.port);
7f6688
+		if (status < 0)
7f6688
+			return status;
7f6688
+	}
7f6688
 
7f6688
 	status = rpc_ping_proto(&info;;
7f6688
 
7f6688
 	return status;
7f6688
 }
7f6688
 
7f6688
-int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
7f6688
+int rpc_ping(const char *host, int port,
7f6688
+	     long seconds, long micros, unsigned int option)
7f6688
 {
7f6688
 	unsigned long vers4 = NFS4_VERSION;
7f6688
 	unsigned long vers3 = NFS3_VERSION;
7f6688
 	unsigned long vers2 = NFS2_VERSION;
7f6688
 	int status;
7f6688
 
7f6688
-	status = __rpc_ping(host, vers2, IPPROTO_UDP, seconds, micros, option);
7f6688
+	status = __rpc_ping(host, vers2,
7f6688
+			    IPPROTO_UDP, port, seconds, micros, option);
7f6688
 	if (status > 0)
7f6688
 		return RPC_PING_V2 | RPC_PING_UDP;
7f6688
 
7f6688
-	status = __rpc_ping(host, vers3, IPPROTO_UDP, seconds, micros, option);
7f6688
+	status = __rpc_ping(host, vers3,
7f6688
+			    IPPROTO_UDP, port, seconds, micros, option);
7f6688
 	if (status > 0)
7f6688
 		return RPC_PING_V3 | RPC_PING_UDP;
7f6688
 
7f6688
@@ -1067,15 +1075,18 @@ int rpc_ping(const char *host, long seco
7f6688
 		return RPC_PING_V4 | RPC_PING_UDP;
7f6688
 	*/
7f6688
 
7f6688
-	status = __rpc_ping(host, vers2, IPPROTO_TCP, seconds, micros, option);
7f6688
+	status = __rpc_ping(host, vers2,
7f6688
+			    IPPROTO_TCP, port, seconds, micros, option);
7f6688
 	if (status > 0)
7f6688
 		return RPC_PING_V2 | RPC_PING_TCP;
7f6688
 
7f6688
-	status = __rpc_ping(host, vers3, IPPROTO_TCP, seconds, micros, option);
7f6688
+	status = __rpc_ping(host, vers3, port,
7f6688
+			    IPPROTO_TCP, seconds, micros, option);
7f6688
 	if (status > 0)
7f6688
 		return RPC_PING_V3 | RPC_PING_TCP;
7f6688
 
7f6688
-	status = __rpc_ping(host, vers4, IPPROTO_TCP, seconds, micros, option);
7f6688
+	status = __rpc_ping(host, vers4,
7f6688
+			    IPPROTO_TCP, port, seconds, micros, option);
7f6688
 	if (status > 0)
7f6688
 		return RPC_PING_V4 | RPC_PING_TCP;
7f6688
 
7f6688
--- autofs-5.0.7.orig/modules/mount_nfs.c
7f6688
+++ autofs-5.0.7/modules/mount_nfs.c
7f6688
@@ -358,7 +358,7 @@ dont_probe:
7f6688
 			char *host = this->name ? this->name : "localhost";
7f6688
 			int ret;
7f6688
 
7f6688
-			ret = rpc_ping(host, 2, 0, RPC_CLOSE_DEFAULT);
7f6688
+			ret = rpc_ping(host, port, 2, 0, RPC_CLOSE_DEFAULT);
7f6688
 			if (ret <= 0)
7f6688
 				goto next;
7f6688
 		}