tcp: fix: TCP timewait port reuse rfc compliance 19/34119/5
authorMichal Kalderon <mkalderon@marvell.com>
Sun, 8 Aug 2021 11:30:39 +0000 (04:30 -0700)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 25 Oct 2021 15:46:23 +0000 (15:46 +0000)
commit3effadc66ff8acb2e5c83645faec411de59332c2
tree8fe4e24bb21f471072a48f795f0efd8e0bc2e853
parent3265ec8cb12d94e91a38ac377e78970eb032d88c
tcp: fix: TCP timewait port reuse rfc compliance

This patch provides a fix for early-kill of timewait sockets that is based on
rfc's 1122, 6191.

The following commits provided a solution for port re-use. However, they
are not fully compliant with rfc 1122 4.2.2.13 ( Closing a connection )
and rfc 6191 (Reducing the TIME-WAIT State Using TCP Timestamps)

commit b092b77cf238ba ("tcp: Enable TCP timewait port use") introduced
a significant improvement by enabling TCP timewait port re-use.

commit ee1cb469b2dd ("tcp: fix port reuse with multiple listeners") fixed
usage of the wrong value for connection_index when searching for a
listener, by storing the state in tcp.flags.

Implementation details:
When a SYN is received during time-wait state, the code
checks whether all the requirements for accepting the SYN packet are
met. If they aren't, the SYN can't be accepted and the packet is dropped,
otherwise, connection is deleted and a new connection with same port
is opened.

Type: fix
Signed-off-by: Ofer Heifetz <oferh@marvell.com>
Signed-off-by: Yuval Caduri <cyuval@marvell.com>
Signed-off-by: Michal Kalderon <mkalderon@marvell.com>
Change-Id: I38a33c6e321c760d45ebec9154399e1c90dd0250
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp_input.c