aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-02-12 03:53:30 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:35 -0500
commit067d7817310569f7b76ca08c4d071ca95ad4c1d3 (patch)
treeee931bac235a3f9d0083edd7c00340121fe32767 /net/sunrpc
parente79eff1f90826b207b1152fc87aa97fa74fb7f9c (diff)
[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')
-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)
568static int 568static int
569svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) 569svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
570{ 570{
571 struct svc_sock *svsk = rqstp->rq_sock;
571 struct msghdr msg; 572 struct msghdr msg;
572 struct socket *sock; 573 struct socket *sock;
573 int len, alen; 574 int len;
574 575
575 rqstp->rq_addrlen = sizeof(rqstp->rq_addr); 576 rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
576 sock = rqstp->rq_sock->sk_sock; 577 sock = svsk->sk_sock;
577 578
578 msg.msg_name = &rqstp->rq_addr; 579 msg.msg_name = &rqstp->rq_addr;
579 msg.msg_namelen = sizeof(rqstp->rq_addr); 580 msg.msg_namelen = sizeof(rqstp->rq_addr);
@@ -585,11 +586,9 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
585 len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT); 586 len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT);
586 587
587 /* sock_recvmsg doesn't fill in the name/namelen, so we must.. 588 /* sock_recvmsg doesn't fill in the name/namelen, so we must..
588 * possibly we should cache this in the svc_sock structure
589 * at accept time. FIXME
590 */ 589 */
591 alen = sizeof(rqstp->rq_addr); 590 memcpy(&rqstp->rq_addr, &svsk->sk_remote, svsk->sk_remotelen);
592 kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen); 591 rqstp->rq_addrlen = svsk->sk_remotelen;
593 592
594 dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", 593 dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
595 rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); 594 rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len);
@@ -938,6 +937,9 @@ svc_tcp_accept(struct svc_sock *svsk)
938 if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 937 if (!(newsvsk = svc_setup_socket(serv, newsock, &err,
939 (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) 938 (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY))))
940 goto failed; 939 goto failed;
940 memcpy(&newsvsk->sk_remote, &sin, slen);
941 newsvsk->sk_remotelen = slen;
942
941 svc_sock_received(newsvsk); 943 svc_sock_received(newsvsk);
942 944
943 /* make sure that we don't have too many active connections. 945 /* make sure that we don't have too many active connections.