]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
tcp: utilize new solisten_clone() and solisten_enqueue()
authorGleb Smirnoff <glebius@FreeBSD.org>
Wed, 10 Aug 2022 18:09:34 +0000 (11:09 -0700)
committerGleb Smirnoff <glebius@FreeBSD.org>
Wed, 10 Aug 2022 18:09:34 +0000 (11:09 -0700)
commit07285bb4c22c026a50f69149d5dae03169b15fe4
tree847d6bae12b7b9baf3f7a726da2b63db12c73d52
parent8f5a0a2e4f315a03caaa2d51efdcf837e303e510
tcp: utilize new solisten_clone() and solisten_enqueue()

This streamlines cloning of a socket from a listener.  Now we do not
drop the inpcb lock during creation of a new socket, do not do useless
state transitions, and put a fully initialized socket+inpcb+tcpcb into
the listen queue.

Before this change, first we would allocate the socket and inpcb+tcpcb via
tcp_usr_attach() as TCPS_CLOSED, link them into global list of pcbs, unlock
pcb and put this onto incomplete queue (see 6f3caa6d815).  Then, after
sonewconn() we would lock it again, transition into TCPS_SYN_RECEIVED,
insert into inpcb hash, finalize initialization of tcpcb.  And then, in
call into tcp_do_segment() and upon transition to TCPS_ESTABLISHED call
soisconnected().  This call would lock the listening socket once again
with a LOR protection sequence and then we would relocate the socket onto
the complete queue and only now it is ready for accept(2).

Reviewed by: rrs, tuexen
Differential revision: https://reviews.freebsd.org/D36064
sys/kern/uipc_socket.c
sys/netinet/tcp_syncache.c
sys/netinet/tcp_usrreq.c
sys/sys/socketvar.h