Skip to content

port/builtin: support source IP propagation for UDP via IP_TRANSPARENT#577

Draft
AkihiroSuda wants to merge 1 commit intorootless-containers:masterfrom
AkihiroSuda:fix-576
Draft

port/builtin: support source IP propagation for UDP via IP_TRANSPARENT#577
AkihiroSuda wants to merge 1 commit intorootless-containers:masterfrom
AkihiroSuda:fix-576

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

The builtin port driver already preserved source IPs for TCP using IP_TRANSPARENT, but UDP was not supported. This commit extends the mechanism to UDP:

  • msg: extract SourceIP/SourcePort from *net.UDPAddr (not just *net.TCPAddr)
  • udpproxy: pass client address (from) to BackendDial callback
  • parent/udp: forward the client address to ConnectToChildWithRetry
  • child: allow dialProto=="udp" in the IP_TRANSPARENT path; use *net.UDPAddr as LocalAddr in transparentDial
  • testsuite: add RunUDPTransparent / TestUDPTransparent with a UDP echo server exercising the round-trip

Co-Authored-By: Claude Opus 4.6 (1M context)

Fix #576

The builtin port driver already preserved source IPs for TCP using
IP_TRANSPARENT, but UDP was not supported. This commit extends the
mechanism to UDP:

- msg: extract SourceIP/SourcePort from *net.UDPAddr (not just *net.TCPAddr)
- udpproxy: pass client address (from) to BackendDial callback
- parent/udp: forward the client address to ConnectToChildWithRetry
- child: allow dialProto=="udp" in the IP_TRANSPARENT path; use
  *net.UDPAddr as LocalAddr in transparentDial
- testsuite: add RunUDPTransparent / TestUDPTransparent with a
  UDP echo server exercising the round-trip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda added this to the v3.0.0 milestone Apr 7, 2026
time.Sleep(500 * time.Millisecond)

// Dial the parent port
conn, err := net.Dial("udp", fmt.Sprintf("127.0.0.1:%d", parentPort))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should test dialing non-loopback addr

@AkihiroSuda AkihiroSuda marked this pull request as draft April 7, 2026 15:42
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.

builtin port driver: source IP propagation does not work for UDP

1 participant