summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-07-01 12:13:22 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:46 -0400
commit43780b87fa799ae65df11d89d4539d8d6a7c67eb (patch)
tree46fce452807c8672af77666bb03cab5ff4191e94 /net
parent45160d6275814e0c86206e6981f0b92c61a50a21 (diff)
downloadlinux-43780b87fa799ae65df11d89d4539d8d6a7c67eb.tar.gz
linux-43780b87fa799ae65df11d89d4539d8d6a7c67eb.tar.bz2
linux-43780b87fa799ae65df11d89d4539d8d6a7c67eb.zip
SUNRPC: Add a convenient default for the hostname when calling rpc_create()
A couple of callers just use a stringified IP address for the rpc client's hostname. Move the logic for constructing this into rpc_create(), so it can be shared. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/clnt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index e1553cf2a68f..0d9b5275fac3 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -234,6 +234,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
{
struct rpc_xprt *xprt;
struct rpc_clnt *clnt;
+ char servername[20];
xprt = xprt_create_transport(args->protocol, args->address,
args->addrsize, args->timeout);
@@ -241,6 +242,18 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
return (struct rpc_clnt *)xprt;
/*
+ * If the caller chooses not to specify a hostname, whip
+ * up a string representation of the passed-in address.
+ */
+ if (args->servername == NULL) {
+ struct sockaddr_in *addr =
+ (struct sockaddr_in *) &args->address;
+ snprintf(servername, sizeof(servername), NIPQUAD_FMT,
+ NIPQUAD(addr->sin_addr.s_addr));
+ args->servername = servername;
+ }
+
+ /*
* By default, kernel RPC client connects from a reserved port.
* CAP_NET_BIND_SERVICE will not be set for unprivileged requesters,
* but it is always enabled for rpciod, which handles the connect