Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 May 2009 15:41:22 +0000 (UTC)
From:      Doug Rabson <dfr@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191937 - head/sys/nlm
Message-ID:  <200905091541.n49FfMn5027553@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dfr
Date: Sat May  9 15:41:22 2009
New Revision: 191937
URL: http://svn.freebsd.org/changeset/base/191937

Log:
  Work around non-standard behaviour of rpcbind in some versions of Linux (FC4?).
  
  Submitted by:	zachary dot loafman at isilon dot com

Modified:
  head/sys/nlm/nlm_prot_impl.c

Modified: head/sys/nlm/nlm_prot_impl.c
==============================================================================
--- head/sys/nlm/nlm_prot_impl.c	Sat May  9 15:09:40 2009	(r191936)
+++ head/sys/nlm/nlm_prot_impl.c	Sat May  9 15:41:22 2009	(r191937)
@@ -312,6 +312,7 @@ nlm_get_rpc(struct sockaddr *sa, rpcprog
 	enum clnt_stat stat = RPC_SUCCESS;
 	int rpcvers = RPCBVERS4;
 	bool_t do_tcp = FALSE;
+	bool_t tryagain = FALSE;
 	struct portmap mapping;
 	u_short port = 0;
 
@@ -373,14 +374,7 @@ again:
 		stat = CLNT_CALL(rpcb, (rpcprog_t) RPCBPROC_GETADDR,
 		    (xdrproc_t) xdr_rpcb, &parms,
 		    (xdrproc_t) xdr_wrapstring, &uaddr, timo);
-		if (stat == RPC_PROGVERSMISMATCH) {
-			if (rpcvers == RPCBVERS4)
-				rpcvers = RPCBVERS;
-			else if (rpcvers == RPCBVERS)
-				rpcvers = PMAPVERS;
-			CLNT_CONTROL(rpcb, CLSET_VERS, &rpcvers);
-			goto again;
-		} else if (stat == RPC_SUCCESS) {
+		if (stat == RPC_SUCCESS) {
 			/*
 			 * We have a reply from the remote RPCBIND - turn it
 			 * into an appropriate address and make a new client
@@ -391,13 +385,22 @@ again:
 			struct netbuf *a;
 			a = __rpc_uaddr2taddr_af(ss.ss_family, uaddr);
 			if (!a) {
-				CLNT_DESTROY(rpcb);
-				return (NULL);
+				tryagain = TRUE;
+			} else {
+				tryagain = FALSE;
+				memcpy(&ss, a->buf, a->len);
+				free(a->buf, M_RPC);
+				free(a, M_RPC);
+				xdr_free((xdrproc_t) xdr_wrapstring, &uaddr);
 			}
-			memcpy(&ss, a->buf, a->len);
-			free(a->buf, M_RPC);
-			free(a, M_RPC);
-			xdr_free((xdrproc_t) xdr_wrapstring, &uaddr);
+		}
+		if (tryagain || stat == RPC_PROGVERSMISMATCH) {
+			if (rpcvers == RPCBVERS4)
+				rpcvers = RPCBVERS;
+			else if (rpcvers == RPCBVERS)
+				rpcvers = PMAPVERS;
+			CLNT_CONTROL(rpcb, CLSET_VERS, &rpcvers);
+			goto again;
 		}
 		break;
 	case PMAPVERS:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905091541.n49FfMn5027553>