Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2001 01:40:40 +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:  <200107230040.f6N0efg12288@hak.lan.Awfulhak.org>
In-Reply-To: Message from Hajimu UMEMOTO <ume@mahoroba.org>  of "Mon, 23 Jul 2001 05:52:25 %2B0900." <20010723.055225.111155784.ume@mahoroba.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> >>>>> On Sun, 22 Jul 2001 21:11:50 +0100
> >>>>> Brian Somers <brian@Awfulhak.org> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107230040.f6N0efg12288>