mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
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: 07285bb4c2
Differential revision: https://reviews.freebsd.org/D37610
This commit is contained in:
1 parent
54d65fdd56
commit
5050df3f4a
1 file changed
+3
-2
@@ -1313,9 +1313,10 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
||||
|
||||
*lsop = syncache_socket(sc, *lsop, m);
|
||||
|
||||
if (*lsop == NULL)
|
||||
if (__predict_false(*lsop == NULL)) {
|
||||
TCPSTAT_INC(tcps_sc_aborted);
|
||||
else
|
||||
TCPSTATES_DEC(TCPS_SYN_RECEIVED);
|
||||
} else
|
||||
TCPSTAT_INC(tcps_sc_completed);
|
||||
|
||||
/* how do we find the inp for the new socket? */
|
||||
|
||||
Reference in new issue
Block a user