diff options
author | Sridhar Samudrala <sri@us.ibm.com> | 2006-08-07 23:58:01 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 17:54:06 -0400 |
commit | e6242e928ef1e4ed853f909a7479e4934f4bcb70 (patch) | |
tree | f348f28e1993c73b2683f7edf87ef673ad2d5ec8 /net/sunrpc/svcsock.c | |
parent | ac5a488ef252ed673cb067843e411f8cc43f7ab9 (diff) |
[SUNRPC]: Update to use in-kernel sockets API.
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sunrpc/svcsock.c')
-rw-r--r-- | net/sunrpc/svcsock.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index d9a95732df46..953aff89bcac 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -388,7 +388,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) | |||
388 | /* send head */ | 388 | /* send head */ |
389 | if (slen == xdr->head[0].iov_len) | 389 | if (slen == xdr->head[0].iov_len) |
390 | flags = 0; | 390 | flags = 0; |
391 | len = sock->ops->sendpage(sock, rqstp->rq_respages[0], 0, xdr->head[0].iov_len, flags); | 391 | len = kernel_sendpage(sock, rqstp->rq_respages[0], 0, xdr->head[0].iov_len, flags); |
392 | if (len != xdr->head[0].iov_len) | 392 | if (len != xdr->head[0].iov_len) |
393 | goto out; | 393 | goto out; |
394 | slen -= xdr->head[0].iov_len; | 394 | slen -= xdr->head[0].iov_len; |
@@ -400,7 +400,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) | |||
400 | while (pglen > 0) { | 400 | while (pglen > 0) { |
401 | if (slen == size) | 401 | if (slen == size) |
402 | flags = 0; | 402 | flags = 0; |
403 | result = sock->ops->sendpage(sock, *ppage, base, size, flags); | 403 | result = kernel_sendpage(sock, *ppage, base, size, flags); |
404 | if (result > 0) | 404 | if (result > 0) |
405 | len += result; | 405 | len += result; |
406 | if (result != size) | 406 | if (result != size) |
@@ -413,7 +413,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) | |||
413 | } | 413 | } |
414 | /* send tail */ | 414 | /* send tail */ |
415 | if (xdr->tail[0].iov_len) { | 415 | if (xdr->tail[0].iov_len) { |
416 | result = sock->ops->sendpage(sock, rqstp->rq_respages[rqstp->rq_restailpage], | 416 | result = kernel_sendpage(sock, rqstp->rq_respages[rqstp->rq_restailpage], |
417 | ((unsigned long)xdr->tail[0].iov_base)& (PAGE_SIZE-1), | 417 | ((unsigned long)xdr->tail[0].iov_base)& (PAGE_SIZE-1), |
418 | xdr->tail[0].iov_len, 0); | 418 | xdr->tail[0].iov_len, 0); |
419 | 419 | ||
@@ -434,13 +434,10 @@ out: | |||
434 | static int | 434 | static int |
435 | svc_recv_available(struct svc_sock *svsk) | 435 | svc_recv_available(struct svc_sock *svsk) |
436 | { | 436 | { |
437 | mm_segment_t oldfs; | ||
438 | struct socket *sock = svsk->sk_sock; | 437 | struct socket *sock = svsk->sk_sock; |
439 | int avail, err; | 438 | int avail, err; |
440 | 439 | ||
441 | oldfs = get_fs(); set_fs(KERNEL_DS); | 440 | err = kernel_sock_ioctl(sock, TIOCINQ, (unsigned long) &avail); |
442 | err = sock->ops->ioctl(sock, TIOCINQ, (unsigned long) &avail); | ||
443 | set_fs(oldfs); | ||
444 | 441 | ||
445 | return (err >= 0)? avail : err; | 442 | return (err >= 0)? avail : err; |
446 | } | 443 | } |
@@ -472,7 +469,7 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) | |||
472 | * at accept time. FIXME | 469 | * at accept time. FIXME |
473 | */ | 470 | */ |
474 | alen = sizeof(rqstp->rq_addr); | 471 | alen = sizeof(rqstp->rq_addr); |
475 | sock->ops->getname(sock, (struct sockaddr *)&rqstp->rq_addr, &alen, 1); | 472 | kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen); |
476 | 473 | ||
477 | dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", | 474 | dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", |
478 | rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); | 475 | rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); |
@@ -758,7 +755,6 @@ svc_tcp_accept(struct svc_sock *svsk) | |||
758 | struct svc_serv *serv = svsk->sk_server; | 755 | struct svc_serv *serv = svsk->sk_server; |
759 | struct socket *sock = svsk->sk_sock; | 756 | struct socket *sock = svsk->sk_sock; |
760 | struct socket *newsock; | 757 | struct socket *newsock; |
761 | const struct proto_ops *ops; | ||
762 | struct svc_sock *newsvsk; | 758 | struct svc_sock *newsvsk; |
763 | int err, slen; | 759 | int err, slen; |
764 | 760 | ||
@@ -766,29 +762,23 @@ svc_tcp_accept(struct svc_sock *svsk) | |||
766 | if (!sock) | 762 | if (!sock) |
767 | return; | 763 | return; |
768 | 764 | ||
769 | err = sock_create_lite(PF_INET, SOCK_STREAM, IPPROTO_TCP, &newsock); | 765 | clear_bit(SK_CONN, &svsk->sk_flags); |
770 | if (err) { | 766 | err = kernel_accept(sock, &newsock, O_NONBLOCK); |
767 | if (err < 0) { | ||
771 | if (err == -ENOMEM) | 768 | if (err == -ENOMEM) |
772 | printk(KERN_WARNING "%s: no more sockets!\n", | 769 | printk(KERN_WARNING "%s: no more sockets!\n", |
773 | serv->sv_name); | 770 | serv->sv_name); |
774 | return; | 771 | else if (err != -EAGAIN && net_ratelimit()) |
775 | } | ||
776 | |||
777 | dprintk("svc: tcp_accept %p allocated\n", newsock); | ||
778 | newsock->ops = ops = sock->ops; | ||
779 | |||
780 | clear_bit(SK_CONN, &svsk->sk_flags); | ||
781 | if ((err = ops->accept(sock, newsock, O_NONBLOCK)) < 0) { | ||
782 | if (err != -EAGAIN && net_ratelimit()) | ||
783 | printk(KERN_WARNING "%s: accept failed (err %d)!\n", | 772 | printk(KERN_WARNING "%s: accept failed (err %d)!\n", |
784 | serv->sv_name, -err); | 773 | serv->sv_name, -err); |
785 | goto failed; /* aborted connection or whatever */ | 774 | return; |
786 | } | 775 | } |
776 | |||
787 | set_bit(SK_CONN, &svsk->sk_flags); | 777 | set_bit(SK_CONN, &svsk->sk_flags); |
788 | svc_sock_enqueue(svsk); | 778 | svc_sock_enqueue(svsk); |
789 | 779 | ||
790 | slen = sizeof(sin); | 780 | slen = sizeof(sin); |
791 | err = ops->getname(newsock, (struct sockaddr *) &sin, &slen, 1); | 781 | err = kernel_getpeername(newsock, (struct sockaddr *) &sin, &slen); |
792 | if (err < 0) { | 782 | if (err < 0) { |
793 | if (net_ratelimit()) | 783 | if (net_ratelimit()) |
794 | printk(KERN_WARNING "%s: peername failed (err %d)!\n", | 784 | printk(KERN_WARNING "%s: peername failed (err %d)!\n", |
@@ -1406,14 +1396,14 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) | |||
1406 | if (sin != NULL) { | 1396 | if (sin != NULL) { |
1407 | if (type == SOCK_STREAM) | 1397 | if (type == SOCK_STREAM) |
1408 | sock->sk->sk_reuse = 1; /* allow address reuse */ | 1398 | sock->sk->sk_reuse = 1; /* allow address reuse */ |
1409 | error = sock->ops->bind(sock, (struct sockaddr *) sin, | 1399 | error = kernel_bind(sock, (struct sockaddr *) sin, |
1410 | sizeof(*sin)); | 1400 | sizeof(*sin)); |
1411 | if (error < 0) | 1401 | if (error < 0) |
1412 | goto bummer; | 1402 | goto bummer; |
1413 | } | 1403 | } |
1414 | 1404 | ||
1415 | if (protocol == IPPROTO_TCP) { | 1405 | if (protocol == IPPROTO_TCP) { |
1416 | if ((error = sock->ops->listen(sock, 64)) < 0) | 1406 | if ((error = kernel_listen(sock, 64)) < 0) |
1417 | goto bummer; | 1407 | goto bummer; |
1418 | } | 1408 | } |
1419 | 1409 | ||