From nobody Fri May 3 20:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583154423; cv=none; d=zohomail.com; s=zohoarc; b=oDtqtDcGElFsALp7IPjM3j7MUkuVe6HW8vJWdzcBfgeAQnW1vqMReWYT9lL8WzMSqWD0vVLY/orfJiP2dOKQNngaYF347zq1cOFmLiByoD14fLwNHOXAqXwa4cb+tMzzpAp9Idv125oDDvldGf8WAEZvhwx7tdiZRBmsg7JI0ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583154423; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=3COeDYtwpRSAARyob5aBNiC/U8d3U3rMGZjhvgw3CWU=; b=YucrJdri7blVg+CCzqU0F2K3hNCJS5cOVYSCkGtH5zTMPO6UZ2VUSO5awA6qKFR6vWCEFz8uNq+EekU7YIwhePt+6LK0nq77UboqEKp9OQ7++UF3kju/QLwrfFKPuhKrH2/1ijpcaWHqdwH0aArba7cCzIypwkaG8E2g+9WjXG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583154423326118.24842300437513; Mon, 2 Mar 2020 05:07:03 -0800 (PST) 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-489-NF5zaojKMXGyIW9yZFdXUg-1; Mon, 02 Mar 2020 08:07:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1A2A800D6C; Mon, 2 Mar 2020 13:06:53 +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 164B310027B1; Mon, 2 Mar 2020 13:06:52 +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 876C784468; Mon, 2 Mar 2020 13:06:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0228R9Za015706 for ; Mon, 2 Mar 2020 03:27:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4839C10EE788; Mon, 2 Mar 2020 08:27:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 437F910EE784 for ; Mon, 2 Mar 2020 08:27:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E2ED185A78F for ; Mon, 2 Mar 2020 08:27:06 +0000 (UTC) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-ZEUuAfVCN8KwPMEa1qw6UA-1; Mon, 02 Mar 2020 03:27:03 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A1BE53F5661916E754C0 for ; Mon, 2 Mar 2020 16:27:00 +0800 (CST) Received: from huawei.com (10.173.220.198) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Mon, 2 Mar 2020 16:26:55 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583154422; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3COeDYtwpRSAARyob5aBNiC/U8d3U3rMGZjhvgw3CWU=; b=XzyyXSb6vs1hfC69R4Q1R18Qb2JFAHeHNy0wb1ZXIpPefvoJPCA2Z1OvkrpcuJnRihFPhe ZkvK1hpNEJhF/gPEup2JYNqKXmYonYz54jA3DFoiSBrCGwGP6e7r4fJTnnh6k/M2sFptPD 1FoB5HbVMth2VwbRenji4tahiX19LEA= X-MC-Unique: NF5zaojKMXGyIW9yZFdXUg-1 X-MC-Unique: ZEUuAfVCN8KwPMEa1qw6UA-1 From: Zhimin Feng To: Subject: [PATCH] rpc: 'getaddrinfo' function support both IPv4 and IPv6 Date: Mon, 2 Mar 2020 16:26:51 +0800 Message-ID: <20200302082651.1932-1-fengzhimin1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.173.220.198] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0228R9Za015706 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 02 Mar 2020 08:06:46 -0500 Cc: kkk.wanghua@huawei.com, zhengxiang9@huawei.com, Zhimin Feng , zhang.zhanghailiang@huawei.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.84 on 10.5.11.22 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" If only IPv6 is configured and nscd is started, getaddrinfo function reture value is -9. So hints.ai_flags should include the AI_V4MAPPED flag. The following is the partial implementation of getaddrinfo(glibc): if (req->ai_family =3D=3D AF_UNSPEC || req->ai_family =3D=3D AF_INET) at->family =3D AF_INET; else if (req->ai_family =3D=3D AF_INET6 && (req->ai_flags & AI_V4MAPPED= )) { at->addr[3] =3D at->addr[0]; at->addr[2] =3D htonl (0xffff); at->addr[1] =3D 0; at->addr[0] =3D 0; at->family =3D AF_INET6; } else { result =3D -EAI_ADDRFAMILY; goto free_and_return; } Signed-off-by: Zhimin Feng Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnetsocket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index a217404fa6..c547acefc0 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -575,7 +575,7 @@ int virNetSocketNewConnectTCP(const char *nodename, =20 memset(&hints, 0, sizeof(hints)); hints.ai_family =3D family; - hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG; + hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED; hints.ai_socktype =3D SOCK_STREAM; =20 int e =3D getaddrinfo(nodename, service, &hints, &ai); --=20 2.19.1