Commit 69408a2f authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: Make sure an early close on a nfs/tcp connection is handled properly.

From: Hirokazu Takahashi <taka@valinux.co.jp>

In svc_tcp_listen_data_ready we should be waiting for
TCP_LISTEN, not TCP_ESTABLISHED.  The later only worked
by accident.

Also, if a socket is closed as soon as we accept it, we
must shut it down straight away as we will never get a 'close'
event.
parent 74001bcd
......@@ -681,8 +681,17 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
dprintk("svc: socket %p TCP (listen) state change %d\n",
sk, sk->sk_state);
if (sk->sk_state != TCP_ESTABLISHED) {
/* Aborted connection, SYN_RECV or whatever... */
if (sk->sk_state != TCP_LISTEN) {
/*
* This callback may called twice when a new connection
* is established as a child socket inherits everything
* from a parent LISTEN socket.
* 1) data_ready method of the parent socket will be called
* when one of child sockets become ESTABLISHED.
* 2) data_ready method of the child socket may be called
* when it receives data before the socket is accepted.
* In case of 2, we should ignore it silently.
*/
goto out;
}
if (!(svsk = (struct svc_sock *) sk->sk_user_data)) {
......@@ -1060,6 +1069,8 @@ svc_tcp_init(struct svc_sock *svsk)
set_bit(SK_CHNGBUF, &svsk->sk_flags);
set_bit(SK_DATA, &svsk->sk_flags);
if (sk->sk_state != TCP_ESTABLISHED)
set_bit(SK_CLOSE, &svsk->sk_flags);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment