From nobody Tue Sep 27 21:09:57 2022 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4McXMM6WMjz4cwyG for ; Tue, 27 Sep 2022 21:10:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4McXMM1sP1z4K3M for ; Tue, 27 Sep 2022 21:10:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 28RL9v79091490 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 28 Sep 2022 00:10:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 28RL9vjS091489; Wed, 28 Sep 2022 00:09:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 28 Sep 2022 00:09:57 +0300 From: Konstantin Belousov To: Mike Karels Cc: freebsd-net@freebsd.org Subject: Re: getaddrinfo error for existing host without requested address family Message-ID: References: <202209272053.28RKrDEa004321@mail.karels.net> List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202209272053.28RKrDEa004321@mail.karels.net> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on tom.home X-Rspamd-Queue-Id: 4McXMM1sP1z4K3M X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-0.997]; NEURAL_HAM_SHORT(-0.96)[-0.960]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-net@freebsd.org]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_SOFTFAIL(0.00)[~all:c]; HAS_XAW(0.00)[]; ARC_NA(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, Sep 27, 2022 at 03:53:12PM -0500, Mike Karels wrote: > I recently noticed the following behavior: > > % ping6 redrock > ping6: Name does not resolve > % host redrock > redrock.karels.net has address 10.0.2.2 > redrock.karels.net mail is handled by 10 mail.karels.net. > % ping6 nonexistenthost > ping6: Name does not resolve > > The first error message is misleading, because the name *does* resolve, > but has no AAAA record, and it is the same error message as for a name > that truly does not exist. The problem comes from the set of error > codes that getaddrinfo() returns in these two cases. The problem did > not exist with gethostbyname(), which has separate error codes for the > two (although gethostbyname did not have provision for IPv6, it handled > cases like domain names and mail domains without IPv4 addresses). > > getaddrinfo() uses a richer set of error codes than gethostbyname(), but > still misses this case. However, looking at , I see > > #if 0 > /* Obsoleted on RFC 2553bis-02 */ > #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ > #endif > ... > #if 0 > /* Obsoleted on RFC 2553bis-02 */ > #define EAI_NODATA 7 /* no address associated with hostname */ > #endif > > I don't know why these two were omitted from the update to RFC 2553, but > the first seems to me to be the correct error for an existing name without > an address for the requested address family. Also, that is the error > message produced by Linux (Ubuntu 22.04.1). > > NetBSD and OpenBSD produce the second of these two errors for a host > without the requested address. But they also produce the same error > when a name does not exist. > > RFC 2553bis-02 has timed out, and is replaced by RFC 3493, which is also > missing EAI_ADDRFAMILY. These are informational RFCs, not specifying an > Internet standard. > > I propose re-enabling EAI_ADDRFAMILY and using it for the situation > where a name exists but does not have an address in the requested family. > This would make the error in the example less misleading, and would behave > the same as Linux in this regard. The change to netdb.h is trivial, but > getaddrinfo() needs a little more work because it uses the NS_* errors > from internally and then translates. But it will benefit > from greater accuracy in other cases as well (e.g. "out of memory" > rather than "Name does not resolve"). > > Comments? I have a change in progress, but wanted to float the idea > before I finish it and put it into review. Perhaps look there https://www.openwall.com/lists/libc-coord/2022/09/27/1 You might want to participate in the thread, instead of me.