Skip to content

fix(transport): preserve wildcard socket source addresses - #174

Open
richard-ramos wants to merge 16 commits into
mainfrom
fix/quic-wildcard-socket
Open

richard-ramos wants to merge 16 commits into
mainfrom
fix/quic-wildcard-socket

Conversation

@richard-ramos

Copy link
Copy Markdown
Collaborator

Summary

Preserve the concrete local address when QUIC uses a wildcard-bound UDP socket
on Linux:

  • pass each datagram destination address into LSQUIC
  • select that source address on outbound packets with packet-info ancillary data
  • initialize outgoing connections with the route-selected local address

This keeps LSQUIC path identity stable while allowing one dual-stack listener
socket to dial IPv4 peers.

Dependency

Impact on Library Users

Linux endpoints can use wildcard listener sockets for outbound QUIC without
losing source-address control. Non-Linux behavior is unchanged.

Risk Assessment

The change affects Linux QUIC packet I/O. It retains the existing sendmmsg
batching and caps receive draining as before.

References

@richard-ramos

Copy link
Copy Markdown
Collaborator Author

/review pro

@richard-ramos

Copy link
Copy Markdown
Collaborator Author

/review pro

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 5 issue(s) in this PR.

  • ✅ Successfully posted inline: 5 comment(s)

Comment thread lsquic/context/io.nim Resolved
Comment thread lsquic/context/io.nim Resolved
Comment thread lsquic/context/io.nim Resolved
Comment thread lsquic/context/io.nim Resolved
Comment thread tests/test_receive.nim Resolved
@richard-ramos
richard-ramos marked this pull request as ready for review September 22, 2026 18:29
@richard-ramos
richard-ramos requested a review from a team as a code owner September 22, 2026 18:29
@richard-ramos
richard-ramos requested review from gmelodie and vladopajic and removed request for a team September 22, 2026 18:29

@gmelodie gmelodie 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.

  1. I think it should be possible to use only one definition of ControlBuffer for all systems, no?
  2. Instead of having huge portions of the code inside when blocks, we could have these blocks inside procs e.g. instead of two definitions of prepareSourceAddr we could have:
proc prepareSourceAddr() = 
  when defined(linux):
    prepareSourceAddrPosix
  when defined(windows):
    prepareSourceAddrWin

obs: also address cmsg logic which is duplicated in both definitions of prepareSourceAddr

  1. Tests do not seem to cover windows + WSASendMsg, IPv6 pktinfo send or macOS.

  2. I see recvFrom was dropped from windows and mac, but that means a perf drawback for UDP on these platforms. Can we not implement them for windows (leveraging WSARecvMsg) and mac (using IP_RECVPKTINFO and IPV6_RECVPKTINFO)?

Comment thread lsquic/context/io.nim Resolved
Comment thread lsquic/endpoint.nim Resolved
Comment thread lsquic/endpoint.nim Resolved
Comment thread lsquic/context/io.nim Resolved
Comment thread lsquic/context/io.nim Resolved
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