From owner-cvs-all Sun Jul 22 17:40:51 2001 Delivered-To: cvs-all@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 2CD5B37B406; Sun, 22 Jul 2001 17:40:43 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.4/8.11.4) with ESMTP id f6N0efI00987; Mon, 23 Jul 2001 01:40:41 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.4/8.11.4) with ESMTP id f6N0efg12288; Mon, 23 Jul 2001 01:40:41 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200107230040.f6N0efg12288@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Hajimu UMEMOTO Cc: brian@Awfulhak.org, brian@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org, brian@Awfulhak.org Subject: Re: cvs commit: src/lib/libutil realhostname.c In-Reply-To: Message from Hajimu UMEMOTO of "Mon, 23 Jul 2001 05:52:25 +0900." <20010723.055225.111155784.ume@mahoroba.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 23 Jul 2001 01:40:40 +0100 From: Brian Somers Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > >>>>> On Sun, 22 Jul 2001 21:11:50 +0100 > >>>>> Brian Somers said: > > brian> With this patch, getaddrinfo() only comes back with the A record, and > > Yes, it is expected behavior. > > brian> realhostname_sa() fails (because it's not the same as the connecting > brian> IPv6 number). > > Umm, realhostname_sa() has a trick for this case. The past when I > tested it, it seemd working to me. > > #ifdef INET6 [.....] It seems to me that realhostname_sa() already has to deal specially with ipv4 mapped ipv6 addresses. Surely the correct answer is to special-case such addresses in the getaddrinfo() hints (see the attached patch - based on what's in -current at the moment). The only alternative that I can think of is to have getaddrinfo() with a hint of AF_UNSPEC end up finding all A and AAAA records. If it returns only one type of address, then it can't satisfy both the ipv4 mapped address case *and* the normal ipv6 case (as per my fec0::* addresses that I mentioned before). > -- > Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan > ume@mahoroba.org ume@bisd.hitachi.co.jp ume@{,jp.}FreeBSD.org > http://www.imasy.org/~ume/ Index: realhostname.c =================================================================== RCS file: /home/ncvs/src/lib/libutil/realhostname.c,v retrieving revision 1.12 diff -u -r1.12 realhostname.c --- realhostname.c 2001/07/21 00:18:54 1.12 +++ realhostname.c 2001/07/23 00:32:52 @@ -103,8 +103,17 @@ memset(&hints, 0, sizeof(struct addrinfo)); switch (addr->sa_family) { - case AF_INET: +#ifdef INET6 case AF_INET6: + if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr) + ->sin6_addr)) { + /* Special-case IP6 over IP4 stuff */ + hints.ai_family = AF_INET; + break; + } + /*FALLTHRU*/ +#endif + case AF_INET: hints.ai_family = addr->sa_family; break; default: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message