Skip to content

net: tcp: Change SYN FIN to use send_data_timer #90786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

shrek-wang
Copy link
Contributor

The send_queue was used as SYN/FIN packet retransmission. Before the SYN/FIN being ACKed and dequeue-ed, the following packets in the send_queue cannot be sent out. That's why Zephyr had to send a FIN+ACK instead of a duplicated ACK-only in FINWAIT1, CLOSING. In fact, we can take SYN/FIN as kind of data and use the same send_data_timer for retransmission, like other OSes do. This way, the send_queue is simply used for local traffics.
Benefits (in theory):

  1. The code is easier,
  2. TxPkt performance is better after skipping enq/deq send_queue,
  3. The struct tcp{} node is a few bytes smaller, saving memory.

@shrek-wang
Copy link
Contributor Author

@hakehuang , could you please help checking it on the physical boards? Thanks!

Copy link
Collaborator

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, having (in practice) two retransmission timers was indeed pretty confusing, the change looks quite reasonalable, another step in the right direction 👍

@rlubos
Copy link
Collaborator

rlubos commented May 29, 2025

Regarding twister failure - the removed flag is still referenced in the net shell:

conn->in_retransmission, conn->in_connect, conn->in_close,

@hakehuang
Copy link
Collaborator

hakehuang commented May 29, 2025

@hakehuang , could you please help checking it on the physical boards? Thanks!

board testing is OK on mimxrt1060_evk@C, and with max-pro testing, no regression issues found.

@shrek-wang
Copy link
Contributor Author

Regarding twister failure - the removed flag is still referenced in the net shell:

conn->in_retransmission, conn->in_connect, conn->in_close,

Thanks @rlubos , I didn't notice that during my local run. Sorry.
After the change, the 'send_queue' won't be used for all the TCP packets transmission while only for local traffics. If you agree, I'd like to keep the tcp_send_list_cb() there for now and only fix the issue like this:
replace the 'conn->in_retransmission' with 'conn->data_mode == TCP_DATA_MODE_RESEND ? 1 : 0'.
In fact, the SYN/FIN 'in_retransmission' or not can be deduced via checking the TCP State.

The send_queue was used as SYN/FIN packet retransmission. Before
the SYN/FIN being ACKed and dequeue-ed, the following packets in
the send_queue cannot be sent out. That's why Zephyr had to send
a FIN+ACK instead of a duplicated ACK-only in FINWAIT1, CLOSING.
In fact, we can take SYN/FIN as kind of data and use the same
send_data_timer for retransmission, like other OSes do. This way,
the send_queue is simply used for local traffics.
Benefits (in theory):
1. The code is easier,
2. TxPkt performance is better after skipping enq/deq send_queue,
3. The struct tcp{} node is a few bytes smaller, saving memory.

Signed-off-by: Shrek Wang <inet_eman@outlook.com>
Copy link

@rlubos
Copy link
Collaborator

rlubos commented May 30, 2025

Regarding twister failure - the removed flag is still referenced in the net shell:

conn->in_retransmission, conn->in_connect, conn->in_close,

Thanks @rlubos , I didn't notice that during my local run. Sorry. After the change, the 'send_queue' won't be used for all the TCP packets transmission while only for local traffics. If you agree, I'd like to keep the tcp_send_list_cb() there for now and only fix the issue like this: replace the 'conn->in_retransmission' with 'conn->data_mode == TCP_DATA_MODE_RESEND ? 1 : 0'. In fact, the SYN/FIN 'in_retransmission' or not can be deduced via checking the TCP State.

Sounds ok

Copy link
Collaborator

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@kartben kartben merged commit 6e7756a into zephyrproject-rtos:main Jun 2, 2025
27 checks passed
@shrek-wang shrek-wang deleted the tcp_polish branch June 3, 2025 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants