From nobody Fri Apr 19 23:55:27 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 1526372451493986.0371683451132; Tue, 15 May 2018 01:20:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B2B4C0E674F; Tue, 15 May 2018 08:20:49 +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 1EC0A5FC2E; Tue, 15 May 2018 08:20:49 +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 D86CC1801249; Tue, 15 May 2018 08:20:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4F8KiRx009080 for ; Tue, 15 May 2018 04:20:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9303830B2004; Tue, 15 May 2018 08:20:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C66C30B2001 for ; Tue, 15 May 2018 08:20:42 +0000 (UTC) Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.218]) (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 F00C0ECFA2 for ; Tue, 15 May 2018 08:20:30 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 43.8 AUTH) with ESMTPSA id h032f7u4F8KS3Gy (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); Tue, 15 May 2018 10:20:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1526372429; 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=ga87fzTB16V0SQ1sAk72nsdK7r2DjJq4tNoM7bLu6pQ=; b=cyEChwkLNbVTVJt6gnrj05T3O+T1H1kgVMjWd4O+e01Bne3mPxwXWL69IrRpUvjLvD bCjnS7g0kW88LYY5PjcPuRZ35NP3T0Lma8nQnxf0I8guFTdk90AXCAmMf2VJW+PVArGi ZFwgchkI9e1+Zu9eWZRUkh8KX2PwZ3mM0aZHiqMDr2OIKdfYLiXEMaJEFxuanO6u1BwZ d3UfR1K8epSxHP5CfSZ6/4+yDejcdYWInt6oPi8vV/QakHCahoBK+o/WM1317wO1Ub/J e2eMvcP7UfAUHJveOzA4CclOOAqnrV0dIn1B1urz5QQA49SSRb7JgPTaB9gn0w11PX8g oiLQ== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgc09VbzR8stxx+XNVGnx9ZX3co74kFtJGu5gyLH" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: libvir-list@redhat.com Date: Tue, 15 May 2018 10:20:26 +0200 Message-Id: <20180515082026.13928-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.27]); Tue, 15 May 2018 08:20:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 15 May 2018 08:20:31 +0000 (UTC) for IP:'81.169.146.218' DOMAIN:'mo4-p00-ob.smtp.rzone.de' HELO:'mo4-p00-ob.smtp.rzone.de' FROM:'olaf@aepfle.de' RCPT:'' X-RedHat-Spam-Score: -0.591 (DKIM_SIGNED, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, T_DKIM_INVALID) 81.169.146.218 mo4-p00-ob.smtp.rzone.de 81.169.146.218 mo4-p00-ob.smtp.rzone.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Olaf Hering Subject: [libvirt] [PATCH v1] 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 15 May 2018 08:20:50 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_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 addreses 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 the appropriate error. Signed-off-by: Olaf Hering --- 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..0ee5e3604f 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=20 + errno =3D EDESTADDRREQ; + virReportSystemError(errno, "%s", _("Unable to bind to port")); goto error; } =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list