Skip to content

fix(connlib): update checksum after setting ECN information#9005

Merged
thomaseizinger merged 2 commits into
mainfrom
fix/update-checksum-after-ecn
May 2, 2025
Merged

fix(connlib): update checksum after setting ECN information#9005
thomaseizinger merged 2 commits into
mainfrom
fix/update-checksum-after-ecn

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented May 2, 2025

Copy link
Copy Markdown
Member

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

@thomaseizinger thomaseizinger requested review from Copilot and jamilbk May 2, 2025 02:21
@vercel

vercel Bot commented May 2, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 2:21am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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() {

Comment thread rust/ip-packet/src/lib.rs
@@ -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),
}

Copilot AI May 2, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@thomaseizinger thomaseizinger added this pull request to the merge queue May 2, 2025
Merged via the queue into main with commit 471483f May 2, 2025
120 checks passed
@thomaseizinger thomaseizinger deleted the fix/update-checksum-after-ecn branch May 2, 2025 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants