|
|
306fa1 |
autofs-5.1.3 - add version parameter to rpc_ping()
|
|
|
306fa1 |
|
|
|
306fa1 |
From: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
|
|
|
306fa1 |
Add an version parameter to rpc_ping() to try and avoid NFS pings
|
|
|
306fa1 |
to protocol or NFS version that isn't to be used.
|
|
|
306fa1 |
|
|
|
306fa1 |
When the port option is specified (possibly for NFS tunneling) it's
|
|
|
306fa1 |
likely that the protocol is also specified which will reduce uneeded
|
|
|
306fa1 |
NFS ping requests. But for this to work best (with the minimum delay)
|
|
|
306fa1 |
the NFS version needs to also be specified in the NFS mount options.
|
|
|
306fa1 |
|
|
|
306fa1 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
---
|
|
|
306fa1 |
CHANGELOG | 1
|
|
|
306fa1 |
include/rpc_subs.h | 2 -
|
|
|
306fa1 |
lib/rpc_subs.c | 74 +++++++++++++++++++++++++++-------------------------
|
|
|
306fa1 |
modules/mount_nfs.c | 2 -
|
|
|
306fa1 |
4 files changed, 42 insertions(+), 37 deletions(-)
|
|
|
306fa1 |
|
|
|
306fa1 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
306fa1 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
306fa1 |
@@ -306,6 +306,7 @@
|
|
|
306fa1 |
- remove some redundant rpc library code.
|
|
|
306fa1 |
- add port parameter to rpc_ping().
|
|
|
306fa1 |
- dont probe NFSv2 by default.
|
|
|
306fa1 |
+- add version parameter to rpc_ping().
|
|
|
306fa1 |
|
|
|
306fa1 |
25/07/2012 autofs-5.0.7
|
|
|
306fa1 |
=======================
|
|
|
306fa1 |
--- autofs-5.0.7.orig/include/rpc_subs.h
|
|
|
306fa1 |
+++ autofs-5.0.7/include/rpc_subs.h
|
|
|
306fa1 |
@@ -69,7 +69,7 @@ void rpc_destroy_tcp_client(struct conn_
|
|
|
306fa1 |
int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, int, unsigned int);
|
|
|
306fa1 |
int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *);
|
|
|
306fa1 |
int rpc_ping_proto(struct conn_info *);
|
|
|
306fa1 |
-int rpc_ping(const char *, int, long, long, unsigned int);
|
|
|
306fa1 |
+int rpc_ping(const char *, int, unsigned int, long, long, unsigned int);
|
|
|
306fa1 |
double elapsed(struct timeval, struct timeval);
|
|
|
306fa1 |
const char *get_addr_string(struct sockaddr *, char *, socklen_t);
|
|
|
306fa1 |
|
|
|
306fa1 |
--- autofs-5.0.7.orig/lib/rpc_subs.c
|
|
|
306fa1 |
+++ autofs-5.0.7/lib/rpc_subs.c
|
|
|
306fa1 |
@@ -53,6 +53,7 @@ const rpcvers_t rpcb_version = PMAPVERS;
|
|
|
306fa1 |
|
|
|
306fa1 |
#include "mount.h"
|
|
|
306fa1 |
#include "rpc_subs.h"
|
|
|
306fa1 |
+#include "replicated.h"
|
|
|
306fa1 |
#include "automount.h"
|
|
|
306fa1 |
|
|
|
306fa1 |
/* #define STANDALONE */
|
|
|
306fa1 |
@@ -1052,43 +1053,46 @@ static int __rpc_ping(const char *host,
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
int rpc_ping(const char *host, int port,
|
|
|
306fa1 |
- long seconds, long micros, unsigned int option)
|
|
|
306fa1 |
+ unsigned int version, long seconds, long micros,
|
|
|
306fa1 |
+ unsigned int option)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- unsigned long vers4 = NFS4_VERSION;
|
|
|
306fa1 |
- unsigned long vers3 = NFS3_VERSION;
|
|
|
306fa1 |
- unsigned long vers2 = NFS2_VERSION;
|
|
|
306fa1 |
- int status;
|
|
|
306fa1 |
+ int status = 0;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if ((version & NFS2_REQUESTED) && (version & TCP_REQUESTED)) {
|
|
|
306fa1 |
+ status = __rpc_ping(host, NFS2_VERSION,
|
|
|
306fa1 |
+ IPPROTO_TCP, port, seconds, micros, option);
|
|
|
306fa1 |
+ if (status > 0)
|
|
|
306fa1 |
+ return RPC_PING_V2 | RPC_PING_TCP;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if ((version & NFS2_REQUESTED) && (version & UDP_REQUESTED)) {
|
|
|
306fa1 |
+ status = __rpc_ping(host, NFS2_VERSION,
|
|
|
306fa1 |
+ IPPROTO_UDP, port, seconds, micros, option);
|
|
|
306fa1 |
+ if (status > 0)
|
|
|
306fa1 |
+ return RPC_PING_V2 | RPC_PING_UDP;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
|
|
|
306fa1 |
- status = __rpc_ping(host, vers2,
|
|
|
306fa1 |
- IPPROTO_UDP, port, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V2 | RPC_PING_UDP;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = __rpc_ping(host, vers3,
|
|
|
306fa1 |
- IPPROTO_UDP, port, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V3 | RPC_PING_UDP;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- /* UDP isn't recommended for NFSv4, don't bother checking it.
|
|
|
306fa1 |
- status = __rpc_ping(host, vers4, IPPROTO_UDP, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V4 | RPC_PING_UDP;
|
|
|
306fa1 |
- */
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = __rpc_ping(host, vers2,
|
|
|
306fa1 |
- IPPROTO_TCP, port, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V2 | RPC_PING_TCP;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = __rpc_ping(host, vers3, port,
|
|
|
306fa1 |
- IPPROTO_TCP, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V3 | RPC_PING_TCP;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- status = __rpc_ping(host, vers4,
|
|
|
306fa1 |
- IPPROTO_TCP, port, seconds, micros, option);
|
|
|
306fa1 |
- if (status > 0)
|
|
|
306fa1 |
- return RPC_PING_V4 | RPC_PING_TCP;
|
|
|
306fa1 |
+ if ((version & NFS3_REQUESTED) && (version & TCP_REQUESTED)) {
|
|
|
306fa1 |
+ status = __rpc_ping(host, NFS3_VERSION,
|
|
|
306fa1 |
+ IPPROTO_TCP, port, seconds, micros, option);
|
|
|
306fa1 |
+ if (status > 0)
|
|
|
306fa1 |
+ return RPC_PING_V3 | RPC_PING_TCP;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if ((version & NFS3_REQUESTED) && (version & UDP_REQUESTED)) {
|
|
|
306fa1 |
+ status = __rpc_ping(host, NFS3_VERSION,
|
|
|
306fa1 |
+ IPPROTO_UDP, port, seconds, micros, option);
|
|
|
306fa1 |
+ if (status > 0)
|
|
|
306fa1 |
+ return RPC_PING_V3 | RPC_PING_UDP;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if (version & NFS4_REQUESTED) {
|
|
|
306fa1 |
+ /* UDP isn't recommended for NFSv4, don't check it. */
|
|
|
306fa1 |
+ status = __rpc_ping(host, NFS4_VERSION,
|
|
|
306fa1 |
+ IPPROTO_TCP, port, seconds, micros, option);
|
|
|
306fa1 |
+ if (status > 0)
|
|
|
306fa1 |
+ return RPC_PING_V4 | RPC_PING_TCP;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
|
|
|
306fa1 |
return status;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
--- autofs-5.0.7.orig/modules/mount_nfs.c
|
|
|
306fa1 |
+++ autofs-5.0.7/modules/mount_nfs.c
|
|
|
306fa1 |
@@ -358,7 +358,7 @@ dont_probe:
|
|
|
306fa1 |
char *host = this->name ? this->name : "localhost";
|
|
|
306fa1 |
int ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
- ret = rpc_ping(host, port, 2, 0, RPC_CLOSE_DEFAULT);
|
|
|
306fa1 |
+ ret = rpc_ping(host, port, vers, 2, 0, RPC_CLOSE_DEFAULT);
|
|
|
306fa1 |
if (ret <= 0)
|
|
|
306fa1 |
goto next;
|
|
|
306fa1 |
}
|