fix(connlib): never clear ECT from IP packets - #9009
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
thomaseizinger
enabled auto-merge
May 2, 2025 04:47
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves ECN handling in encrypted IP packet tunneling by ensuring that ECN bits are not cleared when not appropriate. Key changes include:
- Making the existing with_ecn function private and introducing a new with_ecn_from_transport function with refined logic.
- Updating tunnel code in both the client and gateway modules to use the new function.
- Adding tests to validate the updated ECN behavior.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rust/ip-packet/src/lib.rs | Introduces with_ecn_from_transport with enhanced ECN logic and accompanying tests. |
| rust/connlib/tunnel/src/lib.rs | Updates tunnel module to correctly call the new ECN handling function. |
Comments suppressed due to low confidence (1)
rust/connlib/tunnel/src/lib.rs:215
- Confirm that all possible ECN cases are covered in the new with_ecn_from_transport logic, to avoid unexpected behavior in production. Ensure thorough testing across diverse ECN scenarios.
.send_tun(packet.with_ecn_from_transport(received.ecn));
thomaseizinger
force-pushed
the
fix/no-clear-ect
branch
from
May 2, 2025 04:55
8b7141a to
3fd4882
Compare
jamilbk
reviewed
May 2, 2025
Co-authored-by: Jamil <jamilbk@users.noreply.github.com> Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
jamilbk
reviewed
May 2, 2025
thomaseizinger
disabled auto-merge
May 2, 2025 05:14
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.
ECN information is helpful to allow the congestion controllers to more easily fine-tune their send and receive windows. When a Firezone Client receives an IP packet where the ECN bits signal an ECN capable transport, we mirror this bit on the UDP datagram that carries the encrypted IP packet.
When receiving a datagram with ECN bits set, the Gateway will then apply these bits to the decrypted IP packet and pass it along towards its destination.
This implementation is unfortunately a bit too naive. Not all devices on the Internet support ECN and therefore, we may receive a datagram that has its ECN bits cleared when the ECN bits on the inner IP packet still signal an ECN capable transport. In this case, we should not override the ECN bits and instead pass the IP packet along as is. Network devices along the path between Gateway and Resource may still use these ECN bits to signal congestion.
We fix this by making the
with_ecnfunction onIpPacketprivate. It is not meant to be used outside of the module. We supersede it with awith_ecn_from_transportfunction that implements the above logic.