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

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