From nobody Wed Jul 06 15:06:03 2022 X-Original-To: net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 53BD11CFC495 for ; Wed, 6 Jul 2022 15:06:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LdNCc1C7Qz4h5W for ; Wed, 6 Jul 2022 15:06:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 05C391C75E for ; Wed, 6 Jul 2022 15:06:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 266F63P0092885 for ; Wed, 6 Jul 2022 15:06:03 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 266F63Cv092884 for net@FreeBSD.org; Wed, 6 Jul 2022 15:06:03 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 265064] connect(2): unexpected EADDRINUSE when connecting from IPv6 wildcard to IPv4 address Date: Wed, 06 Jul 2022 15:06:03 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dmgk@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657119964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lTEFTGTA/WpbHd964HHQ8txddlEG57oY19cFn2gtpJY=; b=ncy5x/Hi6ZVa50HD09DMxR2nyy8tNpF6AjIPZfiy523BsLW7brJmVNfu9Qd+yhxN/OgdEI xzu6YLmrDdH1rrEUKxHJI6jfwsbV9+7X3AeB5mRWe99Qj6O+5cagaY5wzXMIBjZd5bHUpF BbptAVAbJJ4rrz4jb8sDQSKyAYlYZlCPkr1c9XxpXBjQE1HLO4qzyG0zmWPL3PvcrRoekM yhCiMm/fgBIeuxUQ4HYkywVofZp+MCm3gsJKz+H3R5WAN/v0Fv0ddIv6lMRE+eS/rUNcY9 5X64lqkJ4pM/qqMSm28iX/3v0SjIqUC8vBCa3I/IQg9lffsgGw1i6NpeQFWwtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657119964; a=rsa-sha256; cv=none; b=t9qKkzm91+dYGuqSP0UHDXXkOt9QAi3v7fAh9U5GSOrDWoKDe0eDGEJpvC4FpjUV6WNqaa CnY58OM1iR29B9hJ+7aeg7YbvmvSgUbluBYCt58BC8iQkgIIR1bpQ6cj4bl01D5GodTiwI GAUhnV29l0g4U1D7GUPkwEiu+otXDyO5GroiN0NPia6Nts31skc1aC08fGysVuhRrIz/nK PHbJtqRaJbBe2OqZI+4QISg5avROY0UbxOtFDmMU7vcpMZtQGE4XlgEAK2Q/53WTPOW3S+ or1WRXnS9Or6tv2WU+23BmY35NmGnkfWgG2r4ytdAgiqG8fWgt6deaSle6JC3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265064 Bug ID: 265064 Summary: connect(2): unexpected EADDRINUSE when connecting from IPv6 wildcard to IPv4 address Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: net@FreeBSD.org Reporter: dmgk@freebsd.org I'm trying to get to the bottom of the Go issue reported in [1] and noticed some differences in the bind(2)/connect(2) behavior between IPv4/IPv6 and IPv4-mapped addresses. I wrote a small C reproducer [2] to isolate the issu= e. When the available port range is exhausted, both IPv4->IPv4 and IPv6->IPv6 clients fail to bind(2) with EADDRNOTAVAIL, which is expected: $ sysctl net.inet.ip.portrange.first=3D10000 $ sysctl net.inet.ip.portrange.last=3D10001 $ ./localdial -4 server4: listening on 0.0.0.0:10001 server6: listening on :::10001 client4: connecting 0.0.0.0:0 -> 127.0.0.1:10001 client4: connected 127.0.0.1:10000 -> 127.0.0.1:10001 server4: accepted 127.0.0.1:10000 -> 0.0.0.0:10001 client4: connecting 0.0.0.0:0 -> 127.0.0.1:10001 localdial: client4: bind: Can't assign requested address $ ./localdial -6 server4: listening on 0.0.0.0:10001 server6: listening on :::10001 client6: connecting :::0 -> ::1:10001 client6: connected ::1:10000 -> ::1:10001 client6: connecting :::0 -> ::1:10001 server6: accepted ::1:10000 -> :::10001 localdial: client6: bind: Can't assign requested address With IPv4-mapped address, the behavior is different: $ sysctl net.inet.ip.portrange.first=3D10000 $ sysctl net.inet.ip.portrange.last=3D10001 $ ./localdial -M server4: listening on 0.0.0.0:10001 server6: listening on :::10001 client6: connecting :::0 -> ::ffff:127.0.0.1:10001 client6: connected ::ffff:127.0.0.1:10000 -> ::ffff:127.0.0.1:10001 server4: accepted 127.0.0.1:10000 -> 0.0.0.0:10001 client6: connecting :::0 -> ::ffff:127.0.0.1:10001 client6: connected ::ffff:127.0.0.1:10000 -> ::ffff:127.0.0.1:10001 server4: accepted 127.0.0.1:10000 -> 0.0.0.0:10001 client6: connecting :::0 -> ::ffff:127.0.0.1:10001 localdial: client6: connect: Address already in use Here, the client successfully does bind(2) but then fails at connect(2) with EADDRINUSE, which looks surprising. This seems to confuse the Go testing su= ite and leads to [1]. Is this an expected/known issue? Reproducible on all FreeBSD versions from 12.3-RELEASE to 14.0-CURRENT. [1] https://github.com/golang/go/issues/34264 [2] https://github.com/dmgk/localdial --=20 You are receiving this mail because: You are the assignee for the bug.=