[Bug 265064] connect(2): unexpected EADDRINUSE when connecting from IPv6 wildcard to IPv4 address

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 26 Jul 2022 21:35:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265064

--- Comment #6 from Mike Karels <karels@freebsd.org> ---
(In reply to firk from comment #5)

> No, wildcard ipv6 bind() shouldn't fail just because ipv4 port
> for the specifiec ipv4 address is busy.

There is nothing specific in this bind() call.  The address is ANY and the port
is zero.  Also, the application has cleared the IPV6_ONLY option, specifically
enabling IPv4.  It seems far better to allocate a port that can work for IPv4
as well as IPv6 in this case.  My in-progress change modifies only that
situation.  Hopefully I'll be ready to circulate the change soon.

> I'm not sure how this error should be reported to userland, but it surely
> shouldn't be triggered until we try to connect() to ipv6-wrapped ipv4 address.
> May be it will be okay to return EADDRNOTAVAIL from such connect(), considering
> wildcard-bound socket as partially unbound socket as we really have to do
> new ipv4-bind() over existing ipv6-wildcard-bind.

We can't do a new bind() for IPv4; ports are immutable once bound.  Note that
the application could have skipped the bind() call, in which case connect() can
do the right thing.  But this procedure should also work.

-- 
You are receiving this mail because:
You are the assignee for the bug.