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

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