From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: [PATCH 003 of 14] knfsd: SUNRPC: Cache remote peer's address in svc_sock. Date: Wed, 13 Dec 2006 10:58:50 +1100 Message-ID: <1061212235850.21380@suse.de> References: <20061213105528.21128.patches@notabene> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: nfs@lists.sourceforge.net, linux-kernel@vger.kernel.org Return-path: Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list2-new.sourceforge.net with esmtp (Exim 4.43) id 1GuHW6-0002RH-Rq for nfs@lists.sourceforge.net; Tue, 12 Dec 2006 15:58:35 -0800 Received: from mx2.suse.de ([195.135.220.15]) by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1GuHW7-0006Og-EZ for nfs@lists.sourceforge.net; Tue, 12 Dec 2006 15:58:36 -0800 To: Andrew Morton List-Id: "Discussion of NFS under Linux development, interoperability, and testing." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: nfs-bounces@lists.sourceforge.net Errors-To: nfs-bounces@lists.sourceforge.net From: Chuck Lever 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 Cc: Aurelien Charbon Signed-off-by: Neil Brown ### Diffstat output ./include/linux/sunrpc/svcsock.h | 3 +++ ./net/sunrpc/svcsock.c | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff .prev/include/linux/sunrpc/svcsock.h ./include/linux/sunrpc/svcsock.h --- .prev/include/linux/sunrpc/svcsock.h 2006-12-13 10:29:09.000000000 +1100 +++ ./include/linux/sunrpc/svcsock.h 2006-12-13 10:29:13.000000000 +1100 @@ -57,6 +57,9 @@ struct svc_sock { /* cache of various info for TCP sockets */ void *sk_info_authunix; + + struct sockaddr_storage sk_remote; /* remote peer's address */ + int sk_remotelen; /* length of address */ }; /* diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c --- .prev/net/sunrpc/svcsock.c 2006-12-13 10:29:09.000000000 +1100 +++ ./net/sunrpc/svcsock.c 2006-12-13 10:29:13.000000000 +1100 @@ -577,11 +577,9 @@ svc_recvfrom(struct svc_rqst *rqstp, str 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); @@ -873,7 +871,7 @@ svc_tcp_accept(struct svc_sock *svsk) struct socket *sock = svsk->sk_sock; struct socket *newsock; struct svc_sock *newsvsk; - int err, slen; + int err, slen = 0; dprintk("svc: tcp_accept %p sock %p\n", svsk, sock); if (!sock) @@ -925,7 +923,8 @@ 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; /* make sure that we don't have too many active connections. * If we have, something must be dropped. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964830AbWLMASV (ORCPT ); Tue, 12 Dec 2006 19:18:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932587AbWLMASA (ORCPT ); Tue, 12 Dec 2006 19:18:00 -0500 Received: from cantor2.suse.de ([195.135.220.15]:52833 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932591AbWLMARs (ORCPT ); Tue, 12 Dec 2006 19:17:48 -0500 From: NeilBrown To: Andrew Morton Date: Wed, 13 Dec 2006 10:58:50 +1100 Message-Id: <1061212235850.21380@suse.de> X-face: [Gw_3E*Gng}4rRrKRYotwlE?.2|**#s9D Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org From: Chuck Lever 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 Cc: Aurelien Charbon Signed-off-by: Neil Brown ### Diffstat output ./include/linux/sunrpc/svcsock.h | 3 +++ ./net/sunrpc/svcsock.c | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff .prev/include/linux/sunrpc/svcsock.h ./include/linux/sunrpc/svcsock.h --- .prev/include/linux/sunrpc/svcsock.h 2006-12-13 10:29:09.000000000 +1100 +++ ./include/linux/sunrpc/svcsock.h 2006-12-13 10:29:13.000000000 +1100 @@ -57,6 +57,9 @@ struct svc_sock { /* cache of various info for TCP sockets */ void *sk_info_authunix; + + struct sockaddr_storage sk_remote; /* remote peer's address */ + int sk_remotelen; /* length of address */ }; /* diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c --- .prev/net/sunrpc/svcsock.c 2006-12-13 10:29:09.000000000 +1100 +++ ./net/sunrpc/svcsock.c 2006-12-13 10:29:13.000000000 +1100 @@ -577,11 +577,9 @@ svc_recvfrom(struct svc_rqst *rqstp, str 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); @@ -873,7 +871,7 @@ svc_tcp_accept(struct svc_sock *svsk) struct socket *sock = svsk->sk_sock; struct socket *newsock; struct svc_sock *newsvsk; - int err, slen; + int err, slen = 0; dprintk("svc: tcp_accept %p sock %p\n", svsk, sock); if (!sock) @@ -925,7 +923,8 @@ 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; /* make sure that we don't have too many active connections. * If we have, something must be dropped.