Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a97476926ec061f90b77da478620ea6dc71a3237
Commit:     a97476926ec061f90b77da478620ea6dc71a3237
Parent:     96802a095171f5b35cf0e1e0d4be943e6696a253
Author:     Frank van Maarseveen <[EMAIL PROTECTED]>
AuthorDate: Mon Jul 9 22:21:39 2007 +0200
Committer:  Trond Myklebust <[EMAIL PROTECTED]>
CommitDate: Tue Jul 10 23:40:49 2007 -0400

    SUNRPC server: record the destination address of a request
    
    Save the destination address of an incoming request over TCP like is
    done already for UDP. It is necessary later for callbacks by the server.
    
    Signed-off-by: Frank van Maarseveen <[EMAIL PROTECTED]>
    Signed-off-by: Trond Myklebust <[EMAIL PROTECTED]>
---
 include/linux/sunrpc/svcsock.h |    1 +
 net/sunrpc/svcsock.c           |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index e21dd93..a53e0fa 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -59,6 +59,7 @@ struct svc_sock {
        /* cache of various info for TCP sockets */
        void                    *sk_info_authunix;
 
+       struct sockaddr_storage sk_local;       /* local address */
        struct sockaddr_storage sk_remote;      /* remote peer's address */
        int                     sk_remotelen;   /* length of address */
 };
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 5baf48d..64b9b8c 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -644,6 +644,7 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int 
nr, int buflen)
        struct msghdr msg = {
                .msg_flags      = MSG_DONTWAIT,
        };
+       struct sockaddr *sin;
        int len;
 
        len = kernel_recvmsg(svsk->sk_sock, &msg, iov, nr, buflen,
@@ -654,6 +655,19 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int 
nr, int buflen)
        memcpy(&rqstp->rq_addr, &svsk->sk_remote, svsk->sk_remotelen);
        rqstp->rq_addrlen = svsk->sk_remotelen;
 
+       /* Destination address in request is needed for binding the
+        * source address in RPC callbacks later.
+        */
+       sin = (struct sockaddr *)&svsk->sk_local;
+       switch (sin->sa_family) {
+       case AF_INET:
+               rqstp->rq_daddr.addr = ((struct sockaddr_in *)sin)->sin_addr;
+               break;
+       case AF_INET6:
+               rqstp->rq_daddr.addr6 = ((struct sockaddr_in6 *)sin)->sin6_addr;
+               break;
+       }
+
        dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
                svsk, iov[0].iov_base, iov[0].iov_len, len);
 
@@ -1064,6 +1078,12 @@ svc_tcp_accept(struct svc_sock *svsk)
                goto failed;
        memcpy(&newsvsk->sk_remote, sin, slen);
        newsvsk->sk_remotelen = slen;
+       err = kernel_getsockname(newsock, sin, &slen);
+       if (unlikely(err < 0)) {
+               dprintk("svc_tcp_accept: kernel_getsockname error %d\n", -err);
+               slen = offsetof(struct sockaddr, sa_data);
+       }
+       memcpy(&newsvsk->sk_local, sin, slen);
 
        svc_sock_received(newsvsk);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to