autofs-5.0.1 - include ip address in debug logging From: Ian Kent <raven@themaw.net> When probing availability of a host also log the network address along with the host name. --- include/rpc_subs.h | 1 + lib/rpc_subs.c | 10 ++++++++++ modules/replicated.c | 24 +++++++++++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) --- autofs-5.0.1.orig/include/rpc_subs.h +++ autofs-5.0.1/include/rpc_subs.h @@ -69,6 +69,7 @@ int rpc_ping_proto(struct conn_info *); int rpc_ping(const char *, long, long, unsigned int); double elapsed(struct timeval, struct timeval); int rpc_time(const char *, unsigned int, unsigned int, long, long, unsigned int, double *); +const char *get_addr_string(char *, char *, socklen_t); #endif --- autofs-5.0.1.orig/lib/rpc_subs.c +++ autofs-5.0.1/lib/rpc_subs.c @@ -861,6 +861,16 @@ try_tcp: return exportlist; } +const char *get_addr_string(char *address, char *name, socklen_t len) +{ + struct in_addr addr; + + memset(&addr, 0, sizeof(addr)); + memcpy(&addr.s_addr, address, sizeof(addr)); + + return inet_ntop(AF_INET, &addr, name, len); +} + #if 0 #include <stdio.h> --- autofs-5.0.1.orig/modules/replicated.c +++ autofs-5.0.1/modules/replicated.c @@ -444,6 +444,8 @@ static unsigned int get_nfs_info(unsigne char *have_port_opt = options ? strstr(options, "port=") : NULL; unsigned int random_selection = host->options & MOUNT_FLAG_RANDOM_SELECT; unsigned int use_weight_only = host->options & MOUNT_FLAG_USE_WEIGHT_ONLY; + socklen_t len = INET_ADDRSTRLEN; + char buf[len + 1]; struct pmap parms; struct timeval start, end; struct timezone tz; @@ -451,9 +453,14 @@ static unsigned int get_nfs_info(unsigne double taken = 0; int status, count = 0; - debug(logopt, - "called for host %s proto %s version 0x%x", - host->name, proto, version); + if (host->addr) + debug(logopt, "called with host %s(%s) proto %s version 0x%x", + host->name, get_addr_string(host->addr, buf, len), + proto, version); + else + debug(logopt, + "called for host %s proto %s version 0x%x", + host->name, proto, version); memset(&parms, 0, sizeof(struct pmap)); @@ -667,6 +674,8 @@ static int get_supported_ver_and_cost(un unsigned int random_selection = host->options & MOUNT_FLAG_RANDOM_SELECT; unsigned int use_weight_only = host->options & MOUNT_FLAG_USE_WEIGHT_ONLY; struct conn_info pm_info, rpc_info; + socklen_t len = INET_ADDRSTRLEN; + char buf[len + 1]; struct pmap parms; const char *proto; unsigned int vers; @@ -676,8 +685,13 @@ static int get_supported_ver_and_cost(un time_t timeout = RPC_TIMEOUT; int status; - debug(logopt, - "called with host %s version 0x%x", host->name, version); + if (host->addr) + debug(logopt, "called with host %s(%s) version 0x%x", + host->name, get_addr_string(host->addr, buf, len), + version); + else + debug(logopt, "called with host %s version 0x%x", + host->name, version); memset(&pm_info, 0, sizeof(struct conn_info)); memset(&rpc_info, 0, sizeof(struct conn_info));