summaryrefslogtreecommitdiff
path: root/net/sunrpc
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2006-08-22 20:06:17 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-09-22 23:24:45 -0400
commited39440a2573abc926f230267000f21fa5a87822 (patch)
treef9b6ba1ce3a7f94fc9d3f4a3e82eea3fdcc965a6 /net/sunrpc
parentbbf7c1dd2ae2b4040b41b1065ee9b1b6905b1605 (diff)
downloadlinux-3.10-ed39440a2573abc926f230267000f21fa5a87822.tar.gz
linux-3.10-ed39440a2573abc926f230267000f21fa5a87822.tar.bz2
linux-3.10-ed39440a2573abc926f230267000f21fa5a87822.zip
SUNRPC: create API for getting remote peer address
Provide an API for retrieving the remote peer address without allowing direct access to the rpc_xprt struct. Test-plan: Compile kernel with CONFIG_NFS enabled. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/clnt.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index d003c2f5688..94768cf5fd5 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -533,6 +533,27 @@ rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)
task->tk_action = rpc_exit_task;
}
+/**
+ * rpc_peeraddr - extract remote peer address from clnt's xprt
+ * @clnt: RPC client structure
+ * @buf: target buffer
+ * @size: length of target buffer
+ *
+ * Returns the number of bytes that are actually in the stored address.
+ */
+size_t rpc_peeraddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t bufsize)
+{
+ size_t bytes;
+ struct rpc_xprt *xprt = clnt->cl_xprt;
+
+ bytes = sizeof(xprt->addr);
+ if (bytes > bufsize)
+ bytes = bufsize;
+ memcpy(buf, &clnt->cl_xprt->addr, bytes);
+ return sizeof(xprt->addr);
+}
+EXPORT_SYMBOL(rpc_peeraddr);
+
void
rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize)
{