From nobody Tue Apr 5 02:17:31 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 B50CA1A977CF for ; Tue, 5 Apr 2022 02:17:34 +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 4KXWWL41ZWz3v5P for ; Tue, 5 Apr 2022 02:17:34 +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 6B13F1DC37 for ; Tue, 5 Apr 2022 02:17:34 +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 2352HYOX031511 for ; Tue, 5 Apr 2022 02:17:34 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2352HYNv031510 for net@FreeBSD.org; Tue, 5 Apr 2022 02:17:34 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 210726] tcp connect() can return invalid EADDRINUSE (Eg: multiple jails with the same IP address) Date: Tue, 05 Apr 2022 02:17:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: firk@cantconnect.ru X-Bugzilla-Status: Closed X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: karels@freebsd.org X-Bugzilla-Flags: mfc-stable12+ mfc-stable11- X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: 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=1649125054; 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: in-reply-to:in-reply-to:references:references; bh=D9P98sgl7Brua0JIu5MEUp/3dHGOgH6sE00PcFg7DZU=; b=tQT7scomHoFr9XEe0vtEzteCjFg6z8FvZgT3RFuhsuphSMOUZpC1/AOj/vyjYH+1GwZ96l YYIAYctmbMblY4Ati2cxJ3KOI9BigIJ5LxhUoJLqjglPbQEL9kOb8zLRxOYUNTUrLJSHHS XnwtCa0OSqp1X+plTvIJLE1niCVesiCgkYbdtbA8TNM3a9P4mRI0RWRX67R2edYK33QjK9 fv57w4cOwMbW+C34A90pEscfeqe3ZpAN/cfavxflhqWMW5v3VOMP1xguI0gegTsJQLmSvq PZfCsCuo+kyZi4q5uTWEdpdfbRgeXMs5y/2NfqbbVUU1cjk8x+na5h7bpM+Erg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649125054; a=rsa-sha256; cv=none; b=XMO7Uq7F5TJboWhS5Cvat0aerpEP+eZINRPSTGf52Msk5IIFF4f9FjOpO0KF/OhswFf4/c Hlj9eAVvxWcN0d1tqzeycrPQZ9RJuOFnqW0ZiVAoYtuwKyhk7IJElWCWxc7+2IbtW3M5PZ 13AgLoDzh77EDYVx+/2KcVmqfQvXUg3f8xYBbspXQzpA3plY/AZ1uy/yZWgr720epQGc8H 84fNNEHyQh1N8oMoVwuEn9M4SRFMAlUAdpD74E71nzzbcvYgWTs4KCGc3MAar4alzMb09e ikVBdvMEghfCtgPBXTok3OeXyb2i/59CyX3b3+YO+mRlkSVOyXcdaXyJyUTWkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N 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.=