Date: Tue, 05 Apr 2022 02:17:31 +0000 From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 210726] tcp connect() can return invalid EADDRINUSE (Eg: multiple jails with the same IP address) Message-ID: <bug-210726-7501-ITqsgFPJ3Z@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-210726-7501@https.bugs.freebsd.org/bugzilla/> References: <bug-210726-7501@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D210726 --- Comment #26 from firk@cantconnect.ru --- Created attachment 232948 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D232948&action= =3Dedit patch for 12.x 13.x 14-CURRENT > connecting from an IPv6 address to an IPv4 one. How do you connect from IPv6 to IPv4? It giving me EINVAL (12.3) or EAFNOSUPPORT (14) when I try to call bind() or connect() with IPv4 address on IPv6 socket. And that's check at the very beginning of tcp6_usr_connect(): > if (nam->sa_family !=3D AF_INET6) > return (EAFNOSUPPORT); > if (nam->sa_len !=3D sizeof (*sin6)) > return (EINVAL); giving no chance to handle IPv4 address with it. Do you using jails? I found a way to still trigger EADDRINUSE from connect() from a jail in 12.3 and 14-CURRENT, may be that's your case: bind(fd,{0.0.0.0:0}) and then do connect (that's all for a pure IPv4 socket= ). Since the issue you linked contains "connect from wildcard IPv6", most like= ly it was really wildcard-bound IPv4 (because connecting from IPv6 to IPv4 is = not possible at all). Adding a patch to fix that (that's the same patch that was posted 6 years a= go but very slightly modified for freebsd 12+). --=20 You are receiving this mail because: You are on the CC list for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-210726-7501-ITqsgFPJ3Z>