From nobody Mon Apr 29 06:07:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513642939419680.7752604391404; Mon, 18 Dec 2017 16:22:19 -0800 (PST) Received: from localhost ([::1]:57385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR5fh-0002dj-8w for importer@patchew.org; Mon, 18 Dec 2017 19:22:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR5ek-0002F1-SG for qemu-devel@nongnu.org; Mon, 18 Dec 2017 19:21:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eR5eh-00035w-LJ for qemu-devel@nongnu.org; Mon, 18 Dec 2017 19:21:14 -0500 Received: from mailrelay.quantumachine.net ([37.59.103.225]:34526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR5eh-00034m-DW for qemu-devel@nongnu.org; Mon, 18 Dec 2017 19:21:11 -0500 Received: from mail.quantumachine.net (unknown [89.128.97.235]) by mailrelay.quantumachine.net (Postfix) with ESMTP id 7955045 for ; Tue, 19 Dec 2017 01:21:07 +0100 (CET) Received: by mail.quantumachine.net (Postfix, from userid 1005) id A137EE418E; Tue, 19 Dec 2017 01:21:06 +0100 (CET) Received: from sector.int (unknown [192.168.4.12]) by mail.quantumachine.net (Postfix) with ESMTPSA id D1031E4181; Tue, 19 Dec 2017 01:21:05 +0100 (CET) (envelope-from tuxillo@quantumachine.net) Received: from mgnt.home (mgnt.home [192.168.4.137]) by www.quantumachine.net (Horde Framework) with HTTPS; Tue, 19 Dec 2017 00:21:05 +0000 Date: Tue, 19 Dec 2017 00:21:05 +0000 Message-ID: <20171219002105.Horde.McUB5OjQ4CcwjyzfFEIWM2V@www.quantumachine.net> From: Antonio Huete =?utf-8?b?Smltw6luZXo=?= To: qemu-devel@nongnu.org User-Agent: Horde Application Framework 5 MIME-Version: 1.0 Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 37.59.103.225 Subject: [Qemu-devel] [PATCH] sockets: Fix test for DragonFly BSD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; format="flowed"; delsp="Yes" From f57cdc7ec2d5a5e906fa8b795eeede2d7b66aa56 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Fri, 15 Dec 2017 01:08:10 +0100 Subject: [PATCH] sockets: Fix test for DragonFly BSD DragonFly BSD does not implement AI_V4MAPPED for its getaddrinfo() so probe and discard that flag instead of aborting the test. Test that fails: ERROR:tests/test-char.c:448:char_udp_test_internal: 'chr' should =20 not be NULL Signed-off-by: Antonio Huete Jimenez --- util/qemu-sockets.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index af4f01211a..5a9c55c303 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -43,6 +43,8 @@ # define AI_NUMERICSERV 0 #endif +int useV4Mapped =3D 1; + static int inet_getport(struct addrinfo *e) { @@ -383,7 +385,6 @@ static struct addrinfo =20 *inet_parse_connect_saddr(InetSocketAddress *saddr, struct addrinfo ai, *res; int rc; Error *err =3D NULL; - static int useV4Mapped =3D 1; memset(&ai, 0, sizeof(ai)); @@ -474,7 +475,11 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, /* lookup peer addr */ memset(&ai,0, sizeof(ai)); - ai.ai_flags =3D AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; + ai.ai_flags =3D AI_CANONNAME | AI_ADDRCONFIG; + if (atomic_read(&useV4Mapped)) { + ai.ai_flags |=3D AI_V4MAPPED; + } + ai.ai_family =3D inet_ai_family_from_address(sraddr, &err); ai.ai_socktype =3D SOCK_DGRAM; @@ -493,7 +498,21 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, goto err; } - if ((rc =3D getaddrinfo(addr, port, &ai, &peer)) !=3D 0) { + /* lookup */ + rc =3D getaddrinfo(addr, port, &ai, &peer); + + /* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but + * then don't implement it in their getaddrinfo(). Detect + * this and retry without the flag since that's preferrable + * to a fatal error + */ + if (rc =3D=3D EAI_BADFLAGS && + (ai.ai_flags & AI_V4MAPPED)) { + atomic_set(&useV4Mapped, 0); + ai.ai_flags &=3D ~AI_V4MAPPED; + rc =3D getaddrinfo(addr, port, &ai, &peer); + } + if (rc !=3D 0) { error_setg(errp, "address resolution failed for %s:%s: %s", =20 addr, port, gai_strerror(rc)); goto err; --=20 2.15.0