From: Olaf Kirch <okir@suse.de>
To: linux-nfs@vger.kernel.org
Cc: nfsv4@linux-nfs.org, Steve Dickson <SteveD@redhat.com>
Subject: [PATCH 1/2] Introduce new helper function getpmaphandle
Date: Mon, 30 Aug 2010 15:04:20 +0200 [thread overview]
Message-ID: <201008301504.20634.okir@suse.de> (raw)
In-Reply-To: <201008301503.19783.okir@suse.de>
From: Olaf Kirch <okir@suse.de>
Date: Mon, 23 Aug 2010 12:58:41 +0200
Subject: [PATCH] Introduce new helper function getpmaphandle
This moves some code for creation of PMAP handles out of the getaddr
code and into a function of its own.
Signed-off-by: Olaf Kirch <okir@suse.de>
---
src/rpcb_clnt.c | 62 ++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 19 deletions(-)
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
index a800128..531c619 100644
--- a/src/rpcb_clnt.c
+++ b/src/rpcb_clnt.c
@@ -434,6 +434,44 @@ out_err:
return (client);
}
+/*
+ * Create a PMAP client handle.
+ */
+static CLIENT *
+getpmaphandle(nconf, hostname, tgtaddr)
+ const struct netconfig *nconf;
+ const char *hostname;
+ char **tgtaddr;
+{
+ CLIENT *client = NULL;
+ rpcvers_t pmapvers = 2;
+
+ /*
+ * Try UDP only - there are some portmappers out
+ * there that use UDP only.
+ */
+ if (nconf == NULL || strcmp(nconf->nc_proto, NC_TCP) == 0) {
+ struct netconfig *newnconf;
+
+ if ((newnconf = getnetconfigent("udp")) == NULL) {
+ rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
+ return NULL;
+ }
+ client = getclnthandle(hostname, newnconf, tgtaddr);
+ freenetconfigent(newnconf);
+ } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+ if (strcmp(nconf->nc_protofmly, NC_INET) != 0)
+ return NULL;
+ client = getclnthandle(hostname, nconf, tgtaddr);
+ }
+
+ /* Set version */
+ if (client != NULL)
+ CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
+
+ return client;
+}
+
/* XXX */
#define IN4_LOCALHOST_STRING "127.0.0.1"
#define IN6_LOCALHOST_STRING "::1"
@@ -770,34 +808,20 @@ __rpcb_findaddr_timed(program, version, nconf, host,
clpp, tp)
if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
u_short port = 0;
struct netbuf remote;
- rpcvers_t pmapvers = 2;
struct pmap pmapparms;
- /*
- * Try UDP only - there are some portmappers out
- * there that use UDP only.
- */
- if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
- struct netconfig *newnconf;
-
- if ((newnconf = getnetconfigent("udp")) == NULL) {
- rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
- return (NULL);
- }
- client = getclnthandle(host, newnconf, &parms.r_addr);
- freenetconfigent(newnconf);
- } else if (strcmp(nconf->nc_proto, NC_UDP) == 0)
- client = getclnthandle(host, nconf, &parms.r_addr);
- else
+ if (strcmp(nconf->nc_proto, NC_UDP) != 0
+ && strcmp(nconf->nc_proto, NC_TCP) != 0)
goto try_rpcbind;
+
+ client = getpmaphandle(nconf, IN4_LOCALHOST_STRING, &parms.r_addr);
if (client == NULL)
return (NULL);
/*
- * Set version and retry timeout.
+ * Set retry timeout.
*/
CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)&rpcbrmttime);
- CLNT_CONTROL(client, CLSET_VERS, (char *)&pmapvers);
pmapparms.pm_prog = program;
pmapparms.pm_vers = version;
--
1.6.0.2
--
Neo didn't bring down the Matrix. SOA did. (soafacts.com)
--------------------------------------------
Olaf Kirch - Director Server (okir@novell.com)
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
next prev parent reply other threads:[~2010-08-30 13:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-30 13:03 [PATCH 0/2] Make libtirpc work with old style portmapper Olaf Kirch
2010-08-30 13:04 ` Olaf Kirch [this message]
2010-08-30 13:04 ` [PATCH 2/2] Introduce new helper function getpmaphandle Olaf Kirch
2010-08-30 15:59 ` [PATCH 0/2] Make libtirpc work with old style portmapper Chuck Lever
2010-08-30 16:19 ` Olaf Kirch
2010-08-30 23:48 ` Chuck Lever
2010-09-07 11:27 ` Olaf Kirch
2010-09-07 15:36 ` Chuck Lever
2010-09-07 20:58 ` Olaf Kirch
2010-09-07 21:15 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201008301504.20634.okir@suse.de \
--to=okir@suse.de \
--cc=SteveD@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox