Skip to content

fix(endpoint): route shared-socket QUIC packets by destination CID#89

Merged
richard-ramos merged 3 commits into
mainfrom
codex/quic-shared-socket-cid-routing
Jun 3, 2026
Merged

fix(endpoint): route shared-socket QUIC packets by destination CID#89
richard-ramos merged 3 commits into
mainfrom
codex/quic-shared-socket-cid-routing

Conversation

@richard-ramos

@richard-ramos richard-ramos commented Jun 2, 2026

Copy link
Copy Markdown
Member

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_t in the prelude and excludes it from Futhark generation to avoid the invalid generated aligned layout.

Copilot AI review requested due to automatic review settings June 2, 2026 01:19

Copilot AI left a comment

Copy link
Copy Markdown

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 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 QuicContext and wired lsquic CID lifecycle callbacks (new/live/old SCIDs) to maintain an owned-CID set per engine.
  • Implemented DCID extraction in QuicEndpoint.receiveDatagram and 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.

Comment thread lsquic/context/context.nim Outdated
@richard-ramos
richard-ramos force-pushed the codex/quic-shared-socket-cid-routing branch from e3418f3 to dba97fe Compare June 3, 2026 01:30
Copilot AI review requested due to automatic review settings June 3, 2026 01:32
@richard-ramos
richard-ramos force-pushed the codex/quic-shared-socket-cid-routing branch from dba97fe to 3894eae Compare June 3, 2026 01:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread lsquic/context/context.nim
Comment thread lsquic/context/context.nim
@richard-ramos
richard-ramos force-pushed the codex/quic-shared-socket-cid-routing branch from 3894eae to d2275fc Compare June 3, 2026 01:42
Copilot AI review requested due to automatic review settings June 3, 2026 02:10
@richard-ramos
richard-ramos force-pushed the codex/quic-shared-socket-cid-routing branch from d2275fc to 93f5ca5 Compare June 3, 2026 02:10
@richard-ramos
richard-ramos marked this pull request as ready for review June 3, 2026 02:13
@richard-ramos
richard-ramos requested a review from a team as a code owner June 3, 2026 02:13
@richard-ramos
richard-ramos requested review from gmelodie and vladopajic and removed request for a team June 3, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread lsquic/endpoint.nim
Comment thread lsquic/context/io.nim
@richard-ramos richard-ramos changed the title fix: route shared-socket QUIC packets by destination CID fix(endpoint): route shared-socket QUIC packets by destination CID Jun 3, 2026
Copilot AI review requested due to automatic review settings June 3, 2026 02:22
@richard-ramos
richard-ramos force-pushed the codex/quic-shared-socket-cid-routing branch from 4e1ef3e to 38d4355 Compare June 3, 2026 02:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@richard-ramos
richard-ramos merged commit 870214e into main Jun 3, 2026
17 checks passed
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.

4 participants