From owner-cvs-all Sun Jul 22 11:24:52 2001 Delivered-To: cvs-all@freebsd.org Received: from light.imasy.or.jp (light.imasy.or.jp [202.227.24.4]) by hub.freebsd.org (Postfix) with ESMTP id 0E10F37B403; Sun, 22 Jul 2001 11:24:38 -0700 (PDT) (envelope-from ume@mahoroba.org) Received: (from uucp@localhost) by light.imasy.or.jp (8.11.3+3.4W/8.11.3/light) with UUCP id f6MIOOw13330; Mon, 23 Jul 2001 03:24:24 +0900 (JST) (envelope-from ume@mahoroba.org) Received: from peace.mahoroba.org (IDENT:JOSTYdi8Ur5CrJk+k9EkV/ZWw9Ex/ZZ78CsBjL/oRbk6nPaWZ8ALiQousOEQS7Qz@peace.mahoroba.org [2001:200:301:0:200:f8ff:fe05:3eae]) (authenticated as ume with CRAM-MD5) by mail.mahoroba.org (8.11.4/8.11.4/chaos) with ESMTP/inet6 id f6MINxL28154; Mon, 23 Jul 2001 03:23:59 +0900 (JST) (envelope-from ume@mahoroba.org) Date: Mon, 23 Jul 2001 03:23:54 +0900 (JST) Message-Id: <20010723.032354.31691239.ume@mahoroba.org> To: brian@Awfulhak.org Cc: brian@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libutil realhostname.c From: Hajimu UMEMOTO In-Reply-To: <200107221127.f6MBRXg02996@hak.lan.Awfulhak.org> References: <200107221127.f6MBRXg02996@hak.lan.Awfulhak.org> X-Mailer: xcite1.38> Mew version 1.95b119 on Emacs 20.7 / Mule 4.0 =?iso-2022-jp?B?KBskQjJWMWMbKEIp?= X-PGP-Public-Key: http://www.imasy.org/~ume/publickey.asc X-PGP-Fingerprint: 6B 0C 53 FC 5D D0 37 91 05 D0 B3 EF 36 9B 6A BC X-URL: http://www.imasy.org/~ume/ X-Operating-System: FreeBSD 5.0-CURRENT Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 12:27:33 +0100 >>>>> Brian Somers said: brian> But with such services enabled, surely the connection's sockaddr will brian> show up as ::ffff:w.x.y.z where w.x.y.z is the IPv4 address of the brian> connecting host ? I'm guessing that if such an address is going to brian> reverse resolve, then the forward resolution should be available too, brian> meaning reverse dns: brian> $ORIGIN f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT. brian> z.y.x.w IN PTR some.domain.name. brian> and forward dns: brian> $ORIGIN domain.name. brian> some IN A w.x.y.z brian> IN AAAA ::ffff:w.x.y.z brian> or is the DNS for such connections meant to magically DTRT without brian> the above entries ? Yes, you don't need extra AAAA RR for ::ffff:w.x.y.z. It is treated as IPv4 address in getnameinfo(3) (actually getipnodebyaddr(3)). Once getnameinfo(3) returns FQDN, FQDN itself doesn't have the information whether the address is ::ffff:w.x.y.z or w.x.y.z. This is why we need AF_UNSPEC to getaddrinfo(3). Unless it, we cannot get A RR for ::ffff:w.x.y.z. brian> Unfortunately this doesn't work. getnameinfo() already does the brian> right thing (it gets the name from the ip6.int entry in my DNS) which brian> says: brian> $ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.IP6.INT. brian> 1.0.0.0.0 IN PTR gw.lan.Awfulhak.org. I forgot the fact you have AAAA RR. NI_WITHSCOPEID is meaningless in your case. When AAAA RR is not available, NI_WITHSCOPEID adds a scope identifier to a resulted string form of an IPv6 address. Then, information for scope is not lost. brian> the problem was that giving getaddrinfo() hints with AF_UNSPEC only brian> brought back the A records, and not the AAAA records for the name. brian> My DNS says: brian> $ORIGIN lan.Awfulhak.org. brian> gw IN A 172.16.0.1 brian> IN AAAA fec0::1 Okay, I understand your problem. brian> Giving getaddrinfo() hints with AF_INET6 gets the AAAA record. Umm, getaddrinfo(3) searches AAAA RR even if AF_UNSPEC is specified. What's happen? brian> Interestingly enough, getaddrinfo seemed to be returning two brian> 172.16.0.1 INET entries when it was given AF_UNSPEC in the hints.... brian> I don't know if that's relevant in any way though. I see. realhostname_sa(3) didn't initialize hints correctly. Please try this: Index: lib/libutil/realhostname.c =================================================================== RCS file: /home/ncvs/src/lib/libutil/realhostname.c,v retrieving revision 1.12 diff -u -r1.12 realhostname.c --- lib/libutil/realhostname.c 2001/07/21 00:18:54 1.12 +++ lib/libutil/realhostname.c 2001/07/22 18:20:19 @@ -96,7 +96,8 @@ result = HOSTNAME_INVALIDADDR; - error = getnameinfo(addr, addrlen, buf, sizeof(buf), NULL, 0, 0); + error = getnameinfo(addr, addrlen, buf, sizeof(buf), NULL, 0, + NI_WITHSCOPEID); if (error == 0) { struct addrinfo hints, *res, *ores; struct sockaddr *sa; @@ -111,7 +112,8 @@ hints.ai_family = AF_UNSPEC; break; } - hints.ai_flags = AI_CANONNAME; + hints.ai_flags = AI_CANONNAME | AI_PASSIVE; + hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(buf, NULL, &hints, &res); if (error) { -- 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/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message