Date: Mon, 23 Jul 2001 03:23:54 +0900 (JST) From: Hajimu UMEMOTO <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 Message-ID: <20010723.032354.31691239.ume@mahoroba.org> In-Reply-To: <200107221127.f6MBRXg02996@hak.lan.Awfulhak.org> References: <ume@mahoroba.org> <200107221127.f6MBRXg02996@hak.lan.Awfulhak.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> On Sun, 22 Jul 2001 12:27:33 +0100 >>>>> Brian Somers <brian@Awfulhak.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010723.032354.31691239.ume>