Skip to content

Support IP_TRANSPARENT on listening sockets - #987

Open
torinnd wants to merge 1 commit into
cloudflare:mainfrom
torinnd:add-ip-transparent
Open

Support IP_TRANSPARENT on listening sockets#987
torinnd wants to merge 1 commit into
cloudflare:mainfrom
torinnd:add-ip-transparent

Conversation

@torinnd

@torinnd torinnd commented Sep 1, 2026

Copy link
Copy Markdown

Adds a Linux-only ip_transparent option to TcpSocketOptions. Pingora applies IP_TRANSPARENT to IPv4 listeners and IPV6_TRANSPARENT to IPv6 listeners before bind().

Transparent proxy listeners need this option before binding non-local addresses. Exposing it through TcpSocketOptions lets Pingora retain ownership of the listener and participate in its normal fd-transfer lifecycle, rather than requiring the application to bind the socket itself.

Enabling the option requires CAP_NET_ADMIN or CAP_NET_RAW, along with the corresponding routing configuration. Inherited listener fds retain their existing socket options, so configuration changes apply when Pingora binds a new listener.

The unprivileged test exercises the disabled setting for IPv4 and, where IPv6 sockets are available, IPv6. Testing the enabled setting would require privileged CI.

Add a Linux-only ip_transparent option to TcpSocketOptions. Pingora
applies IP_TRANSPARENT for IPv4 listeners or IPV6_TRANSPARENT for IPv6
listeners before bind, preserving Pingora's ownership of the listening
fd and its graceful-transfer path.

Enabling the option requires CAP_NET_ADMIN or CAP_NET_RAW and the
corresponding transparent routing configuration. Restored listener fds
keep the option state inherited from the old process.

The unprivileged test exercises disabling the option for IPv4 and, when
IPv6 sockets are available, IPv6.
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.

1 participant