Blame SOURCES/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch

4d476f
autofs-5.0.7 - use numeric protocol ids instead of protoent structs
4d476f
4d476f
From: Leonardo Chiquitto <leonardo.lists@gmail.com>
4d476f
4d476f
The function getprotobyname() is not reentrant, so we can't call
4d476f
it simultaneously from multiple threads. Instead of switching to
4d476f
the reentrant version which adds more complexity to the code,
4d476f
lets use numeric protocol IDs instead of protoent structures.
4d476f
---
4d476f
4d476f
 CHANGELOG            |    1 +
4d476f
 include/rpc_subs.h   |    4 +--
4d476f
 lib/rpc_subs.c       |   80 ++++++++++++++++++--------------------------------
4d476f
 modules/replicated.c |   42 +++++++++++---------------
4d476f
 4 files changed, 50 insertions(+), 77 deletions(-)
4d476f
4d476f
4d476f
diff --git a/CHANGELOG b/CHANGELOG
4d476f
index 4cf5621..ba1d65b 100644
4d476f
--- a/CHANGELOG
4d476f
+++ b/CHANGELOG
4d476f
@@ -23,6 +23,7 @@
4d476f
 - fix use get_proximity() without libtirpc.
4d476f
 - don't use dirent d_type to filter out files in scandir()
4d476f
 - don't schedule new alarms after readmap.
4d476f
+- use numeric protocol ids instead of protoent structs.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
diff --git a/include/rpc_subs.h b/include/rpc_subs.h
4d476f
index ca474d9..b6d59f9 100644
4d476f
--- a/include/rpc_subs.h
4d476f
+++ b/include/rpc_subs.h
4d476f
@@ -54,7 +54,7 @@ struct conn_info {
4d476f
 	unsigned short port;
4d476f
 	unsigned long program;
4d476f
 	unsigned long version;
4d476f
-	struct protoent *proto;
4d476f
+	int proto;
4d476f
 	unsigned int send_sz;
4d476f
 	unsigned int recv_sz;
4d476f
 	struct timeval timeout;
4d476f
@@ -66,7 +66,7 @@ int rpc_udp_getclient(struct conn_info *, unsigned int, unsigned int);
4d476f
 void rpc_destroy_udp_client(struct conn_info *);
4d476f
 int rpc_tcp_getclient(struct conn_info *, unsigned int, unsigned int);
4d476f
 void rpc_destroy_tcp_client(struct conn_info *);
4d476f
-int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, const char *, unsigned int);
4d476f
+int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, int, unsigned int);
4d476f
 int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *);
4d476f
 int rpc_ping_proto(struct conn_info *);
4d476f
 int rpc_ping(const char *, long, long, unsigned int);
4d476f
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
4d476f
index d33a3c4..ad1d557 100644
4d476f
--- a/lib/rpc_subs.c
4d476f
+++ b/lib/rpc_subs.c
4d476f
@@ -170,7 +170,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
4d476f
 
4d476f
 	*client = NULL;
4d476f
 
4d476f
-	proto = info->proto->p_proto;
4d476f
+	proto = info->proto;
4d476f
 	if (proto == IPPROTO_UDP)
4d476f
 		type = SOCK_DGRAM;
4d476f
 	else
4d476f
@@ -201,7 +201,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
4d476f
 	in4_raddr = (struct sockaddr_in *) addr;
4d476f
 	in4_raddr->sin_port = htons(info->port);
4d476f
 
4d476f
-	switch (info->proto->p_proto) {
4d476f
+	switch (info->proto) {
4d476f
 	case IPPROTO_UDP:
4d476f
 		clnt = clntudp_bufcreate(in4_raddr,
4d476f
 					 info->program, info->version,
4d476f
@@ -241,7 +241,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
4d476f
 
4d476f
 	*client = NULL;
4d476f
 
4d476f
-	proto = info->proto->p_proto;
4d476f
+	proto = info->proto;
4d476f
 	if (proto == IPPROTO_UDP)
4d476f
 		type = SOCK_DGRAM;
4d476f
 	else
4d476f
@@ -292,11 +292,11 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
4d476f
 	nb_addr.maxlen = nb_addr.len = slen;
4d476f
 	nb_addr.buf = addr;
4d476f
 
4d476f
-	if (info->proto->p_proto == IPPROTO_UDP)
4d476f
+	if (info->proto == IPPROTO_UDP)
4d476f
 		clnt = clnt_dg_create(*fd, &nb_addr,
4d476f
 				      info->program, info->version,
4d476f
 				      info->send_sz, info->recv_sz);
4d476f
-	else if (info->proto->p_proto == IPPROTO_TCP) {
4d476f
+	else if (info->proto == IPPROTO_TCP) {
4d476f
 		ret = connect_nb(*fd, addr, slen, &info->timeout);
4d476f
 		if (ret < 0)
4d476f
 			return ret;
4d476f
@@ -355,7 +355,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
4d476f
 	memset(&hints, 0, sizeof(hints));
4d476f
 	hints.ai_flags = AI_ADDRCONFIG;
4d476f
 	hints.ai_family = AF_UNSPEC;
4d476f
-	if (info->proto->p_proto == IPPROTO_UDP)
4d476f
+	if (info->proto == IPPROTO_UDP)
4d476f
 		hints.ai_socktype = SOCK_DGRAM;
4d476f
 	else
4d476f
 		hints.ai_socktype = SOCK_STREAM;
4d476f
@@ -370,7 +370,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
4d476f
 
4d476f
 	haddr = ai;
4d476f
 	while (haddr) {
4d476f
-		if (haddr->ai_protocol != info->proto->p_proto) {
4d476f
+		if (haddr->ai_protocol != info->proto) {
4d476f
 			haddr = haddr->ai_next;
4d476f
 			continue;
4d476f
 		}
4d476f
@@ -417,16 +417,11 @@ out_close:
4d476f
 int rpc_udp_getclient(struct conn_info *info,
4d476f
 		      unsigned int program, unsigned int version)
4d476f
 {
4d476f
-	struct protoent *pe_proto;
4d476f
 	CLIENT *client;
4d476f
 	int ret;
4d476f
 
4d476f
 	if (!info->client) {
4d476f
-		pe_proto = getprotobyname("udp");
4d476f
-		if (!pe_proto)
4d476f
-			return -ENOENT;
4d476f
-
4d476f
-		info->proto = pe_proto;
4d476f
+		info->proto = IPPROTO_UDP;
4d476f
 		info->timeout.tv_sec = RPC_TOUT_UDP;
4d476f
 		info->timeout.tv_usec = 0;
4d476f
 		info->send_sz = UDPMSGSIZE;
4d476f
@@ -458,16 +453,11 @@ void rpc_destroy_udp_client(struct conn_info *info)
4d476f
 int rpc_tcp_getclient(struct conn_info *info,
4d476f
 		      unsigned int program, unsigned int version)
4d476f
 {
4d476f
-	struct protoent *pe_proto;
4d476f
 	CLIENT *client;
4d476f
 	int ret;
4d476f
 
4d476f
 	if (!info->client) {
4d476f
-		pe_proto = getprotobyname("tcp");
4d476f
-		if (!pe_proto)
4d476f
-			return -ENOENT;
4d476f
-
4d476f
-		info->proto = pe_proto;
4d476f
+		info->proto = IPPROTO_TCP;
4d476f
 		info->timeout.tv_sec = RPC_TOUT_TCP;
4d476f
 		info->timeout.tv_usec = 0;
4d476f
 		info->send_sz = 0;
4d476f
@@ -513,23 +503,18 @@ void rpc_destroy_tcp_client(struct conn_info *info)
4d476f
 
4d476f
 int rpc_portmap_getclient(struct conn_info *info,
4d476f
 			  const char *host, struct sockaddr *addr, size_t addr_len,
4d476f
-			  const char *proto, unsigned int option)
4d476f
+			  int proto, unsigned int option)
4d476f
 {
4d476f
-	struct protoent *pe_proto;
4d476f
 	CLIENT *client;
4d476f
 	int ret;
4d476f
 
4d476f
-	pe_proto = getprotobyname(proto);
4d476f
-	if (!pe_proto)
4d476f
-		return -ENOENT;
4d476f
-
4d476f
 	info->host = host;
4d476f
 	info->addr = addr;
4d476f
 	info->addr_len = addr_len;
4d476f
 	info->program = PMAPPROG;
4d476f
 	info->port = PMAPPORT;
4d476f
 	info->version = PMAPVERS;
4d476f
-	info->proto = pe_proto;
4d476f
+	info->proto = proto;
4d476f
 	info->send_sz = RPCSMALLMSGSIZE;
4d476f
 	info->recv_sz = RPCSMALLMSGSIZE;
4d476f
 	info->timeout.tv_sec = PMAP_TOUT_UDP;
4d476f
@@ -537,7 +522,7 @@ int rpc_portmap_getclient(struct conn_info *info,
4d476f
 	info->close_option = option;
4d476f
 	info->client = NULL;
4d476f
 
4d476f
-	if (pe_proto->p_proto == IPPROTO_TCP)
4d476f
+	if (info->proto == IPPROTO_TCP)
4d476f
 		info->timeout.tv_sec = PMAP_TOUT_TCP;
4d476f
 
4d476f
 	ret = create_client(info, &client);
4d476f
@@ -555,7 +540,7 @@ int rpc_portmap_getport(struct conn_info *info,
4d476f
 	struct conn_info pmap_info;
4d476f
 	CLIENT *client;
4d476f
 	enum clnt_stat status;
4d476f
-	int proto = info->proto->p_proto;
4d476f
+	int proto = info->proto;
4d476f
 	int ret;
4d476f
 
4d476f
 	memset(&pmap_info, 0, sizeof(struct conn_info));
4d476f
@@ -633,13 +618,13 @@ int rpc_ping_proto(struct conn_info *info)
4d476f
 {
4d476f
 	CLIENT *client;
4d476f
 	enum clnt_stat status;
4d476f
-	int proto = info->proto->p_proto;
4d476f
+	int proto = info->proto;
4d476f
 	int ret;
4d476f
 
4d476f
 	if (info->client)
4d476f
 		client = info->client;
4d476f
 	else {
4d476f
-		if (info->proto->p_proto == IPPROTO_UDP) {
4d476f
+		if (info->proto == IPPROTO_UDP) {
4d476f
 			info->send_sz = UDPMSGSIZE;
4d476f
 			info->recv_sz = UDPMSGSIZE;
4d476f
 		}
4d476f
@@ -688,7 +673,7 @@ int rpc_ping_proto(struct conn_info *info)
4d476f
 
4d476f
 static unsigned int __rpc_ping(const char *host,
4d476f
 				unsigned long version,
4d476f
-				char *proto,
4d476f
+				int proto,
4d476f
 				long seconds, long micros,
4d476f
 				unsigned int option)
4d476f
 {
4d476f
@@ -696,6 +681,7 @@ static unsigned int __rpc_ping(const char *host,
4d476f
 	struct conn_info info;
4d476f
 	struct pmap parms;
4d476f
 
4d476f
+	info.proto = proto;
4d476f
 	info.host = host;
4d476f
 	info.addr = NULL;
4d476f
 	info.addr_len = 0;
4d476f
@@ -710,13 +696,9 @@ static unsigned int __rpc_ping(const char *host,
4d476f
 
4d476f
 	status = RPC_PING_FAIL;
4d476f
 
4d476f
-	info.proto = getprotobyname(proto);
4d476f
-	if (!info.proto)
4d476f
-		return status;
4d476f
-
4d476f
 	parms.pm_prog = NFS_PROGRAM;
4d476f
 	parms.pm_vers = version;
4d476f
-	parms.pm_prot = info.proto->p_proto;
4d476f
+	parms.pm_prot = info.proto;
4d476f
 	parms.pm_port = 0;
4d476f
 
4d476f
 	status = rpc_portmap_getport(&info, &parms, &info.port);
4d476f
@@ -734,19 +716,19 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
4d476f
 	unsigned long vers2 = NFS2_VERSION;
4d476f
 	unsigned int status;
4d476f
 
4d476f
-	status = __rpc_ping(host, vers2, "udp", seconds, micros, option);
4d476f
+	status = __rpc_ping(host, vers2, IPPROTO_UDP, seconds, micros, option);
4d476f
 	if (status > 0)
4d476f
 		return RPC_PING_V2 | RPC_PING_UDP;
4d476f
 
4d476f
-	status = __rpc_ping(host, vers3, "udp", seconds, micros, option);
4d476f
+	status = __rpc_ping(host, vers3, IPPROTO_UDP, seconds, micros, option);
4d476f
 	if (status > 0)
4d476f
 		return RPC_PING_V3 | RPC_PING_UDP;
4d476f
 
4d476f
-	status = __rpc_ping(host, vers2, "tcp", seconds, micros, option);
4d476f
+	status = __rpc_ping(host, vers2, IPPROTO_TCP, seconds, micros, option);
4d476f
 	if (status > 0)
4d476f
 		return RPC_PING_V2 | RPC_PING_TCP;
4d476f
 
4d476f
-	status = __rpc_ping(host, vers3, "tcp", seconds, micros, option);
4d476f
+	status = __rpc_ping(host, vers3, IPPROTO_TCP, seconds, micros, option);
4d476f
 	if (status > 0)
4d476f
 		return RPC_PING_V3 | RPC_PING_TCP;
4d476f
 
4d476f
@@ -769,7 +751,7 @@ int rpc_time(const char *host,
4d476f
 	double taken;
4d476f
 	struct timeval start, end;
4d476f
 	struct timezone tz;
4d476f
-	char *proto = (ping_proto & RPC_PING_UDP) ? "udp" : "tcp";
4d476f
+	int proto = (ping_proto & RPC_PING_UDP) ? IPPROTO_UDP : IPPROTO_TCP;
4d476f
 	unsigned long vers = ping_vers;
4d476f
 
4d476f
 	gettimeofday(&start, &tz;;
4d476f
@@ -791,12 +773,12 @@ static int rpc_get_exports_proto(struct conn_info *info, exports *exp)
4d476f
 {
4d476f
 	CLIENT *client;
4d476f
 	enum clnt_stat status;
4d476f
-	int proto = info->proto->p_proto;
4d476f
+	int proto = info->proto;
4d476f
 	unsigned int option = info->close_option;
4d476f
 	int vers_entry;
4d476f
 	int ret;
4d476f
 
4d476f
-	if (info->proto->p_proto == IPPROTO_UDP) {
4d476f
+	if (info->proto == IPPROTO_UDP) {
4d476f
 		info->send_sz = UDPMSGSIZE;
4d476f
 		info->recv_sz = UDPMSGSIZE;
4d476f
 	}
4d476f
@@ -903,11 +885,9 @@ exports rpc_get_exports(const char *host, long seconds, long micros, unsigned in
4d476f
 	parms.pm_port = 0;
4d476f
 
4d476f
 	/* Try UDP first */
4d476f
-	info.proto = getprotobyname("udp");
4d476f
-	if (!info.proto)
4d476f
-		goto try_tcp;
4d476f
+	info.proto = IPPROTO_UDP;
4d476f
 
4d476f
-	parms.pm_prot = info.proto->p_proto;
4d476f
+	parms.pm_prot = info.proto;
4d476f
 
4d476f
 	status = rpc_portmap_getport(&info, &parms, &info.port);
4d476f
 	if (status < 0)
4d476f
@@ -920,11 +900,9 @@ exports rpc_get_exports(const char *host, long seconds, long micros, unsigned in
4d476f
 		return exportlist;
4d476f
 
4d476f
 try_tcp:
4d476f
-	info.proto = getprotobyname("tcp");
4d476f
-	if (!info.proto)
4d476f
-		return NULL;
4d476f
+	info.proto = IPPROTO_TCP;
4d476f
 
4d476f
-	parms.pm_prot = info.proto->p_proto;
4d476f
+	parms.pm_prot = info.proto;
4d476f
 
4d476f
 	status = rpc_portmap_getport(&info, &parms, &info.port);
4d476f
 	if (status < 0)
4d476f
diff --git a/modules/replicated.c b/modules/replicated.c
4d476f
index 6b96320..dbd5513 100644
4d476f
--- a/modules/replicated.c
4d476f
+++ b/modules/replicated.c
4d476f
@@ -419,7 +419,7 @@ void free_host_list(struct host **list)
4d476f
 
4d476f
 static unsigned int get_nfs_info(unsigned logopt, struct host *host,
4d476f
 			 struct conn_info *pm_info, struct conn_info *rpc_info,
4d476f
-			 const char *proto, unsigned int version, int port)
4d476f
+			 int proto, unsigned int version, int port)
4d476f
 {
4d476f
 	unsigned int random_selection = host->options & MOUNT_FLAG_RANDOM_SELECT;
4d476f
 	unsigned int use_weight_only = host->options & MOUNT_FLAG_USE_WEIGHT_ONLY;
4d476f
@@ -433,22 +433,18 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,
4d476f
 	int status, count = 0;
4d476f
 
4d476f
 	if (host->addr)
4d476f
-		debug(logopt, "called with host %s(%s) proto %s version 0x%x",
4d476f
+		debug(logopt, "called with host %s(%s) proto %d version 0x%x",
4d476f
 		      host->name, get_addr_string(host->addr, buf, len),
4d476f
 		      proto, version);
4d476f
 	else
4d476f
 		debug(logopt,
4d476f
-		      "called for host %s proto %s version 0x%x",
4d476f
+		      "called for host %s proto %d version 0x%x",
4d476f
 		      host->name, proto, version);
4d476f
 
4d476f
-	rpc_info->proto = getprotobyname(proto);
4d476f
-	if (!rpc_info->proto)
4d476f
-		return 0;
4d476f
-
4d476f
+	rpc_info->proto = proto;
4d476f
 	memset(&parms, 0, sizeof(struct pmap));
4d476f
-
4d476f
 	parms.pm_prog = NFS_PROGRAM;
4d476f
-	parms.pm_prot = rpc_info->proto->p_proto;
4d476f
+	parms.pm_prot = proto;
4d476f
 
4d476f
 	if (!(version & NFS4_REQUESTED))
4d476f
 		goto v3_ver;
4d476f
@@ -479,7 +475,7 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,
4d476f
 		}
4d476f
 	}
4d476f
 
4d476f
-	if (rpc_info->proto->p_proto == IPPROTO_UDP)
4d476f
+	if (rpc_info->proto == IPPROTO_UDP)
4d476f
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
4d476f
 	else
4d476f
 		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
4d476f
@@ -540,7 +536,7 @@ v3_ver:
4d476f
 			goto v2_ver;
4d476f
 	}
4d476f
 
4d476f
-	if (rpc_info->proto->p_proto == IPPROTO_UDP)
4d476f
+	if (rpc_info->proto == IPPROTO_UDP)
4d476f
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
4d476f
 	else
4d476f
 		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
4d476f
@@ -587,7 +583,7 @@ v2_ver:
4d476f
 			goto done_ver;
4d476f
 	}
4d476f
 
4d476f
-	if (rpc_info->proto->p_proto == IPPROTO_UDP)
4d476f
+	if (rpc_info->proto == IPPROTO_UDP)
4d476f
 		status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
4d476f
 	else
4d476f
 		status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
4d476f
@@ -618,7 +614,7 @@ v2_ver:
4d476f
 	}
4d476f
 
4d476f
 done_ver:
4d476f
-	if (rpc_info->proto->p_proto == IPPROTO_UDP) {
4d476f
+	if (rpc_info->proto == IPPROTO_UDP) {
4d476f
 		rpc_destroy_udp_client(rpc_info);
4d476f
 		rpc_destroy_udp_client(pm_info);
4d476f
 	} else {
4d476f
@@ -675,7 +671,7 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
4d476f
 
4d476f
 	if (version & TCP_REQUESTED) {
4d476f
 		supported = get_nfs_info(logopt, host,
4d476f
-				   &pm_info, &rpc_info, "tcp", vers, port);
4d476f
+				   &pm_info, &rpc_info, IPPROTO_TCP, vers, port);
4d476f
 		if (IS_ERR(supported)) {
4d476f
 			if (ERR(supported) == EHOSTUNREACH ||
4d476f
 			    ERR(supported) == ETIMEDOUT)
4d476f
@@ -688,7 +684,7 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
4d476f
 
4d476f
 	if (version & UDP_REQUESTED) {
4d476f
 		supported = get_nfs_info(logopt, host,
4d476f
-				   &pm_info, &rpc_info, "udp", vers, port);
4d476f
+				   &pm_info, &rpc_info, IPPROTO_UDP, vers, port);
4d476f
 		if (IS_ERR(supported)) {
4d476f
 			if (!ret && ERR(supported) == ETIMEDOUT)
4d476f
 				return ret;
4d476f
@@ -709,7 +705,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
4d476f
 	socklen_t len = INET6_ADDRSTRLEN;
4d476f
 	char buf[len + 1];
4d476f
 	struct conn_info pm_info, rpc_info;
4d476f
-	const char *proto;
4d476f
+	int proto;
4d476f
 	unsigned int vers;
4d476f
 	struct timeval start, end;
4d476f
 	struct timezone tz;
4d476f
@@ -748,10 +744,10 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
4d476f
 	 *  So, we do the conversion here.
4d476f
 	 */
4d476f
 	if (version & UDP_SELECTED_MASK) {
4d476f
-		proto = "udp";
4d476f
+		proto = IPPROTO_UDP;
4d476f
 		version >>= 8;
4d476f
 	} else
4d476f
-		proto = "tcp";
4d476f
+		proto = IPPROTO_TCP;
4d476f
 
4d476f
 	switch (version) {
4d476f
 	case NFS2_SUPPORTED:
4d476f
@@ -768,9 +764,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
4d476f
 		return 0;
4d476f
 	}
4d476f
 
4d476f
-	rpc_info.proto = getprotobyname(proto);
4d476f
-	if (!rpc_info.proto)
4d476f
-		return 0;
4d476f
+	rpc_info.proto = proto;
4d476f
 
4d476f
 	if (port > 0)
4d476f
 		rpc_info.port = port;
4d476f
@@ -786,14 +780,14 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
4d476f
 
4d476f
 		memset(&parms, 0, sizeof(struct pmap));
4d476f
 		parms.pm_prog = NFS_PROGRAM;
4d476f
-		parms.pm_prot = rpc_info.proto->p_proto;
4d476f
+		parms.pm_prot = rpc_info.proto;
4d476f
 		parms.pm_vers = vers;
4d476f
 		ret = rpc_portmap_getport(&pm_info, &parms, &rpc_info.port);
4d476f
 		if (ret < 0)
4d476f
 			goto done;
4d476f
 	}
4d476f
 
4d476f
-	if (rpc_info.proto->p_proto == IPPROTO_UDP)
4d476f
+	if (rpc_info.proto == IPPROTO_UDP)
4d476f
 		status = rpc_udp_getclient(&rpc_info, NFS_PROGRAM, vers);
4d476f
 	else
4d476f
 		status = rpc_tcp_getclient(&rpc_info, NFS_PROGRAM, vers);
4d476f
@@ -815,7 +809,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
4d476f
 		}
4d476f
 	}
4d476f
 done:
4d476f
-	if (rpc_info.proto->p_proto == IPPROTO_UDP) {
4d476f
+	if (rpc_info.proto == IPPROTO_UDP) {
4d476f
 		rpc_destroy_udp_client(&rpc_info);
4d476f
 		rpc_destroy_udp_client(&pm_info);
4d476f
 	} else {