fix(connlib): update checksum after setting ECN information#9005
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the IP packet functionality to recalculate the checksum after modifying the ECN information. Key changes include updating the checksum immediately after setting the ECN and adding a test to validate that the IPv4 checksum is correct post-modification.
Comments suppressed due to low confidence (1)
rust/ip-packet/src/lib.rs:1138
- [nitpick] The new test covers the IPv4 case, but if ECN is set on IPv6 packets elsewhere, consider adding a complementary test to ensure the checksum (or related behavior) is handled appropriately in that scenario.
fn ip4_checksum_after_ecn_is_correct() {
| @@ -890,6 +890,7 @@ impl IpPacket { | |||
| IpPacket::Ipv4(ip) => ip.ip_header_mut().set_ecn(ecn as u8), | |||
| IpPacket::Ipv6(ip) => ip.header_mut().set_ecn(ecn as u8), | |||
| } | |||
There was a problem hiding this comment.
Consider adding a comment to clarify that update_checksum() is being called for both IPv4 and IPv6 packets, especially since IPv6 typically does not include a header checksum.
Suggested change
| } | |
| } | |
| // Update the checksum for the packet. Note that this is relevant for IPv4 packets, | |
| // as IPv6 does not include a header checksum. The function handles both cases. |
jamilbk
approved these changes
May 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When setting ECN information on an IP packet, the header changes and therefore, we need to update the IP checksum. MacOS attempts to open TCP connections with ECN information but will fallback to non-ECT if it detects packet loss. Failing to update the checksums caused the packet to get dropped at the remote TCP stack and therefore triggered a retransmission on the MacOS side.
Related: #8899