From nobody Mon May 6 00:29:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594813746; cv=none; d=zohomail.com; s=zohoarc; b=HdrKj9XaGAsncLJyAW4xD+T940o3YsuBrTy7sW2CJUnRos7trQkk3Vth996MfRMbGBT21EZlp/E7YCEx4MqxcnvHgP0ez92xHroyQ8Jrj3zr+14E5kUQ2c7o7prFZXEdW6rTASz2goGEou9BpTv8UCpkhW8KaFJIOT/H7Nf15Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594813746; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w7eR88FNdsHiDKfJQLsi9qpOpvPDO/b0ZG/t0Cpopxw=; b=VvjH02CK9hRhf0/XzvrxzVvTodPlLU0Rx8OYR4m/orUGqHzDdN53BPWvTY+uca697ETvqmlf61taFVfm7WZ8h643mnrZNnQjqQZzWmq+LpjoPstGHrnf5KxQEQlu5v0ZNTW4wIwW2UJz0ZgE2Kafk1p4a0VCJoYOACxRUYfMbG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594813746190798.662611556048; Wed, 15 Jul 2020 04:49:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-EdQInl7OPLOlWWL_DpabfQ-1; Wed, 15 Jul 2020 07:49:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7367A800597; Wed, 15 Jul 2020 11:48:57 +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 4FF2860C84; Wed, 15 Jul 2020 11:48:57 +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 1E2EF1809561; Wed, 15 Jul 2020 11:48:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06FBmrZ3023052 for ; Wed, 15 Jul 2020 07:48:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6CD475D9C5; Wed, 15 Jul 2020 11:48:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF710757DF for ; Wed, 15 Jul 2020 11:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594813745; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=w7eR88FNdsHiDKfJQLsi9qpOpvPDO/b0ZG/t0Cpopxw=; b=WYJ0rtU/YeQzvLOnGBta7zmTZPUu14xHMa4FVrmTHKbP01v4yKy4+08rxpIwKOyjiqh+ZF Ur2/dtaxKvT6tUbLHuKLUtxWw16WxMHc5cwGdvQuPFBpCcOo73H/3VWISJCZyeM0ygm9pC 641NM908DXC+4Sm8pTthDAXTPAoA3MI= X-MC-Unique: EdQInl7OPLOlWWL_DpabfQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] virNetSocketCheckProtocols: Separate out checking family via getaddrinfo() Date: Wed, 15 Jul 2020 13:48:44 +0200 Message-Id: <58cf5bf47817a597bc871a6aca8f7df6614162ad.1594813562.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The virNetSocketCheckProtocols() function is supposed to tell caller whether IPv4 and/or IPv6 is supported on the system. In the initial round, it uses getifaddrs() to see if an interface has IPv4/IPv6 address assigned and then to double check IPv6 it uses getaddrinfo() to lookup IPv6 loopback address. Separate out this latter code because it is going to be reused. Since the original code lived under an #ifdef and the new function doesn't it is marked as unused - because on some systems it may be so. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnetsocket.c | 63 ++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index d1f4c531aa..b6bc3edc3b 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -141,16 +141,48 @@ static int virNetSocketForkDaemon(const char *binary) } #endif =20 + +static int G_GNUC_UNUSED +virNetSocketCheckProtocolByLookup(const char *address, + int family, + bool *hasFamily) +{ + struct addrinfo hints; + struct addrinfo *ai =3D NULL; + int gaierr; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family =3D family; + hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG; + hints.ai_socktype =3D SOCK_STREAM; + + if ((gaierr =3D getaddrinfo(address, NULL, &hints, &ai)) !=3D 0) { + *hasFamily =3D false; + + if (gaierr =3D=3D EAI_FAMILY || +#ifdef EAI_ADDRFAMILY + gaierr =3D=3D EAI_ADDRFAMILY || +#endif + gaierr =3D=3D EAI_NONAME) { + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot resolve ::1 address: %s"), + gai_strerror(gaierr)); + return -1; + } + } else { + *hasFamily =3D true; + } + + freeaddrinfo(ai); + return 0; +} + int virNetSocketCheckProtocols(bool *hasIPv4, bool *hasIPv6) { #ifdef HAVE_IFADDRS_H struct ifaddrs *ifaddr =3D NULL, *ifa; - struct addrinfo hints; - struct addrinfo *ai =3D NULL; - int gaierr; - - memset(&hints, 0, sizeof(hints)); =20 *hasIPv4 =3D *hasIPv6 =3D false; =20 @@ -172,26 +204,9 @@ int virNetSocketCheckProtocols(bool *hasIPv4, =20 freeifaddrs(ifaddr); =20 - hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG; - hints.ai_family =3D AF_INET6; - hints.ai_socktype =3D SOCK_STREAM; =20 - if ((gaierr =3D getaddrinfo("::1", NULL, &hints, &ai)) !=3D 0) { - if (gaierr =3D=3D EAI_FAMILY || -# ifdef EAI_ADDRFAMILY - gaierr =3D=3D EAI_ADDRFAMILY || -# endif - gaierr =3D=3D EAI_NONAME) { - *hasIPv6 =3D false; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot resolve ::1 address: %s"), - gai_strerror(gaierr)); - return -1; - } - } - - freeaddrinfo(ai); + if (virNetSocketCheckProtocolByLookup("::1", AF_INET6, hasIPv6) < 0) + return -1; =20 VIR_DEBUG("Protocols: v4 %d v6 %d", *hasIPv4, *hasIPv6); =20 --=20 2.26.2 From nobody Mon May 6 00:29:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594813751; cv=none; d=zohomail.com; s=zohoarc; b=UlOfJou0+LYFNtJs1qs19Wsc7Ee+pKkDjvLMS/d8RpbCK1wn94diQlYENMQ17Sk8xRyG9RIIAWLi7oDrIkA56J3dba0ySvL4wwLTQHY7YzB3AcENbzxkMhM2Lnm4uBOQWCKm0UCqhN2SbpuOcSE5uhEQmIj/yA/MT7pXaNAMM3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594813751; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wzm965lgFN0brOEjP5mDEX4o69lNUiHwb/MQrqpdHQM=; b=E1csleWuw5sdR/++lplj4sKoiOTt2+zkscSAeO+KcPy6ihFGExbX3utNNgvyuKgJ9vrhfAVDxBeUL5IKj5BYJZkjJVIykBp31ElKcgNTkXSHQCC9vCpi6iNOxdMm1Z/2MhcElJqsAw77BWmvXJGM0GtoUjYugsOUeHBBK1h+kwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594813751049247.98463370303728; Wed, 15 Jul 2020 04:49:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-q6h81L7-PsOTY5P9BHt4Hw-1; Wed, 15 Jul 2020 07:49:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 050088027EE; Wed, 15 Jul 2020 11:49:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7F7079D09; Wed, 15 Jul 2020 11:48:59 +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 A7DF772F54; Wed, 15 Jul 2020 11:48:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06FBmsPw023060 for ; Wed, 15 Jul 2020 07:48:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4891A5D9CA; Wed, 15 Jul 2020 11:48:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id BED9F5D9C5 for ; Wed, 15 Jul 2020 11:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594813749; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wzm965lgFN0brOEjP5mDEX4o69lNUiHwb/MQrqpdHQM=; b=NdXmwmyF+hHomimppLl80aLJHQCBff6Mb/qtk10sJDVJ10nGsXIOON+CwYKARuFOAwHQAj LMN4hjoP/EjmnTT6a0m7ZxERSmMl4GuLIEHMTOKUxx8iUgaWog09SGJFq3tBZGCLslXpbz etXnmqAzAVhRu6lUAtbWqHYVdnVBl9c= X-MC-Unique: q6h81L7-PsOTY5P9BHt4Hw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] virNetSocketCheckProtocols: lookup IPv6 only if suspecting IPv6 Date: Wed, 15 Jul 2020 13:48:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There is not much sense trying to disprove host is IPv6 capable if we know after first round (getifaddrs()) that is is not. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnetsocket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b6bc3edc3b..b0d63f0f2c 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -205,7 +205,8 @@ int virNetSocketCheckProtocols(bool *hasIPv4, freeifaddrs(ifaddr); =20 =20 - if (virNetSocketCheckProtocolByLookup("::1", AF_INET6, hasIPv6) < 0) + if (hasIPv6 && + virNetSocketCheckProtocolByLookup("::1", AF_INET6, hasIPv6) < 0) return -1; =20 VIR_DEBUG("Protocols: v4 %d v6 %d", *hasIPv4, *hasIPv6); --=20 2.26.2 From nobody Mon May 6 00:29:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594813752; cv=none; d=zohomail.com; s=zohoarc; b=dfyR479LFpHaoS/Iy0hotX5ijHSrUPnZphFrIf1UqrgrYkj94NBZ+2Y2L/Xd+Q3CSoG4PDZ6yIFq5EJA1qOEtK+J/Nhaugv9MP85QcxlP5sOsgoDsWAZVLCQ8pLUye4wMP6reuP2H43mqeIAu9cPaXEM8o1Vxb4iP6z5lUJX+vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594813752; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RZdG0cghEGnXWLx9GWDaPoKs5wHWoOpRHjOu1rPx7zE=; b=jkAvwe2AWCwQy6SQsh2oUf8eY5Ls9lH5s5zJorr2YPky8pg1zm8ZcvYeyovzijfNmFURmLT4rqCDDL2Lev1UdAXY9pvc8jNhpB1TZVxSUpE7SbwNIsG4P+mE74HDvqBAUWlFnF8erTEXEeK2/U+iOy3nILTiI9eyF+VP/GNk69I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594813752764352.69534169027975; Wed, 15 Jul 2020 04:49:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-LaNWLgUfMk-WDC1c-RHYLQ-1; Wed, 15 Jul 2020 07:49:09 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59FF9100CCC6; Wed, 15 Jul 2020 11:49:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A52A79D02; Wed, 15 Jul 2020 11:49:02 +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 096149622F; Wed, 15 Jul 2020 11:49:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06FBmtV3023068 for ; Wed, 15 Jul 2020 07:48:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 243BE5D9CA; Wed, 15 Jul 2020 11:48:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A2EF5D9C5 for ; Wed, 15 Jul 2020 11:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594813751; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RZdG0cghEGnXWLx9GWDaPoKs5wHWoOpRHjOu1rPx7zE=; b=IOvFHKCSRFgg53csBYCUFY9V4BT4Ct/fm1MWHeMDYr3TV1YyNIDYEkpqiA2jFfm37ZaGJ5 J18LaneOYvnepc3nWWhavjgubYNyjsnnp0uwtEe2C65UPYd7n14xMlNJSZRDl3GA3bK4OH UynmQpBn7lJukW+QquYAm7w1/G/SKOE= X-MC-Unique: LaNWLgUfMk-WDC1c-RHYLQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] virNetSocketCheckProtocols: Confirm IPv4 by lookup too Date: Wed, 15 Jul 2020 13:48:46 +0200 Message-Id: <9ebc3658c325457edb79e5766bd783a78743c726.1594813563.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Historically, if we found an interface with an IPv6 address we did not blindly trust that host is IPv6 capable (as in we can successfully translate IPv4 addresses) but used getaddrinfo() to confirm it. Turns out, we have use the same argument for IPv4. For instance, in an namespace created by the following steps, getaddrinfo("127.0.0.1", ...) fails (demonstrating by "Socket TCP/IPv4 Accept" test case failing in virnetsockettest): unshare -n ip link set lo up ip link add dummy0 type dummy ip link set dummy0 up Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnetsocket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b0d63f0f2c..c62c2fb3fc 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -204,6 +204,9 @@ int virNetSocketCheckProtocols(bool *hasIPv4, =20 freeifaddrs(ifaddr); =20 + if (hasIPv4 && + virNetSocketCheckProtocolByLookup("127.0.0.1", AF_INET, hasIPv4) <= 0) + return -1; =20 if (hasIPv6 && virNetSocketCheckProtocolByLookup("::1", AF_INET6, hasIPv6) < 0) --=20 2.26.2