From 999b7dd24f40690d7cf728324dcf111b597ccb65 Mon Sep 17 00:00:00 2001 From: dfr Date: Sat, 9 May 2009 15:41:22 +0000 Subject: Work around non-standard behaviour of rpcbind in some versions of Linux (FC4?). Submitted by: zachary dot loafman at isilon dot com --- sys/nlm/nlm_prot_impl.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'sys/nlm') diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c index d9472a4..1ddaf3e 100644 --- a/sys/nlm/nlm_prot_impl.c +++ b/sys/nlm/nlm_prot_impl.c @@ -312,6 +312,7 @@ nlm_get_rpc(struct sockaddr *sa, rpcprog_t prog, rpcvers_t vers) 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: -- cgit v1.1