Skip to content

[BUG] State Transition from eCONNECT_SYN to eCLOSE_WAIT? #1301

@Fr3ya

Description

@Fr3ya

Describe the bug
The TCP state machine incorrectly transitions from eCONNECT_SYN (SYN-SENT) to eCLOSE_WAIT in error scenarios. Per RFC 793, connections that fail during establishment should transition to eCLOSED, not eCLOSE_WAIT.

if( pxSocket->u.xTCP.eTCPState != eCONNECT_SYN )
{
/* The connection is in a state other than SYN. */
pxNetworkBuffer = NULL;
/* prvTCPSendRepeated() will only create a network buffer if necessary,
* i.e. when data must be sent to the peer. */
lResult = prvTCPSendRepeated( pxSocket, &pxNetworkBuffer );
if( pxNetworkBuffer != NULL )
{
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
}
}
else
{
if( pxSocket->u.xTCP.ucRepCount >= 3U )
{
/* The connection is in the SYN status. The packet will be repeated
* to most 3 times. When there is no response, the socket get the
* status 'eCLOSE_WAIT'. */
FreeRTOS_debug_printf( ( "Connect: giving up %xip:%u\n",
( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, /* IP address of remote machine. */
pxSocket->u.xTCP.usRemotePort ) ); /* Port on remote machine. */
vTCPStateChange( pxSocket, eCLOSE_WAIT );

RFC 793 Compliance Issue

RFC 793 specifies that SYN-SENT state errors/timeouts should transition to CLOSED, not CLOSE-WAIT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions