Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jul 2001 21:11:50 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        Hajimu UMEMOTO <ume@mahoroba.org>
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 
Message-ID:  <200107222011.f6MKBog08546@hak.lan.Awfulhak.org>
In-Reply-To: Message from Hajimu UMEMOTO <ume@mahoroba.org>  of "Mon, 23 Jul 2001 03:23:54 %2B0900." <20010723.032354.31691239.ume@mahoroba.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 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) {
> 

With this patch, getaddrinfo() only comes back with the A record, and 
realhostname_sa() fails (because it's not the same as the connecting 
IPv6 number).

I'd try to be of more help, but I'm still confused about the 
intention of the getaddrinfo() hints.  For the ::ffff:w.x.y.z 
addresses, surely looking that up and getting whatever w.x.y.z's PTR 
record refers to, then trying to get an A record back from that will 
just end up with ``w.x.y.z'' -- which won't match the original IP and 
will just make things fail.

I'm assuming the following DNS setup now:

$ORIGIN y.x.w.in-addr.any.
z	IN	PTR	some.domain.name.

$ORIGIN domain.name.
some	IN	A	w.x.y.z

If you could give me a better idea about what's supposed to happen 
(or point me at an RFC or something) it'd be appreciated.  Sorry to 
be such a PITA :-/

> --
> 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/

Thanks.
-- 
Brian <brian@freebsd-services.com>                <brian@Awfulhak.org>
      http://www.freebsd-services.com/        <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !      <brian@[uk.]OpenBSD.org>



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?200107222011.f6MKBog08546>