[BUG] Bug State Transition From FIN_WAIT_1.

Open
#1,303 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
networking

Research direction

Start in FreeRTOS_TCP_State_Handling.c, in prvTCPHandleFin and the eFIN_WAIT_1/eFIN_WAIT_2 branches the issue cites (around lines 231-302). Compare the transitions with RFC793 page 74: a FIN that has been ACKed should go to TIME_WAIT, and an unacknowledged FIN should go to CLOSING, not CLOSE_WAIT or LAST_ACK. Done means simultaneous close follows those transitions, and the change is checked against the TCP state tests in the repository.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
The current implementation of the TCP state machine in FreeRTOS_TCP_State_Handling.c does not fully follow RFC793 behavior for connection termination when handling simultaneous close ( both sides send FIN). The stack transitions to CLOSE_WAIT rather than properly handling the CLOSING/TIME_WAIT states as specified by the RFC793.

Specifically, as specified in RFC793 [Page 74], when the state is in FIN-WAIT-1 STATE, it specifies:

If our FIN has been ACKed (perhaps in this segment), then enter TIME-WAIT, start the time-wait timer, turn off the other timers; otherwise, enter the CLOSING state.

When is FIN-WAIT2

Enter the TIME-WAIT state.  Start the time-wait timer, turn off the other timers.

However, In FreeRTOS_TCP_State_Handling.c, when the state is eFIN_WAIT_1 or eFIN_WAIT_2, it goes into the function prvTCPHandleFin. However, the implementation, when FIN is ACKed, it enters to CLOSE_WAIT (Line 302) instead of TIME_WAIT. When not ACKed, the implementation enters into LAST_ACK (Line 273) instead of CLOSING specified.

https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/22c095e9c3bff7773085dd9b061a0013200eadda/source/FreeRTOS_TCP_State_Handling.c#L231-L302

Dominant language
C
Stars
215
Forks
222
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FreeRTOS/FreeRTOS-Plus-TCP

All issues in FreeRTOS/FreeRTOS-Plus-TCP

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.