aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svcsock.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-02-12 03:53:34 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:36 -0500
commit27459f0940e16c68e080f5fc7e85aa9eb3f74528 (patch)
treef13cd1f2005dda2b6115e2afbc49e1271b0d374b /net/sunrpc/svcsock.c
parent2442222283918c2d1c20ae651d95fe168757938b (diff)
[PATCH] knfsd: SUNRPC: Provide room in svc_rqst for larger addresses
Expand the rq_addr field to allow it to contain larger addresses. Specifically, we replace a 'sockaddr_in' with a 'sockaddr_storage', then everywhere the 'sockaddr_in' was referenced, we use instead an accessor function (svc_addr_in) which safely casts the _storage to _in. 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.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 6680e0f0560d..b11669670baa 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -153,7 +153,7 @@ static char *__svc_print_addr(struct sockaddr *addr, char *buf, size_t len)
153 */ 153 */
154char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len) 154char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len)
155{ 155{
156 return __svc_print_addr((struct sockaddr *) &rqstp->rq_addr, buf, len); 156 return __svc_print_addr(svc_addr(rqstp), buf, len);
157} 157}
158EXPORT_SYMBOL_GPL(svc_print_addr); 158EXPORT_SYMBOL_GPL(svc_print_addr);
159 159
@@ -473,7 +473,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
473 /* set the source and destination */ 473 /* set the source and destination */
474 struct msghdr msg; 474 struct msghdr msg;
475 msg.msg_name = &rqstp->rq_addr; 475 msg.msg_name = &rqstp->rq_addr;
476 msg.msg_namelen = sizeof(rqstp->rq_addr); 476 msg.msg_namelen = rqstp->rq_addrlen;
477 msg.msg_iov = NULL; 477 msg.msg_iov = NULL;
478 msg.msg_iovlen = 0; 478 msg.msg_iovlen = 0;
479 msg.msg_flags = MSG_MORE; 479 msg.msg_flags = MSG_MORE;
@@ -696,6 +696,7 @@ svc_write_space(struct sock *sk)
696static int 696static int
697svc_udp_recvfrom(struct svc_rqst *rqstp) 697svc_udp_recvfrom(struct svc_rqst *rqstp)
698{ 698{
699 struct sockaddr_in *sin = svc_addr_in(rqstp);
699 struct svc_sock *svsk = rqstp->rq_sock; 700 struct svc_sock *svsk = rqstp->rq_sock;
700 struct svc_serv *serv = svsk->sk_server; 701 struct svc_serv *serv = svsk->sk_server;
701 struct sk_buff *skb; 702 struct sk_buff *skb;
@@ -756,9 +757,12 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
756 rqstp->rq_prot = IPPROTO_UDP; 757 rqstp->rq_prot = IPPROTO_UDP;
757 758
758 /* Get sender address */ 759 /* Get sender address */
759 rqstp->rq_addr.sin_family = AF_INET; 760 sin->sin_family = AF_INET;
760 rqstp->rq_addr.sin_port = skb->h.uh->source; 761 sin->sin_port = skb->h.uh->source;
761 rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; 762 sin->sin_addr.s_addr = skb->nh.iph->saddr;
763 rqstp->rq_addrlen = sizeof(struct sockaddr_in);
764
765 /* Remember which interface received this request */
762 rqstp->rq_daddr = skb->nh.iph->daddr; 766 rqstp->rq_daddr = skb->nh.iph->daddr;
763 767
764 if (skb_is_nonlinear(skb)) { 768 if (skb_is_nonlinear(skb)) {
@@ -1298,7 +1302,8 @@ svc_sock_update_bufs(struct svc_serv *serv)
1298int 1302int
1299svc_recv(struct svc_rqst *rqstp, long timeout) 1303svc_recv(struct svc_rqst *rqstp, long timeout)
1300{ 1304{
1301 struct svc_sock *svsk =NULL; 1305 struct svc_sock *svsk = NULL;
1306 struct sockaddr_in *sin = svc_addr_in(rqstp);
1302 struct svc_serv *serv = rqstp->rq_server; 1307 struct svc_serv *serv = rqstp->rq_server;
1303 struct svc_pool *pool = rqstp->rq_pool; 1308 struct svc_pool *pool = rqstp->rq_pool;
1304 int len, i; 1309 int len, i;
@@ -1395,7 +1400,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
1395 svsk->sk_lastrecv = get_seconds(); 1400 svsk->sk_lastrecv = get_seconds();
1396 clear_bit(SK_OLD, &svsk->sk_flags); 1401 clear_bit(SK_OLD, &svsk->sk_flags);
1397 1402
1398 rqstp->rq_secure = ntohs(rqstp->rq_addr.sin_port) < 1024; 1403 rqstp->rq_secure = ntohs(sin->sin_port) < PROT_SOCK;
1399 rqstp->rq_chandle.defer = svc_defer; 1404 rqstp->rq_chandle.defer = svc_defer;
1400 1405
1401 if (serv->sv_stats) 1406 if (serv->sv_stats)