# \[PATCH net-next v2 0/2\] tcp: fix false exhaustion of odd-sized bind port ranges

- From: Florin Badita-Nistor \<hidden\>
- Date: 2026-11-06 17:14:46 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/11/17880240
- Thread: https://ratatoskr.run/netdev/2026/11/17880240/t.md

```text
Fix false bind() exhaustion when an odd-sized local port range still
contains an eligible free port. The wrap can flip parity in odd-sized
ranges; even-sized scan sequences are unchanged. The namespace-wide
connect() allocator is not changed by this series.

Earlier x86-64 KVM validation of this unchanged allocator/test code:
- Regression test: four failures before, zero after (eight cases).
- Full port-range suite: four failures before, zero after (80 cases);
  two existing SCTP XPASS results unchanged.
- Go net.Listen, 100 attempts per IP version: 100 failures before,
  zero after; explicit free-port controls succeed in both kernels.

Changes in v2:
- Target net-next and drop the stable Cc, as requested by Eric.
- Document parity changes on odd wraps and scope the fix to bind().
- Shorten the cover letter.

v1: https://lore.kernel.org/netdev/CADnh+D0zSzAyYCLo5cXU56o9X-P3RG3N2ix7ARPrP95d8sBXmg@mail.gmail.com/

Florin Badita-Nistor (2):
  tcp: avoid false bind exhaustion with odd-sized port ranges
  selftests/net: cover odd-sized local port ranges with one free port

 net/ipv4/inet_connection_sock.c               |  2 -
 .../selftests/net/ip_local_port_range.c       | 67 ++++++++++++++++++-
 2 files changed, 64 insertions(+), 5 deletions(-)


base-commit: bb67589c87249c9bc2415ab11a754d6e303774e3
-- 
2.51.0

```
