TCP TIME-WAIT bug in Linux 2.2.5 (still there I think)

Vijay G. Bharadwaj (vgb@isr.umd.edu)
Sun, 25 Jul 1999 17:00:25 -0400 (EDT)


Linux 2.2.5 (and I think later versions as well - I can't find a fix in
the patch sets for 2.2 or 2.3) does not ACK a FIN received when in
TIME-WAIT. This leads to connections on the remote host taking longer to
die than they should, and connections on the Linux host remaining in
TIME-WAIT longer than they should.

Scenario:

Host1 (Linux) Host 2 (anything, including Linux)
------------- ----------------------------------
Send FIN, enter FIN-WAIT1

Send ACK of FIN, enter CLOSE-WAIT

Receive ACK of FIN, enter FIN-WAIT2

Send FIN, enter LAST-ACK

Send ACK of FIN, enter TIME-WAIT

(ACK is lost)
Retransmit FIN, stay in LAST_ACK

Receive retransmitted FIN and drop
it (this is in tcp_timewait_process)
and reset 2MSL timer

Retransmit FIN again

.....

and so on, until Host 2 decides to finally give up. The Linux behavior is
in violation of

RFC 793, page 73:

TIME-WAIT STATE

The only thing that can arrive in this state is a retransmission of the
remote FIN. Acknowledge it, and restart the 2 MSL timeout.

A similar thing was fixed in 2.2.7 I think (quick look at patch) but it
does not seem to fix the problem for connections in TIME-WAIT, it is in
tcp_rcv_state_process I think (modifies sequence number check to deal with
retransmitted FIN - I'm not aware what that problem was, I'm just reading
the comment).

I'm a bit rushed the next few days, so sorry I don't have a patch. It is
more than a quick patch because at this place we don't have a socket so we
can't just call tcp_send_ack or something... I can't think of a way out
except to painfully build a complete ACK packet, and that would be ugly. I
hope others have better ideas.

-Vijay

PS - I'm on netdev, but not on linux-kernel, so please cc: accordingly. I
may not check my mail in the next couple of days, so replies may be late
in coming.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/