Skip to content

Conversation

@srnym
Copy link
Contributor

@srnym srnym commented Sep 22, 2025

This is edumazet's patch.

The network client was binding to a specific IP address without using IP_BIND_ADDRESS_NO_PORT. This forces the kernel to allocate an exclusive ephemeral port for each connection before connect(), leading to "Address already in use" errors when many concurrent connections are attempted (around 60k flows).

This commit adds a setsockopt call with IP_BIND_ADDRESS_NO_PORT before the bind call. This allows the kernel to defer port selection until connect(), enabling the client to establish many more concurrent connections without exhausting the ephemeral port range.

Tested:

  • Verified with strace that IP_BIND_ADDRESS_NO_PORT is called before bind.

This is edumazet's patch.

The network client was binding to a specific IP address without using `IP_BIND_ADDRESS_NO_PORT`. This forces the kernel to allocate an exclusive ephemeral port for each connection before `connect()`, leading to "Address already in use" errors when many concurrent connections are attempted (around 60k flows).

This commit adds a `setsockopt` call with `IP_BIND_ADDRESS_NO_PORT` before the `bind` call. This allows the kernel to defer port selection until `connect()`, enabling the client to establish many more concurrent connections without exhausting the ephemeral port range.

Tested:
  * Verified with strace that `IP_BIND_ADDRESS_NO_PORT` is called before bind.
@hi-rajat-kumar hi-rajat-kumar merged commit 8c35a30 into google:master Sep 23, 2025
1 check 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.

2 participants