All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tcp: fix problems when tcp_fin_timeout is greater than 60
@ 2013-02-12 12:49 Toshiaki Makita
  2013-02-12 12:52 ` [PATCH 1/2] tcp: fix too short FIN_WAIT2 time out Toshiaki Makita
  0 siblings, 1 reply; 6+ messages in thread
From: Toshiaki Makita @ 2013-02-12 12:49 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: Toshiaki Makita

Hi all,

I found a strange behavior of FIN_WAIT2 timer when tcp_fin_timeout is greater
than 60. 

When it is between 60 and 120, if the socket is closed, FIN_WAIT2 keepalive
timer of (tcp_fin_timeout - 60) seconds long starts. After it expires, timewait
timer of (tcp_fin_timeout - 60) seconds long starts again. This takes total time
of (tcp_fin_timeout - 60) * 2 seconds to disappear the FIN_WAIT2 socket, which
is shorter than tcp_fin_timeout.

# sysctl -w net.ipv4.tcp_fin_timeout=63
net.ipv4.tcp_fin_timeout = 63
# while :; do netstat -anot | grep 54321 | grep FIN_WAIT2; sleep 1; done
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   keepalive (2.62/0/0)
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   keepalive (1.59/0/0)
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   keepalive (0.56/0/0)
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   timewait (2.61/0/0)
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   timewait (1.59/0/0)
tcp        0      0 127.0.0.1:43034         127.0.0.1:54321         FIN_WAIT2   timewait (0.56/0/0)

When it is greater than 120, although timewait timer appears to start from
(tcp_fin_timeout - 60), it expires after 60 seconds elapse in practice.

# sysctl -w net.ipv4.tcp_fin_timeout=150
net.ipv4.tcp_fin_timeout = 150
# while :; do netstat -anot | grep 54321 | grep FIN_WAIT2; sleep 1; done
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (90.00/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (88.97/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (87.95/0/0)
...
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (2.76/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (1.73/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   keepalive (0.70/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (89.68/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (88.66/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (87.63/0/0)
...
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (32.21/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (31.18/0/0)
tcp        0      0 127.0.0.1:43036         127.0.0.1:54321         FIN_WAIT2   timewait (30.16/0/0)
(no more messages)

This seems to have been so for many years, but I think this behavior is not
desirable because it is confusing and does not match the documents.

Besides, it is also confusing that netstat shows keepalive timer first, and then
shows timewait timer, even though it is necessary to limit resources for the
orphaned socket.

I made patches that fix these problems.

Toshiaki Makita

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-15  8:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-12 12:49 [PATCH 0/2] tcp: fix problems when tcp_fin_timeout is greater than 60 Toshiaki Makita
2013-02-12 12:52 ` [PATCH 1/2] tcp: fix too short FIN_WAIT2 time out Toshiaki Makita
2013-02-12 12:54   ` [PATCH 2/2] tcp: fix FIN_WAIT2 timer expression in /proc/net/tcp Toshiaki Makita
2013-02-12 14:57     ` Eric Dumazet
2013-02-12 15:13       ` Eric Dumazet
2013-02-15  8:26         ` Toshiaki Makita

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.