HomeFreeBSD

tcp: fix counter leak for SYN_RCVD state when syncache_socket() fails

Description

tcp: fix counter leak for SYN_RCVD state when syncache_socket() fails

The SYN_RCVD state count is tricky here due to default code path and TFO
being so different. In the default case the count is incremented when a
syncache entry is added to the the database in syncache_insert(). Later
when connection transitions from syncache entry to a socket in
syncache_expand(), this counter is inherited by the tcpcb. If socket or
tcpcb allocation failed in syncache_socket() failed the syncache_expand()
is responsible for decrement. In the TFO case the syncache entry is not
inserted into database and count of SYN_RCVD is first incremented in the
syncache_tfo_expand() after successful socket allocation. Thus, inside
syncache_socket() we can't tell whether we need to decrement in a case of
a failure or not. The caller is responsible for this book keeping.

Fixes: 07285bb4c22c026a50f69149d5dae03169b15fe4
Differential revision: https://reviews.freebsd.org/D37610

Details

Provenance
glebiusAuthored on Dec 14 2022, 3:31 AM
Differential Revision
D37610: tcp: fix counter leak for SYN_RCVD state when syncache_socket() fails
Parents
rG54d65fdd5643: diff: restyle loop a bit
Branches
Unknown
Tags
Unknown