diff mbox

[v2,1/4] tcp: fix too short FIN_WAIT2 time out

Message ID 1363610344.7121.5.camel@ubuntu-vm-makita
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Toshiaki Makita March 18, 2013, 12:39 p.m. UTC
When tcp_fin_timeout is between 60 and 120, a FIN_WAIT2 socket
disappears in (tcp_fin_timeout - 60) * 2 sec, which is shorter
than expected.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 net/ipv4/tcp_timer.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

David Miller March 19, 2013, 1:32 p.m. UTC | #1
From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Date: Mon, 18 Mar 2013 21:39:04 +0900

>  		if (tp->linger2 >= 0) {
> -			const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN;
> -
> -			if (tmo > 0) {
> -				tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
> -				goto out;
> -			}
> +			tcp_time_wait(sk, TCP_FIN_WAIT2, TCP_TIMEWAIT_LEN);
> +			goto out;
>  		}

Well, now you're completely ignoring the user's linger setting.

I really can't take these patches seriously, and will not apply them,
sorry.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Toshiaki Makita March 21, 2013, 11:45 a.m. UTC | #2
On Tue, 2013-03-19 at 09:32 -0400, David Miller wrote:
> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> Date: Mon, 18 Mar 2013 21:39:04 +0900
> 
> >               if (tp->linger2 >= 0) {
> > -                     const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN;
> > -
> > -                     if (tmo > 0) {
> > -                             tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
> > -                             goto out;
> > -                     }
> > +                     tcp_time_wait(sk, TCP_FIN_WAIT2, TCP_TIMEWAIT_LEN);
> > +                     goto out;
> >               }
> 
> Well, now you're completely ignoring the user's linger setting.

If you mention TCP_LINGER2, I don't think I'm ignoring it.
It is taken into account in tcp_rcv_state_process() or tcp_close().
If I'm misunderstanding, I'd be glad if you could point out it.

> 
> I really can't take these patches seriously, and will not apply them,
> sorry.

I think, at least, too short timeout is harmful.
If tcp_fin_timeout is set to 61, it will expire in 2 seconds, which
cause peer to receive unexpected reset by sending fin.
Don't you think there is a problem?

Toshiaki Makita

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index b78aac3..c20e474 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -576,12 +576,8 @@  static void tcp_keepalive_timer (unsigned long data)
 
 	if (sk->sk_state == TCP_FIN_WAIT2 && sock_flag(sk, SOCK_DEAD)) {
 		if (tp->linger2 >= 0) {
-			const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN;
-
-			if (tmo > 0) {
-				tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
-				goto out;
-			}
+			tcp_time_wait(sk, TCP_FIN_WAIT2, TCP_TIMEWAIT_LEN);
+			goto out;
 		}
 		tcp_send_active_reset(sk, GFP_ATOMIC);
 		goto death;