From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: ai_flags in calls to getaddrinfo Date: Thu, 31 Dec 2020 17:06:23 +0200 Message-ID: <83sg7mggls.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39551"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 31 16:10:58 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuzbO-000AAU-JD for ged-emacs-devel@m.gmane-mx.org; Thu, 31 Dec 2020 16:10:58 +0100 Original-Received: from localhost ([::1]:52780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuzbN-0006HB-Jd for ged-emacs-devel@m.gmane-mx.org; Thu, 31 Dec 2020 10:10:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuzXM-00045q-12 for emacs-devel@gnu.org; Thu, 31 Dec 2020 10:06:48 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50947) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuzXK-0001sX-64 for emacs-devel@gnu.org; Thu, 31 Dec 2020 10:06:47 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4617 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kuzXI-0007L5-AP for emacs-devel@gnu.org; Thu, 31 Dec 2020 10:06:45 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262163 Archived-At: On one of the systems on which I work, getaddrinfo called with AF_INET6 fails with EAI_NODATA, for some reason. That causes network-lookup-address-info to fail when passed 'ipv6' as the last argument. Adding the AI_V4MAPPED flag, as in the patch below, seems to solve the problem. So I wonder why we don't do this in general. I'm not an expert on DNS, so would people who know more than I do about this please comment on whether the patch below is a good idea? diff --git a/src/process.c b/src/process.c index 28ab15c903..f550703c2a 100644 --- a/src/process.c +++ b/src/process.c @@ -4559,12 +4559,18 @@ DEFUN ("network-lookup-address-info", Fnetwork_lookup_address_info, memset (&hints, 0, sizeof hints); if (EQ (family, Qnil)) - hints.ai_family = AF_UNSPEC; + { + hints.ai_family = AF_UNSPEC; + hints.ai_flags = AI_ALL | AI_V4MAPPED; + } else if (EQ (family, Qipv4)) hints.ai_family = AF_INET; #ifdef AF_INET6 else if (EQ (family, Qipv6)) - hints.ai_family = AF_INET6; + { + hints.ai_family = AF_INET6; + hints.ai_flags = AI_V4MAPPED; + } #endif else error ("Unsupported lookup type");