[Bug 210726] tcp connect() can return invalid EADDRINUSE (Eg: multiple jails with the same IP address)

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 05 Apr 2022 02:25:38 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210726

--- Comment #27 from firk@cantconnect.ru ---
Created attachment 232951
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=232951&action=edit
test program

Test program

First, reduce portrange to hit the problem faster:

sysctl net.inet.ip.portrange.first=10000
sysctl net.inet.ip.portrange.last=10004

Compile:
cc -o test test.c

Open two screens, first:

./test 10 1.2.3.4 0.0.0.0

Second:

jail / x your.real.ip.address csh
cd /your/dir
./test 10 1.2.3.4 0.0.0.0

with unpatched system, second program will show (EADDRINUSE)
> connect() error 48 (Address already in use)
with patched, it will show the proper error (EADDRNOTAVAIL)
> bind() error 49 (Can't assign requested address)

-- 
You are receiving this mail because:
You are on the CC list for the bug.