fix(endpoint): route shared-socket QUIC packets by destination CID#89
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates packet routing for endpoints that share a single UDP socket between client and server lsquic engines, by extracting the destination Connection ID (DCID) from incoming QUIC packets and forwarding each packet to the owning engine when possible. This addresses cross-dial scenarios where both endpoints are simultaneously dialing and accepting on the same underlying listener socket.
Changes:
- Added CID tracking to
QuicContextand wired lsquic CID lifecycle callbacks (new/live/old SCIDs) to maintain an owned-CID set per engine. - Implemented DCID extraction in
QuicEndpoint.receiveDatagramand routed datagrams to the client/server context that owns the destination CID (fallback: deliver to both for unknown CIDs/handshakes). - Added a cross-dial regression test covering concurrent bidirectional dialing between two endpoints.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/test_connection.nim |
Adds a new cross-dial test to reproduce/guard shared-socket routing issues. |
lsquic/endpoint.nim |
Parses packet DCID and routes datagrams to the owning context instead of always delivering to both. |
lsquic/context/context.nim |
Introduces CID keying/tracking, plus lsquic CID update callbacks and helpers (ownsCid, trackConnectionCid). |
lsquic/context/client.nim |
Initializes CID tracking, registers CID update callbacks, and tracks the initial connection CID on dial. |
lsquic/context/server.nim |
Initializes CID tracking, registers CID update callbacks, and tracks the initial connection CID on accept. |
lsquic/context/io.nim |
Adds trace logging around packet input/output and send failures for debugging routing/IO behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
richard-ramos
force-pushed
the
codex/quic-shared-socket-cid-routing
branch
from
June 3, 2026 01:30
e3418f3 to
dba97fe
Compare
richard-ramos
force-pushed
the
codex/quic-shared-socket-cid-routing
branch
from
June 3, 2026 01:32
dba97fe to
3894eae
Compare
richard-ramos
force-pushed
the
codex/quic-shared-socket-cid-routing
branch
from
June 3, 2026 01:42
3894eae to
d2275fc
Compare
richard-ramos
force-pushed
the
codex/quic-shared-socket-cid-routing
branch
from
June 3, 2026 02:10
d2275fc to
93f5ca5
Compare
richard-ramos
marked this pull request as ready for review
June 3, 2026 02:13
richard-ramos
requested review from
gmelodie and
vladopajic
and removed request for
a team
June 3, 2026 02:13
richard-ramos
force-pushed
the
codex/quic-shared-socket-cid-routing
branch
from
June 3, 2026 02:22
4e1ef3e to
38d4355
Compare
vladopajic
approved these changes
Jun 3, 2026
gmelodie
approved these changes
Jun 3, 2026
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.
Summary
This PR makes QUIC endpoints that share a UDP socket route received packets by destination connection ID before handing them to an lsquic engine. Known CIDs are tracked from lsquic callbacks and connection creation, while unknown Initial packets are routed to the server context so new inbound connections can still be accepted.
It also defines
lsquic_cid_tin the prelude and excludes it from Futhark generation to avoid the invalid generated aligned layout.