connect() EADDRINUSE

aler aler at playground.ru
Fri May 20 13:02:52 UTC 2016


Port autoselection on connect() without bind() (or with bind() with zero 
sin_port) sometimes works wronly and gives already busy local port 
number that will lead to EADDRINUSE on connection attempt. This all 
happens when jails used.

How to fix:

src/sys/netinet/in_pcb.c, in_pcb_lport() function

calls to in_pcblookup_local() should have last argument NULL, not cred

that's because here we are not about getting some access but about 
avoiding port number conflicts, so all inpcb's should be taken in account


This all applies to FreeBSD 10.x



More information about the freebsd-net mailing list