From nobody Wed May 1 08:16:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528108213169635.0039388087584; Mon, 4 Jun 2018 03:30:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FEFF30B9E0C; Mon, 4 Jun 2018 10:30:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3B73608F0; Mon, 4 Jun 2018 10:30:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 78B151804480; Mon, 4 Jun 2018 10:30:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w54AU4oL032102 for ; Mon, 4 Jun 2018 06:30:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4226A9BA2A; Mon, 4 Jun 2018 10:30:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 386CC9BA40 for ; Mon, 4 Jun 2018 10:29:59 +0000 (UTC) Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D27B10C176 for ; Mon, 4 Jun 2018 10:29:46 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 43.9 AUTH) with ESMTPSA id e0b45fu54ATiCcZ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 4 Jun 2018 12:29:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1528108184; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=YxonLRWQtMfgQit5kTCx9r2G3+k7KqiURTUlJwlt8zY=; b=a5YLVCG1XOZrKt2DY9PHqjIW4FlVLeclLB62AmNf2jTdmr84CZ0FHAxYJeSMPda3gb iGdd+PTrWyM0wiS2CUMpZBJtAkFkWEV4Kq5mNsZ3trmh9A1EbXZCMnX6PPA0CsSFSYSA sMbyxTHQhqvYNkjOoM2169WQZYEzPw8+ypBETPs96tbgFL0alc+b5c8Mtnk+QaHZaRIk iICxAmGC6C9Csp6+VoLEIi1ZMScm1XCuZ8G0xpk+lJuNc2cFCFesugnJCCu4cxbdDRVO rC3XV533z0SZZtJn9qV83pNJPolohtQxDA/V7DMUxqdEM2aJunnlXnO1D8DJ87ajjGhe MR2g== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgc09VbzR8stxx+XNVGnx9ZX3co74kFtJGu5gyLH" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: libvir-list@redhat.com Date: Mon, 4 Jun 2018 12:29:37 +0200 Message-Id: <20180604102937.9135-1-olaf@aepfle.de> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Jun 2018 10:29:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Jun 2018 10:29:47 +0000 (UTC) for IP:'81.169.146.161' DOMAIN:'mo4-p00-ob.smtp.rzone.de' HELO:'mo4-p00-ob.smtp.rzone.de' FROM:'olaf@aepfle.de' RCPT:'' X-RedHat-Spam-Score: -0.491 (DKIM_SIGNED, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, T_DKIM_INVALID, URIBL_SBL_A) 81.169.146.161 mo4-p00-ob.smtp.rzone.de 81.169.146.161 mo4-p00-ob.smtp.rzone.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Olaf Hering Subject: [libvirt] [PATCH v3] Loop through all resolved addresses in virNetSocketNewListenTCP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1082217096712676634==" Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 04 Jun 2018 10:30:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 --===============1082217096712676634== Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently virNetSocketNewListenTCP bails out early under the following conditions: - the hostname resolves to at least one IPv4 and at least one IPv6 address - the local interfaces have that one IPv4 address assigned, but not any of the IPv6 addresses - the local interfaces have just IPv6 link-local addresses In this case the resolver returns not only the IPv4 addresses but also IPv6. Binding the IPv6 address will obviously fail. But this terminates the entire loop, even if binding to IPv4 succeeded. To fix this error, just keep going and loop through all returned addresses. In case none of the attempts to bind to some address succeeded, try to report some appropriate error. Signed-off-by: Olaf Hering --- v3: more whitespace fixes, as suggested by Daniel P. Berrang=C3=A9 v2: whitespace fixes, as suggested by John Ferlan src/rpc/virnetsocket.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 7087abec9c..3a055acd39 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -382,11 +382,8 @@ int virNetSocketNewListenTCP(const char *nodename, #endif =20 if (bind(fd, runp->ai_addr, runp->ai_addrlen) < 0) { - if (errno !=3D EADDRINUSE) { - virReportSystemError(errno, "%s", _("Unable to bind to por= t")); - goto error; - } - addrInUse =3D true; + if (errno =3D=3D EADDRINUSE) + addrInUse =3D true; VIR_FORCE_CLOSE(fd); runp =3D runp->ai_next; continue; @@ -409,14 +406,14 @@ int virNetSocketNewListenTCP(const char *nodename, fd =3D -1; } =20 - if (nsocks =3D=3D 0 && familyNotSupported) { - virReportSystemError(EAFNOSUPPORT, "%s", _("Unable to bind to port= ")); - goto error; - } - - if (nsocks =3D=3D 0 && - addrInUse) { - virReportSystemError(EADDRINUSE, "%s", _("Unable to bind to port")= ); + if (nsocks =3D=3D 0) { + if (familyNotSupported) + errno =3D EAFNOSUPPORT; + else if (addrInUse) + errno =3D EADDRINUSE; + else + errno =3D EDESTADDRREQ; + virReportSystemError(errno, "%s", _("Unable to bind to port")); goto error; } =20 --===============1082217096712676634== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list --===============1082217096712676634==--