Commit 0c3015d
committed
Avoid ephemeral port exhaustion when binding to a specific IP
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.1 parent c8ed964 commit 0c3015d
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
330 | 333 | | |
331 | 334 | | |
332 | 335 | | |
| |||
0 commit comments