2 * linux/net/sunrpc/svcsock.c
4 * These are the RPC server socket internals.
6 * The server scheduling algorithm does not always distribute the load
7 * evenly when servicing a single client. May need to modify the
8 * svc_sock_enqueue procedure...
10 * TCP support is largely untested and may be a little slow. The problem
11 * is that we currently do two separate recvfrom's, one for the 4-byte
12 * record length, and the second for the actual record. This could possibly
13 * be improved by always reading a minimum size of around 100 bytes and
14 * tucking any superfluous bytes away in a temporary store. Still, that
15 * leaves write requests out in the rain. An alternative may be to peek at
16 * the first skb in the queue, and if it matches the next TCP sequence
17 * number, to extract the record marker. Yuck.
19 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
22 #include <linux/sched.h>
23 #include <linux/errno.h>
24 #include <linux/fcntl.h>
25 #include <linux/net.h>
27 #include <linux/inet.h>
28 #include <linux/udp.h>
29 #include <linux/tcp.h>
30 #include <linux/unistd.h>
31 #include <linux/slab.h>
32 #include <linux/netdevice.h>
33 #include <linux/skbuff.h>
34 #include <linux/suspend.h>
36 #include <net/checksum.h>
39 #include <asm/uaccess.h>
40 #include <asm/ioctls.h>
42 #include <linux/sunrpc/types.h>
43 #include <linux/sunrpc/xdr.h>
44 #include <linux/sunrpc/svcsock.h>
45 #include <linux/sunrpc/stats.h>
47 /* SMP locking strategy:
49 * svc_serv->sv_lock protects most stuff for that service.
51 * Some flags can be set to certain values at any time
52 * providing that certain rules are followed:
54 * SK_BUSY can be set to 0 at any time.
55 * svc_sock_enqueue must be called afterwards
56 * SK_CONN, SK_DATA, can be set or cleared at any time.
57 * after a set, svc_sock_enqueue must be called.
58 * after a clear, the socket must be read/accepted
59 * if this succeeds, it must be set again.
60 * SK_CLOSE can set at any time. It is never cleared.
64 #define RPCDBG_FACILITY RPCDBG_SVCSOCK
67 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
68 int *errp, int pmap_reg);
69 static void svc_udp_data_ready(struct sock *, int);
70 static int svc_udp_recvfrom(struct svc_rqst *);
71 static int svc_udp_sendto(struct svc_rqst *);
73 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
74 static int svc_deferred_recv(struct svc_rqst *rqstp);
75 static struct cache_deferred_req *svc_defer(struct cache_req *req);
78 * Queue up an idle server thread. Must have serv->sv_lock held.
79 * Note: this is really a stack rather than a queue, so that we only
80 * use as many different threads as we need, and the rest don't polute
84 svc_serv_enqueue(struct svc_serv *serv, struct svc_rqst *rqstp)
86 list_add(&rqstp->rq_list, &serv->sv_threads);
90 * Dequeue an nfsd thread. Must have serv->sv_lock held.
93 svc_serv_dequeue(struct svc_serv *serv, struct svc_rqst *rqstp)
95 list_del(&rqstp->rq_list);
99 * Release an skbuff after use
102 svc_release_skb(struct svc_rqst *rqstp)
104 struct sk_buff *skb = rqstp->rq_skbuff;
105 struct svc_deferred_req *dr = rqstp->rq_deferred;
108 rqstp->rq_skbuff = NULL;
110 dprintk("svc: service %p, releasing skb %p\n", rqstp, skb);
111 skb_free_datagram(rqstp->rq_sock->sk_sk, skb);
114 rqstp->rq_deferred = NULL;
120 * Any space to write?
122 static inline unsigned long
123 svc_sock_wspace(struct svc_sock *svsk)
127 if (svsk->sk_sock->type == SOCK_STREAM)
128 wspace = tcp_wspace(svsk->sk_sk);
130 wspace = sock_wspace(svsk->sk_sk);
136 * Queue up a socket with data pending. If there are idle nfsd
137 * processes, wake 'em up.
141 svc_sock_enqueue(struct svc_sock *svsk)
143 struct svc_serv *serv = svsk->sk_server;
144 struct svc_rqst *rqstp;
146 if (!(svsk->sk_flags &
147 ( (1<<SK_CONN)|(1<<SK_DATA)|(1<<SK_CLOSE)|(1<<SK_DEFERRED)) ))
149 if (test_bit(SK_DEAD, &svsk->sk_flags))
152 spin_lock_bh(&serv->sv_lock);
154 if (!list_empty(&serv->sv_threads) &&
155 !list_empty(&serv->sv_sockets))
157 "svc_sock_enqueue: threads and sockets both waiting??\n");
159 if (test_bit(SK_DEAD, &svsk->sk_flags)) {
160 /* Don't enqueue dead sockets */
161 dprintk("svc: socket %p is dead, not enqueued\n", svsk->sk_sk);
165 if (test_bit(SK_BUSY, &svsk->sk_flags)) {
166 /* Don't enqueue socket while daemon is receiving */
167 dprintk("svc: socket %p busy, not enqueued\n", svsk->sk_sk);
171 set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
172 if (((svsk->sk_reserved + serv->sv_bufsz)*2
173 > svc_sock_wspace(svsk))
174 && !test_bit(SK_CLOSE, &svsk->sk_flags)
175 && !test_bit(SK_CONN, &svsk->sk_flags)) {
176 /* Don't enqueue while not enough space for reply */
177 dprintk("svc: socket %p no space, %d*2 > %ld, not enqueued\n",
178 svsk->sk_sk, svsk->sk_reserved+serv->sv_bufsz,
179 svc_sock_wspace(svsk));
182 clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
184 /* Mark socket as busy. It will remain in this state until the
185 * server has processed all pending data and put the socket back
188 set_bit(SK_BUSY, &svsk->sk_flags);
190 if (!list_empty(&serv->sv_threads)) {
191 rqstp = list_entry(serv->sv_threads.next,
194 dprintk("svc: socket %p served by daemon %p\n",
196 svc_serv_dequeue(serv, rqstp);
199 "svc_sock_enqueue: server %p, rq_sock=%p!\n",
200 rqstp, rqstp->rq_sock);
201 rqstp->rq_sock = svsk;
203 rqstp->rq_reserved = serv->sv_bufsz;
204 svsk->sk_reserved += rqstp->rq_reserved;
205 wake_up(&rqstp->rq_wait);
207 dprintk("svc: socket %p put into queue\n", svsk->sk_sk);
208 list_add_tail(&svsk->sk_ready, &serv->sv_sockets);
212 spin_unlock_bh(&serv->sv_lock);
216 * Dequeue the first socket. Must be called with the serv->sv_lock held.
218 static inline struct svc_sock *
219 svc_sock_dequeue(struct svc_serv *serv)
221 struct svc_sock *svsk;
223 if (list_empty(&serv->sv_sockets))
226 svsk = list_entry(serv->sv_sockets.next,
227 struct svc_sock, sk_ready);
228 list_del_init(&svsk->sk_ready);
230 dprintk("svc: socket %p dequeued, inuse=%d\n",
231 svsk->sk_sk, svsk->sk_inuse);
237 * Having read something from a socket, check whether it
238 * needs to be re-enqueued.
239 * Note: SK_DATA only gets cleared when a read-attempt finds
240 * no (or insufficient) data.
243 svc_sock_received(struct svc_sock *svsk)
245 clear_bit(SK_BUSY, &svsk->sk_flags);
246 svc_sock_enqueue(svsk);
251 * svc_reserve - change the space reserved for the reply to a request.
252 * @rqstp: The request in question
253 * @space: new max space to reserve
255 * Each request reserves some space on the output queue of the socket
256 * to make sure the reply fits. This function reduces that reserved
257 * space to be the amount of space used already, plus @space.
260 void svc_reserve(struct svc_rqst *rqstp, int space)
262 space += rqstp->rq_res.head[0].iov_len;
264 if (space < rqstp->rq_reserved) {
265 struct svc_sock *svsk = rqstp->rq_sock;
266 spin_lock_bh(&svsk->sk_server->sv_lock);
267 svsk->sk_reserved -= (rqstp->rq_reserved - space);
268 rqstp->rq_reserved = space;
269 spin_unlock_bh(&svsk->sk_server->sv_lock);
271 svc_sock_enqueue(svsk);
276 * Release a socket after use.
279 svc_sock_put(struct svc_sock *svsk)
281 struct svc_serv *serv = svsk->sk_server;
283 spin_lock_bh(&serv->sv_lock);
284 if (!--(svsk->sk_inuse) && test_bit(SK_DEAD, &svsk->sk_flags)) {
285 spin_unlock_bh(&serv->sv_lock);
286 dprintk("svc: releasing dead socket\n");
287 sock_release(svsk->sk_sock);
291 spin_unlock_bh(&serv->sv_lock);
295 svc_sock_release(struct svc_rqst *rqstp)
297 struct svc_sock *svsk = rqstp->rq_sock;
299 svc_release_skb(rqstp);
301 svc_free_allpages(rqstp);
302 rqstp->rq_res.page_len = 0;
303 rqstp->rq_res.page_base = 0;
306 /* Reset response buffer and release
308 * But first, check that enough space was reserved
309 * for the reply, otherwise we have a bug!
311 if ((rqstp->rq_res.len) > rqstp->rq_reserved)
312 printk(KERN_ERR "RPC request reserved %d but used %d\n",
316 rqstp->rq_res.head[0].iov_len = 0;
317 svc_reserve(rqstp, 0);
318 rqstp->rq_sock = NULL;
324 * External function to wake up a server waiting for data
327 svc_wake_up(struct svc_serv *serv)
329 struct svc_rqst *rqstp;
331 spin_lock_bh(&serv->sv_lock);
332 if (!list_empty(&serv->sv_threads)) {
333 rqstp = list_entry(serv->sv_threads.next,
336 dprintk("svc: daemon %p woken up.\n", rqstp);
338 svc_serv_dequeue(serv, rqstp);
339 rqstp->rq_sock = NULL;
341 wake_up(&rqstp->rq_wait);
343 spin_unlock_bh(&serv->sv_lock);
347 * Generic sendto routine
350 svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
352 struct svc_sock *svsk = rqstp->rq_sock;
353 struct socket *sock = svsk->sk_sock;
355 char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))];
356 struct cmsghdr *cmh = (struct cmsghdr *)buffer;
357 struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmh);
361 struct page **ppage = xdr->pages;
362 size_t base = xdr->page_base;
363 unsigned int pglen = xdr->page_len;
364 unsigned int flags = MSG_MORE;
368 if (rqstp->rq_prot == IPPROTO_UDP) {
369 /* set the source and destination */
371 msg.msg_name = &rqstp->rq_addr;
372 msg.msg_namelen = sizeof(rqstp->rq_addr);
375 msg.msg_flags = MSG_MORE;
377 msg.msg_control = cmh;
378 msg.msg_controllen = sizeof(buffer);
379 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
380 cmh->cmsg_level = SOL_IP;
381 cmh->cmsg_type = IP_PKTINFO;
382 pki->ipi_ifindex = 0;
383 pki->ipi_spec_dst.s_addr = rqstp->rq_daddr;
385 if (sock_sendmsg(sock, &msg, 0) < 0)
390 if (slen == xdr->head[0].iov_len)
392 len = sock->ops->sendpage(sock, rqstp->rq_respages[0], 0, xdr->head[0].iov_len, flags);
393 if (len != xdr->head[0].iov_len)
395 slen -= xdr->head[0].iov_len;
400 size = PAGE_SIZE - base < pglen ? PAGE_SIZE - base : pglen;
404 result = sock->ops->sendpage(sock, *ppage, base, size, flags);
411 size = PAGE_SIZE < pglen ? PAGE_SIZE : pglen;
416 if (xdr->tail[0].iov_len) {
417 /* The tail *will* be in respages[0]; */
418 result = sock->ops->sendpage(sock, rqstp->rq_respages[rqstp->rq_restailpage],
419 ((unsigned long)xdr->tail[0].iov_base)& (PAGE_SIZE-1),
420 xdr->tail[0].iov_len, 0);
426 dprintk("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %x)\n",
427 rqstp->rq_sock, xdr->head[0].iov_base, xdr->head[0].iov_len, xdr->len, len,
428 rqstp->rq_addr.sin_addr.s_addr);
434 * Check input queue length
437 svc_recv_available(struct svc_sock *svsk)
440 struct socket *sock = svsk->sk_sock;
443 oldfs = get_fs(); set_fs(KERNEL_DS);
444 err = sock->ops->ioctl(sock, TIOCINQ, (unsigned long) &avail);
447 return (err >= 0)? avail : err;
451 * Generic recvfrom routine.
454 svc_recvfrom(struct svc_rqst *rqstp, struct iovec *iov, int nr, int buflen)
461 rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
462 sock = rqstp->rq_sock->sk_sock;
464 msg.msg_name = &rqstp->rq_addr;
465 msg.msg_namelen = sizeof(rqstp->rq_addr);
468 msg.msg_control = NULL;
469 msg.msg_controllen = 0;
471 msg.msg_flags = MSG_DONTWAIT;
473 oldfs = get_fs(); set_fs(KERNEL_DS);
474 len = sock_recvmsg(sock, &msg, buflen, MSG_DONTWAIT);
477 /* sock_recvmsg doesn't fill in the name/namelen, so we must..
478 * possibly we should cache this in the svc_sock structure
479 * at accept time. FIXME
481 alen = sizeof(rqstp->rq_addr);
482 sock->ops->getname(sock, (struct sockaddr *)&rqstp->rq_addr, &alen, 1);
484 dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
485 rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len);
491 * Set socket snd and rcv buffer lengths
494 svc_sock_setbufsize(struct socket *sock, unsigned int snd, unsigned int rcv)
498 oldfs = get_fs(); set_fs(KERNEL_DS);
499 sock_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
500 (char*)&snd, sizeof(snd));
501 sock_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
502 (char*)&rcv, sizeof(rcv));
504 /* sock_setsockopt limits use to sysctl_?mem_max,
505 * which isn't acceptable. Until that is made conditional
506 * on not having CAP_SYS_RESOURCE or similar, we go direct...
507 * DaveM said I could!
510 sock->sk->sk_sndbuf = snd * 2;
511 sock->sk->sk_rcvbuf = rcv * 2;
512 sock->sk->sk_userlocks |= SOCK_SNDBUF_LOCK|SOCK_RCVBUF_LOCK;
513 release_sock(sock->sk);
517 * INET callback when data has been received on the socket.
520 svc_udp_data_ready(struct sock *sk, int count)
522 struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data);
526 dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n",
527 svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags));
528 set_bit(SK_DATA, &svsk->sk_flags);
529 svc_sock_enqueue(svsk);
531 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
532 wake_up_interruptible(sk->sk_sleep);
536 * INET callback when space is newly available on the socket.
539 svc_write_space(struct sock *sk)
541 struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data);
544 dprintk("svc: socket %p(inet %p), write_space busy=%d\n",
545 svsk, sk, test_bit(SK_BUSY, &svsk->sk_flags));
546 svc_sock_enqueue(svsk);
549 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) {
550 printk(KERN_WARNING "RPC svc_write_space: some sleeping on %p\n",
552 wake_up_interruptible(sk->sk_sleep);
557 * Receive a datagram from a UDP socket.
560 csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb);
563 svc_udp_recvfrom(struct svc_rqst *rqstp)
565 struct svc_sock *svsk = rqstp->rq_sock;
566 struct svc_serv *serv = svsk->sk_server;
570 if (test_and_clear_bit(SK_CHNGBUF, &svsk->sk_flags))
571 /* udp sockets need large rcvbuf as all pending
572 * requests are still in that buffer. sndbuf must
573 * also be large enough that there is enough space
574 * for one reply per thread.
576 svc_sock_setbufsize(svsk->sk_sock,
577 (serv->sv_nrthreads+3) * serv->sv_bufsz,
578 (serv->sv_nrthreads+3) * serv->sv_bufsz);
580 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
581 svc_sock_received(svsk);
582 return svc_deferred_recv(rqstp);
585 clear_bit(SK_DATA, &svsk->sk_flags);
586 while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
587 if (err == -EAGAIN) {
588 svc_sock_received(svsk);
591 /* possibly an icmp error */
592 dprintk("svc: recvfrom returned error %d\n", -err);
594 if (skb->stamp.tv_sec == 0) {
595 skb->stamp.tv_sec = xtime.tv_sec;
596 skb->stamp.tv_usec = xtime.tv_nsec * 1000;
597 /* Don't enable netstamp, sunrpc doesn't
598 need that much accuracy */
600 svsk->sk_sk->sk_stamp = skb->stamp;
601 set_bit(SK_DATA, &svsk->sk_flags); /* there may be more data... */
604 * Maybe more packets - kick another thread ASAP.
606 svc_sock_received(svsk);
608 len = skb->len - sizeof(struct udphdr);
609 rqstp->rq_arg.len = len;
611 rqstp->rq_prot = IPPROTO_UDP;
613 /* Get sender address */
614 rqstp->rq_addr.sin_family = AF_INET;
615 rqstp->rq_addr.sin_port = skb->h.uh->source;
616 rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr;
617 rqstp->rq_daddr = skb->nh.iph->daddr;
619 if (skb_is_nonlinear(skb)) {
620 /* we have to copy */
622 if (csum_partial_copy_to_xdr(&rqstp->rq_arg, skb)) {
625 skb_free_datagram(svsk->sk_sk, skb);
629 skb_free_datagram(svsk->sk_sk, skb);
631 /* we can use it in-place */
632 rqstp->rq_arg.head[0].iov_base = skb->data + sizeof(struct udphdr);
633 rqstp->rq_arg.head[0].iov_len = len;
634 if (skb->ip_summed != CHECKSUM_UNNECESSARY) {
635 if ((unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum))) {
636 skb_free_datagram(svsk->sk_sk, skb);
639 skb->ip_summed = CHECKSUM_UNNECESSARY;
641 rqstp->rq_skbuff = skb;
644 rqstp->rq_arg.page_base = 0;
645 if (len <= rqstp->rq_arg.head[0].iov_len) {
646 rqstp->rq_arg.head[0].iov_len = len;
647 rqstp->rq_arg.page_len = 0;
649 rqstp->rq_arg.page_len = len - rqstp->rq_arg.head[0].iov_len;
650 rqstp->rq_argused += (rqstp->rq_arg.page_len + PAGE_SIZE - 1)/ PAGE_SIZE;
654 serv->sv_stats->netudpcnt++;
660 svc_udp_sendto(struct svc_rqst *rqstp)
664 error = svc_sendto(rqstp, &rqstp->rq_res);
665 if (error == -ECONNREFUSED)
666 /* ICMP error on earlier request. */
667 error = svc_sendto(rqstp, &rqstp->rq_res);
673 svc_udp_init(struct svc_sock *svsk)
675 svsk->sk_sk->sk_data_ready = svc_udp_data_ready;
676 svsk->sk_sk->sk_write_space = svc_write_space;
677 svsk->sk_recvfrom = svc_udp_recvfrom;
678 svsk->sk_sendto = svc_udp_sendto;
680 /* initialise setting must have enough space to
681 * receive and respond to one request.
682 * svc_udp_recvfrom will re-adjust if necessary
684 svc_sock_setbufsize(svsk->sk_sock,
685 3 * svsk->sk_server->sv_bufsz,
686 3 * svsk->sk_server->sv_bufsz);
688 set_bit(SK_DATA, &svsk->sk_flags); /* might have come in before data_ready set up */
689 set_bit(SK_CHNGBUF, &svsk->sk_flags);
693 * A data_ready event on a listening socket means there's a connection
694 * pending. Do not use state_change as a substitute for it.
697 svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
699 struct svc_sock *svsk;
701 dprintk("svc: socket %p TCP (listen) state change %d\n",
704 if (sk->sk_state != TCP_LISTEN) {
706 * This callback may called twice when a new connection
707 * is established as a child socket inherits everything
708 * from a parent LISTEN socket.
709 * 1) data_ready method of the parent socket will be called
710 * when one of child sockets become ESTABLISHED.
711 * 2) data_ready method of the child socket may be called
712 * when it receives data before the socket is accepted.
713 * In case of 2, we should ignore it silently.
717 if (!(svsk = (struct svc_sock *) sk->sk_user_data)) {
718 printk("svc: socket %p: no user data\n", sk);
721 set_bit(SK_CONN, &svsk->sk_flags);
722 svc_sock_enqueue(svsk);
724 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
725 wake_up_interruptible_all(sk->sk_sleep);
729 * A state change on a connected socket means it's dying or dead.
732 svc_tcp_state_change(struct sock *sk)
734 struct svc_sock *svsk;
736 dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n",
737 sk, sk->sk_state, sk->sk_user_data);
739 if (!(svsk = (struct svc_sock *) sk->sk_user_data)) {
740 printk("svc: socket %p: no user data\n", sk);
743 set_bit(SK_CLOSE, &svsk->sk_flags);
744 svc_sock_enqueue(svsk);
746 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
747 wake_up_interruptible_all(sk->sk_sleep);
751 svc_tcp_data_ready(struct sock *sk, int count)
753 struct svc_sock * svsk;
755 dprintk("svc: socket %p TCP data ready (svsk %p)\n",
756 sk, sk->sk_user_data);
757 if (!(svsk = (struct svc_sock *)(sk->sk_user_data)))
759 set_bit(SK_DATA, &svsk->sk_flags);
760 svc_sock_enqueue(svsk);
762 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
763 wake_up_interruptible(sk->sk_sleep);
767 * Accept a TCP connection
770 svc_tcp_accept(struct svc_sock *svsk)
772 struct sockaddr_in sin;
773 struct svc_serv *serv = svsk->sk_server;
774 struct socket *sock = svsk->sk_sock;
775 struct socket *newsock;
776 struct proto_ops *ops;
777 struct svc_sock *newsvsk;
780 dprintk("svc: tcp_accept %p sock %p\n", svsk, sock);
784 err = sock_create_lite(PF_INET, SOCK_STREAM, IPPROTO_TCP, &newsock);
787 printk(KERN_WARNING "%s: no more sockets!\n",
792 dprintk("svc: tcp_accept %p allocated\n", newsock);
793 newsock->ops = ops = sock->ops;
795 clear_bit(SK_CONN, &svsk->sk_flags);
796 if ((err = ops->accept(sock, newsock, O_NONBLOCK)) < 0) {
797 if (err != -EAGAIN && net_ratelimit())
798 printk(KERN_WARNING "%s: accept failed (err %d)!\n",
799 serv->sv_name, -err);
800 goto failed; /* aborted connection or whatever */
802 set_bit(SK_CONN, &svsk->sk_flags);
803 svc_sock_enqueue(svsk);
806 err = ops->getname(newsock, (struct sockaddr *) &sin, &slen, 1);
809 printk(KERN_WARNING "%s: peername failed (err %d)!\n",
810 serv->sv_name, -err);
811 goto failed; /* aborted connection or whatever */
814 /* Ideally, we would want to reject connections from unauthorized
815 * hosts here, but when we get encription, the IP of the host won't
816 * tell us anything. For now just warn about unpriv connections.
818 if (ntohs(sin.sin_port) >= 1024) {
820 "%s: connect from unprivileged port: %u.%u.%u.%u:%d\n",
822 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
825 dprintk("%s: connect from %u.%u.%u.%u:%04x\n", serv->sv_name,
826 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
828 /* make sure that a write doesn't block forever when
831 newsock->sk->sk_sndtimeo = HZ*30;
833 if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 0)))
837 /* make sure that we don't have too many active connections.
838 * If we have, something must be dropped.
840 * There's no point in trying to do random drop here for
841 * DoS prevention. The NFS clients does 1 reconnect in 15
842 * seconds. An attacker can easily beat that.
844 * The only somewhat efficient mechanism would be if drop
845 * old connections from the same IP first. But right now
846 * we don't even record the client IP in svc_sock.
848 if (serv->sv_tmpcnt > (serv->sv_nrthreads+3)*20) {
849 struct svc_sock *svsk = NULL;
850 spin_lock_bh(&serv->sv_lock);
851 if (!list_empty(&serv->sv_tempsocks)) {
852 if (net_ratelimit()) {
853 /* Try to help the admin */
854 printk(KERN_NOTICE "%s: too many open TCP "
855 "sockets, consider increasing the "
856 "number of nfsd threads\n",
858 printk(KERN_NOTICE "%s: last TCP connect from "
861 NIPQUAD(sin.sin_addr.s_addr),
862 ntohs(sin.sin_port));
865 * Always select the oldest socket. It's not fair,
868 svsk = list_entry(serv->sv_tempsocks.prev,
871 set_bit(SK_CLOSE, &svsk->sk_flags);
874 spin_unlock_bh(&serv->sv_lock);
877 svc_sock_enqueue(svsk);
884 serv->sv_stats->nettcpconn++;
889 sock_release(newsock);
894 * Receive data from a TCP socket.
897 svc_tcp_recvfrom(struct svc_rqst *rqstp)
899 struct svc_sock *svsk = rqstp->rq_sock;
900 struct svc_serv *serv = svsk->sk_server;
902 struct iovec vec[RPCSVC_MAXPAGES];
905 dprintk("svc: tcp_recv %p data %d conn %d close %d\n",
906 svsk, test_bit(SK_DATA, &svsk->sk_flags),
907 test_bit(SK_CONN, &svsk->sk_flags),
908 test_bit(SK_CLOSE, &svsk->sk_flags));
910 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
911 svc_sock_received(svsk);
912 return svc_deferred_recv(rqstp);
915 if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
916 svc_delete_socket(svsk);
920 if (test_bit(SK_CONN, &svsk->sk_flags)) {
921 svc_tcp_accept(svsk);
922 svc_sock_received(svsk);
926 if (test_and_clear_bit(SK_CHNGBUF, &svsk->sk_flags))
927 /* sndbuf needs to have room for one request
928 * per thread, otherwise we can stall even when the
929 * network isn't a bottleneck.
930 * rcvbuf just needs to be able to hold a few requests.
931 * Normally they will be removed from the queue
932 * as soon a a complete request arrives.
934 svc_sock_setbufsize(svsk->sk_sock,
935 (serv->sv_nrthreads+3) * serv->sv_bufsz,
938 clear_bit(SK_DATA, &svsk->sk_flags);
940 /* Receive data. If we haven't got the record length yet, get
941 * the next four bytes. Otherwise try to gobble up as much as
942 * possible up to the complete record length.
944 if (svsk->sk_tcplen < 4) {
945 unsigned long want = 4 - svsk->sk_tcplen;
948 iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen;
950 if ((len = svc_recvfrom(rqstp, &iov, 1, want)) < 0)
952 svsk->sk_tcplen += len;
955 dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
957 svc_sock_received(svsk);
958 return -EAGAIN; /* record header not complete */
961 svsk->sk_reclen = ntohl(svsk->sk_reclen);
962 if (!(svsk->sk_reclen & 0x80000000)) {
963 /* FIXME: technically, a record can be fragmented,
964 * and non-terminal fragments will not have the top
965 * bit set in the fragment length header.
966 * But apparently no known nfs clients send fragmented
968 printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (non-terminal)\n",
969 (unsigned long) svsk->sk_reclen);
972 svsk->sk_reclen &= 0x7fffffff;
973 dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen);
974 if (svsk->sk_reclen > serv->sv_bufsz) {
975 printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (large)\n",
976 (unsigned long) svsk->sk_reclen);
981 /* Check whether enough data is available */
982 len = svc_recv_available(svsk);
986 if (len < svsk->sk_reclen) {
987 dprintk("svc: incomplete TCP record (%d of %d)\n",
988 len, svsk->sk_reclen);
989 svc_sock_received(svsk);
990 return -EAGAIN; /* record not complete */
992 len = svsk->sk_reclen;
993 set_bit(SK_DATA, &svsk->sk_flags);
995 vec[0] = rqstp->rq_arg.head[0];
999 vec[pnum].iov_base = page_address(rqstp->rq_argpages[rqstp->rq_argused++]);
1000 vec[pnum].iov_len = PAGE_SIZE;
1005 /* Now receive data */
1006 len = svc_recvfrom(rqstp, vec, pnum, len);
1010 dprintk("svc: TCP complete record (%d bytes)\n", len);
1011 rqstp->rq_arg.len = len;
1012 rqstp->rq_arg.page_base = 0;
1013 if (len <= rqstp->rq_arg.head[0].iov_len) {
1014 rqstp->rq_arg.head[0].iov_len = len;
1015 rqstp->rq_arg.page_len = 0;
1017 rqstp->rq_arg.page_len = len - rqstp->rq_arg.head[0].iov_len;
1020 rqstp->rq_skbuff = 0;
1021 rqstp->rq_prot = IPPROTO_TCP;
1023 /* Reset TCP read info */
1024 svsk->sk_reclen = 0;
1025 svsk->sk_tcplen = 0;
1027 svc_sock_received(svsk);
1029 serv->sv_stats->nettcpcnt++;
1034 svc_delete_socket(svsk);
1038 if (len == -EAGAIN) {
1039 dprintk("RPC: TCP recvfrom got EAGAIN\n");
1040 svc_sock_received(svsk);
1042 printk(KERN_NOTICE "%s: recvfrom returned errno %d\n",
1043 svsk->sk_server->sv_name, -len);
1044 svc_sock_received(svsk);
1051 * Send out data on TCP socket.
1054 svc_tcp_sendto(struct svc_rqst *rqstp)
1056 struct xdr_buf *xbufp = &rqstp->rq_res;
1060 /* Set up the first element of the reply iovec.
1061 * Any other iovecs that may be in use have been taken
1062 * care of by the server implementation itself.
1064 reclen = htonl(0x80000000|((xbufp->len ) - 4));
1065 memcpy(xbufp->head[0].iov_base, &reclen, 4);
1067 if (test_bit(SK_DEAD, &rqstp->rq_sock->sk_flags))
1070 sent = svc_sendto(rqstp, &rqstp->rq_res);
1071 if (sent != xbufp->len) {
1072 printk(KERN_NOTICE "rpc-srv/tcp: %s: %s %d when sending %d bytes - shutting down socket\n",
1073 rqstp->rq_sock->sk_server->sv_name,
1074 (sent<0)?"got error":"sent only",
1076 svc_delete_socket(rqstp->rq_sock);
1083 svc_tcp_init(struct svc_sock *svsk)
1085 struct sock *sk = svsk->sk_sk;
1086 struct tcp_opt *tp = tcp_sk(sk);
1088 svsk->sk_recvfrom = svc_tcp_recvfrom;
1089 svsk->sk_sendto = svc_tcp_sendto;
1091 if (sk->sk_state == TCP_LISTEN) {
1092 dprintk("setting up TCP socket for listening\n");
1093 sk->sk_data_ready = svc_tcp_listen_data_ready;
1094 set_bit(SK_CONN, &svsk->sk_flags);
1096 dprintk("setting up TCP socket for reading\n");
1097 sk->sk_state_change = svc_tcp_state_change;
1098 sk->sk_data_ready = svc_tcp_data_ready;
1099 sk->sk_write_space = svc_write_space;
1101 svsk->sk_reclen = 0;
1102 svsk->sk_tcplen = 0;
1104 tp->nonagle = 1; /* disable Nagle's algorithm */
1106 /* initialise setting must have enough space to
1107 * receive and respond to one request.
1108 * svc_tcp_recvfrom will re-adjust if necessary
1110 svc_sock_setbufsize(svsk->sk_sock,
1111 3 * svsk->sk_server->sv_bufsz,
1112 3 * svsk->sk_server->sv_bufsz);
1114 set_bit(SK_CHNGBUF, &svsk->sk_flags);
1115 set_bit(SK_DATA, &svsk->sk_flags);
1116 if (sk->sk_state != TCP_ESTABLISHED)
1117 set_bit(SK_CLOSE, &svsk->sk_flags);
1122 svc_sock_update_bufs(struct svc_serv *serv)
1125 * The number of server threads has changed. Update
1126 * rcvbuf and sndbuf accordingly on all sockets
1128 struct list_head *le;
1130 spin_lock_bh(&serv->sv_lock);
1131 list_for_each(le, &serv->sv_permsocks) {
1132 struct svc_sock *svsk =
1133 list_entry(le, struct svc_sock, sk_list);
1134 set_bit(SK_CHNGBUF, &svsk->sk_flags);
1136 list_for_each(le, &serv->sv_tempsocks) {
1137 struct svc_sock *svsk =
1138 list_entry(le, struct svc_sock, sk_list);
1139 set_bit(SK_CHNGBUF, &svsk->sk_flags);
1141 spin_unlock_bh(&serv->sv_lock);
1145 * Receive the next request on any socket.
1148 svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout)
1150 struct svc_sock *svsk =NULL;
1153 struct xdr_buf *arg;
1154 DECLARE_WAITQUEUE(wait, current);
1156 dprintk("svc: server %p waiting for data (to = %ld)\n",
1161 "svc_recv: service %p, socket not NULL!\n",
1163 if (waitqueue_active(&rqstp->rq_wait))
1165 "svc_recv: service %p, wait queue active!\n",
1168 /* Initialize the buffers */
1169 /* first reclaim pages that were moved to response list */
1170 svc_pushback_allpages(rqstp);
1172 /* now allocate needed pages. If we get a failure, sleep briefly */
1173 pages = 2 + (serv->sv_bufsz + PAGE_SIZE -1) / PAGE_SIZE;
1174 while (rqstp->rq_arghi < pages) {
1175 struct page *p = alloc_page(GFP_KERNEL);
1177 set_current_state(TASK_UNINTERRUPTIBLE);
1178 schedule_timeout(HZ/2);
1181 rqstp->rq_argpages[rqstp->rq_arghi++] = p;
1184 /* Make arg->head point to first page and arg->pages point to rest */
1185 arg = &rqstp->rq_arg;
1186 arg->head[0].iov_base = page_address(rqstp->rq_argpages[0]);
1187 arg->head[0].iov_len = PAGE_SIZE;
1188 rqstp->rq_argused = 1;
1189 arg->pages = rqstp->rq_argpages + 1;
1191 /* save at least one page for response */
1192 arg->page_len = (pages-2)*PAGE_SIZE;
1193 arg->len = (pages-1)*PAGE_SIZE;
1194 arg->tail[0].iov_len = 0;
1199 spin_lock_bh(&serv->sv_lock);
1200 if (!list_empty(&serv->sv_tempsocks)) {
1201 svsk = list_entry(serv->sv_tempsocks.next,
1202 struct svc_sock, sk_list);
1203 /* apparently the "standard" is that clients close
1204 * idle connections after 5 minutes, servers after
1206 * http://www.connectathon.org/talks96/nfstcp.pdf
1208 if (get_seconds() - svsk->sk_lastrecv < 6*60
1209 || test_bit(SK_BUSY, &svsk->sk_flags))
1213 set_bit(SK_BUSY, &svsk->sk_flags);
1214 set_bit(SK_CLOSE, &svsk->sk_flags);
1215 rqstp->rq_sock = svsk;
1217 } else if ((svsk = svc_sock_dequeue(serv)) != NULL) {
1218 rqstp->rq_sock = svsk;
1220 rqstp->rq_reserved = serv->sv_bufsz;
1221 svsk->sk_reserved += rqstp->rq_reserved;
1223 /* No data pending. Go to sleep */
1224 svc_serv_enqueue(serv, rqstp);
1227 * We have to be able to interrupt this wait
1228 * to bring down the daemons ...
1230 set_current_state(TASK_INTERRUPTIBLE);
1231 add_wait_queue(&rqstp->rq_wait, &wait);
1232 spin_unlock_bh(&serv->sv_lock);
1234 schedule_timeout(timeout);
1236 if (current->flags & PF_FREEZE)
1237 refrigerator(PF_FREEZE);
1239 spin_lock_bh(&serv->sv_lock);
1240 remove_wait_queue(&rqstp->rq_wait, &wait);
1242 if (!(svsk = rqstp->rq_sock)) {
1243 svc_serv_dequeue(serv, rqstp);
1244 spin_unlock_bh(&serv->sv_lock);
1245 dprintk("svc: server %p, no data yet\n", rqstp);
1246 return signalled()? -EINTR : -EAGAIN;
1249 spin_unlock_bh(&serv->sv_lock);
1251 dprintk("svc: server %p, socket %p, inuse=%d\n",
1252 rqstp, svsk, svsk->sk_inuse);
1253 len = svsk->sk_recvfrom(rqstp);
1254 dprintk("svc: got len=%d\n", len);
1256 /* No data, incomplete (TCP) read, or accept() */
1257 if (len == 0 || len == -EAGAIN) {
1258 svc_sock_release(rqstp);
1261 svsk->sk_lastrecv = get_seconds();
1262 if (test_bit(SK_TEMP, &svsk->sk_flags)) {
1263 /* push active sockets to end of list */
1264 spin_lock_bh(&serv->sv_lock);
1265 if (!list_empty(&svsk->sk_list))
1266 list_move_tail(&svsk->sk_list, &serv->sv_tempsocks);
1267 spin_unlock_bh(&serv->sv_lock);
1270 rqstp->rq_secure = ntohs(rqstp->rq_addr.sin_port) < 1024;
1271 rqstp->rq_chandle.defer = svc_defer;
1274 serv->sv_stats->netcnt++;
1282 svc_drop(struct svc_rqst *rqstp)
1284 dprintk("svc: socket %p dropped request\n", rqstp->rq_sock);
1285 svc_sock_release(rqstp);
1289 * Return reply to client.
1292 svc_send(struct svc_rqst *rqstp)
1294 struct svc_sock *svsk;
1298 if ((svsk = rqstp->rq_sock) == NULL) {
1299 printk(KERN_WARNING "NULL socket pointer in %s:%d\n",
1300 __FILE__, __LINE__);
1304 /* release the receive skb before sending the reply */
1305 svc_release_skb(rqstp);
1307 /* calculate over-all length */
1308 xb = & rqstp->rq_res;
1309 xb->len = xb->head[0].iov_len +
1311 xb->tail[0].iov_len;
1313 /* Grab svsk->sk_sem to serialize outgoing data. */
1314 down(&svsk->sk_sem);
1315 if (test_bit(SK_DEAD, &svsk->sk_flags))
1318 len = svsk->sk_sendto(rqstp);
1320 svc_sock_release(rqstp);
1322 if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
1328 * Initialize socket for RPC use and create svc_sock struct
1329 * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF.
1331 static struct svc_sock *
1332 svc_setup_socket(struct svc_serv *serv, struct socket *sock,
1333 int *errp, int pmap_register)
1335 struct svc_sock *svsk;
1338 dprintk("svc: svc_setup_socket %p\n", sock);
1339 if (!(svsk = kmalloc(sizeof(*svsk), GFP_KERNEL))) {
1343 memset(svsk, 0, sizeof(*svsk));
1347 /* Register socket with portmapper */
1348 if (*errp >= 0 && pmap_register)
1349 *errp = svc_register(serv, inet->sk_protocol,
1350 ntohs(inet_sk(inet)->sport));
1357 set_bit(SK_BUSY, &svsk->sk_flags);
1358 inet->sk_user_data = svsk;
1359 svsk->sk_sock = sock;
1361 svsk->sk_ostate = inet->sk_state_change;
1362 svsk->sk_odata = inet->sk_data_ready;
1363 svsk->sk_owspace = inet->sk_write_space;
1364 svsk->sk_server = serv;
1365 svsk->sk_lastrecv = get_seconds();
1366 INIT_LIST_HEAD(&svsk->sk_deferred);
1367 INIT_LIST_HEAD(&svsk->sk_ready);
1368 sema_init(&svsk->sk_sem, 1);
1370 /* Initialize the socket */
1371 if (sock->type == SOCK_DGRAM)
1376 spin_lock_bh(&serv->sv_lock);
1377 if (!pmap_register) {
1378 set_bit(SK_TEMP, &svsk->sk_flags);
1379 list_add(&svsk->sk_list, &serv->sv_tempsocks);
1382 clear_bit(SK_TEMP, &svsk->sk_flags);
1383 list_add(&svsk->sk_list, &serv->sv_permsocks);
1385 spin_unlock_bh(&serv->sv_lock);
1387 dprintk("svc: svc_setup_socket created %p (inet %p)\n",
1390 clear_bit(SK_BUSY, &svsk->sk_flags);
1391 svc_sock_enqueue(svsk);
1396 * Create socket for RPC service.
1399 svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1401 struct svc_sock *svsk;
1402 struct socket *sock;
1406 dprintk("svc: svc_create_socket(%s, %d, %u.%u.%u.%u:%d)\n",
1407 serv->sv_program->pg_name, protocol,
1408 NIPQUAD(sin->sin_addr.s_addr),
1409 ntohs(sin->sin_port));
1411 if (protocol != IPPROTO_UDP && protocol != IPPROTO_TCP) {
1412 printk(KERN_WARNING "svc: only UDP and TCP "
1413 "sockets supported\n");
1416 type = (protocol == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM;
1418 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0)
1422 if (type == SOCK_STREAM)
1423 sock->sk->sk_reuse = 1; /* allow address reuse */
1424 error = sock->ops->bind(sock, (struct sockaddr *) sin,
1430 if (protocol == IPPROTO_TCP) {
1431 if ((error = sock->ops->listen(sock, 64)) < 0)
1435 if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL)
1439 dprintk("svc: svc_create_socket error = %d\n", -error);
1445 * Remove a dead socket
1448 svc_delete_socket(struct svc_sock *svsk)
1450 struct svc_serv *serv;
1453 dprintk("svc: svc_delete_socket(%p)\n", svsk);
1455 serv = svsk->sk_server;
1458 sk->sk_state_change = svsk->sk_ostate;
1459 sk->sk_data_ready = svsk->sk_odata;
1460 sk->sk_write_space = svsk->sk_owspace;
1462 spin_lock_bh(&serv->sv_lock);
1464 list_del_init(&svsk->sk_list);
1465 list_del_init(&svsk->sk_ready);
1466 if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags))
1467 if (test_bit(SK_TEMP, &svsk->sk_flags))
1470 if (!svsk->sk_inuse) {
1471 spin_unlock_bh(&serv->sv_lock);
1472 sock_release(svsk->sk_sock);
1475 spin_unlock_bh(&serv->sv_lock);
1476 dprintk(KERN_NOTICE "svc: server socket destroy delayed\n");
1477 /* svsk->sk_server = NULL; */
1482 * Make a socket for nfsd and lockd
1485 svc_makesock(struct svc_serv *serv, int protocol, unsigned short port)
1487 struct sockaddr_in sin;
1489 dprintk("svc: creating socket proto = %d\n", protocol);
1490 sin.sin_family = AF_INET;
1491 sin.sin_addr.s_addr = INADDR_ANY;
1492 sin.sin_port = htons(port);
1493 return svc_create_socket(serv, protocol, &sin);
1497 * Handle defer and revisit of requests
1500 static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
1502 struct svc_deferred_req *dr = container_of(dreq, struct svc_deferred_req, handle);
1503 struct svc_serv *serv = dreq->owner;
1504 struct svc_sock *svsk;
1507 svc_sock_put(dr->svsk);
1511 dprintk("revisit queued\n");
1514 spin_lock(&serv->sv_lock);
1515 list_add(&dr->handle.recent, &svsk->sk_deferred);
1516 spin_unlock(&serv->sv_lock);
1517 set_bit(SK_DEFERRED, &svsk->sk_flags);
1518 svc_sock_enqueue(svsk);
1522 static struct cache_deferred_req *
1523 svc_defer(struct cache_req *req)
1525 struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle);
1526 int size = sizeof(struct svc_deferred_req) + (rqstp->rq_arg.len);
1527 struct svc_deferred_req *dr;
1529 if (rqstp->rq_arg.page_len)
1530 return NULL; /* if more than a page, give up FIXME */
1531 if (rqstp->rq_deferred) {
1532 dr = rqstp->rq_deferred;
1533 rqstp->rq_deferred = NULL;
1535 int skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len;
1536 /* FIXME maybe discard if size too large */
1537 dr = kmalloc(size, GFP_KERNEL);
1541 dr->handle.owner = rqstp->rq_server;
1542 dr->prot = rqstp->rq_prot;
1543 dr->addr = rqstp->rq_addr;
1544 dr->argslen = rqstp->rq_arg.len >> 2;
1545 memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2);
1547 spin_lock(&rqstp->rq_server->sv_lock);
1548 rqstp->rq_sock->sk_inuse++;
1549 dr->svsk = rqstp->rq_sock;
1550 spin_unlock(&rqstp->rq_server->sv_lock);
1552 dr->handle.revisit = svc_revisit;
1557 * recv data from a deferred request into an active one
1559 static int svc_deferred_recv(struct svc_rqst *rqstp)
1561 struct svc_deferred_req *dr = rqstp->rq_deferred;
1563 rqstp->rq_arg.head[0].iov_base = dr->args;
1564 rqstp->rq_arg.head[0].iov_len = dr->argslen<<2;
1565 rqstp->rq_arg.page_len = 0;
1566 rqstp->rq_arg.len = dr->argslen<<2;
1567 rqstp->rq_prot = dr->prot;
1568 rqstp->rq_addr = dr->addr;
1569 return dr->argslen<<2;
1573 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk)
1575 struct svc_deferred_req *dr = NULL;
1576 struct svc_serv *serv = svsk->sk_server;
1578 if (!test_bit(SK_DEFERRED, &svsk->sk_flags))
1580 spin_lock(&serv->sv_lock);
1581 clear_bit(SK_DEFERRED, &svsk->sk_flags);
1582 if (!list_empty(&svsk->sk_deferred)) {
1583 dr = list_entry(svsk->sk_deferred.next,
1584 struct svc_deferred_req,
1586 list_del_init(&dr->handle.recent);
1587 set_bit(SK_DEFERRED, &svsk->sk_flags);
1589 spin_unlock(&serv->sv_lock);