Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@stevenengler
Copy link
Contributor

@stevenengler stevenengler commented Apr 20, 2025

Shadow assigns a priority to packets, and packets with a lower priority will be sent before other packets. Previously, shadow only assigned a priority to non-empty packets (here meaning containing a payload), and a priority of 0 to other packets. But this meant that empty packets like FIN (with a priority of 0) could be sent before other packets, even if the FIN had a higher sequence number. Shadow seems to have discarded these out-of-order FIN packets. See #3100 for an example.

This MR changes the legacy TCP code to always assign a non-zero priority if the packets has a sequence number, so that they won't be sent out of order. This (edit: partially; see #3100 (comment)) fixes (edit: <text to prevent github from closing the linked issue>) #3100, but there are still a lot of other shutdown-related bugs (see all the disabled tests in src/test/socket/shutdown/test_shutdown.rs), so shutdown() still won't work 100% as expected.

Related: #3558 (I think this MR fixes this shutdown issue as well, but it looks like there are still some other issues.)

@github-actions github-actions bot added Component: Testing Unit and integration tests and frameworks Component: Main Composing the core Shadow executable Component: Build Build/install tools and dependencies labels Apr 20, 2025
@stevenengler stevenengler changed the title Fix packet order of FIN from Fix packet order of FIN from SHUT_WR Apr 20, 2025
@stevenengler stevenengler requested a review from robgjansen April 20, 2025 02:14
@stevenengler stevenengler force-pushed the fix-shutdown branch 2 times, most recently from 1c52d4a to 394d80d Compare April 20, 2025 02:23
@github-actions github-actions bot added the Component: Documentation In-repository documentation, under docs/ label Apr 20, 2025
Copy link
Member

@robgjansen robgjansen left a comment

Choose a reason for hiding this comment

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

Good find!

If only we had a nice Rust TCP stack so we could throw this janky C stack in the trash :D

This test currently fails.
This should fix shadow#3100 and its
associated regression test.

This prevents FIN packets caused by a `SHUT_WR` from being sent before
other packets with a lower sequence number.
@stevenengler
Copy link
Contributor Author

If only we had a nice Rust TCP stack so we could throw this janky C stack in the trash :D

Every time I look at the rust tcp code, I remember how much work still needs to be done. Someday hopefully :)

@stevenengler stevenengler merged commit 76381d6 into shadow:main Apr 24, 2025
25 checks passed
@stevenengler stevenengler deleted the fix-shutdown branch April 24, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Build Build/install tools and dependencies Component: Documentation In-repository documentation, under docs/ Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants