summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svcsock.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-02-12 00:53:30 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 09:48:35 -0800
commit067d7817310569f7b76ca08c4d071ca95ad4c1d3 (patch)
treeee931bac235a3f9d0083edd7c00340121fe32767 /net/sunrpc/svcsock.c
parente79eff1f90826b207b1152fc87aa97fa74fb7f9c (diff)
downloadlinux-067d7817310569f7b76ca08c4d071ca95ad4c1d3.tar.gz
linux-067d7817310569f7b76ca08c4d071ca95ad4c1d3.tar.bz2
linux-067d7817310569f7b76ca08c4d071ca95ad4c1d3.zip
[PATCH] knfsd: SUNRPC: Cache remote peer's address in svc_sock
The remote peer's address won't change after the socket has been accepted. We don't need to call ->getname on every incoming request. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/sunrpc/svcsock.c')
-rw-r--r--net/sunrpc/svcsock.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 7292baf5a741..1f97ed49fee2 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -568,12 +568,13 @@ svc_recv_available(struct svc_sock *svsk)
static int
svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
{
+ struct svc_sock *svsk = rqstp->rq_sock;
struct msghdr msg;
struct socket *sock;
- int len, alen;
+ int len;
rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
- sock = rqstp->rq_sock->sk_sock;
+ sock = svsk->sk_sock;
msg.msg_name = &rqstp->rq_addr;
msg.msg_namelen = sizeof(rqstp->rq_addr);
@@ -585,11 +586,9 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT);
/* sock_recvmsg doesn't fill in the name/namelen, so we must..
- * possibly we should cache this in the svc_sock structure
- * at accept time. FIXME
*/
- alen = sizeof(rqstp->rq_addr);
- kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen);
+ memcpy(&rqstp->rq_addr, &svsk->sk_remote, svsk->sk_remotelen);
+ rqstp->rq_addrlen = svsk->sk_remotelen;
dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len);
@@ -938,6 +937,9 @@ svc_tcp_accept(struct svc_sock *svsk)
if (!(newsvsk = svc_setup_socket(serv, newsock, &err,
(SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY))))
goto failed;
+ memcpy(&newsvsk->sk_remote, &sin, slen);
+ newsvsk->sk_remotelen = slen;
+
svc_sock_received(newsvsk);
/* make sure that we don't have too many active connections.