aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/sunrpc/svcsock.h3
-rw-r--r--net/sunrpc/svcsock.c14
2 files changed, 11 insertions, 6 deletions
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index f030409d2994..cccea0a0feb4 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -57,6 +57,9 @@ struct svc_sock {
57 57
58 /* cache of various info for TCP sockets */ 58 /* cache of various info for TCP sockets */
59 void *sk_info_authunix; 59 void *sk_info_authunix;
60
61 struct sockaddr_storage sk_remote; /* remote peer's address */
62 int sk_remotelen; /* length of address */
60}; 63};
61 64
62/* 65/*
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.