Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2013 17:05:55 +0000 (UTC)
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r245557 - stable/8/lib/libc/net
Message-ID:  <201301171705.r0HH5tfe020863@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ume
Date: Thu Jan 17 17:05:54 2013
New Revision: 245557
URL: http://svnweb.freebsd.org/changeset/base/245557

Log:
  MFC r245225, r245256: Restrict use of source address selection
  of getipnodebyname(1) only to IPv6 address.

Modified:
  stable/8/lib/libc/net/name6.c
Directory Properties:
  stable/8/lib/libc/   (props changed)

Modified: stable/8/lib/libc/net/name6.c
==============================================================================
--- stable/8/lib/libc/net/name6.c	Thu Jan 17 16:43:59 2013	(r245556)
+++ stable/8/lib/libc/net/name6.c	Thu Jan 17 17:05:54 2013	(r245557)
@@ -200,6 +200,7 @@ static struct	 hostent *_hpmapv6(struct 
 #endif
 static struct	 hostent *_hpsort(struct hostent *, res_state);
 
+#ifdef INET6
 static struct	 hostent *_hpreorder(struct hostent *);
 static int	 get_addrselectpolicy(struct policyhead *);
 static void	 free_addrselectpolicy(struct policyhead *);
@@ -209,6 +210,7 @@ static void	 set_source(struct hp_order 
 static int	 matchlen(struct sockaddr *, struct sockaddr *);
 static int	 comp_dst(const void *, const void *);
 static int	 gai_addr2scopetype(struct sockaddr *);
+#endif
 
 /*
  * Functions defined in RFC2553
@@ -285,8 +287,10 @@ getipnodebyname(const char *name, int af
 	
 	hp = gethostbyname2(name, af);
 	hp = _hpcopy(hp, errp);
-
 #ifdef INET6
+	if (af == AF_INET6)
+		hp = _hpreorder(hp);
+
 	if (af == AF_INET6 && ((flags & AI_ALL) || hp == NULL) &&
 	    MAPADDRENABLED(flags)) {
 		struct hostent *hp2 = gethostbyname2(name, AF_INET);
@@ -309,7 +313,7 @@ getipnodebyname(const char *name, int af
 		*errp = statp->res_h_errno;
 	
 	statp->options = options;
-	return _hpreorder(_hpsort(hp, statp));
+	return _hpsort(hp, statp);
 }
 
 struct hostent *
@@ -632,6 +636,7 @@ _hpsort(struct hostent *hp, res_state st
 	return hp;
 }
 
+#ifdef INET6
 /*
  * _hpreorder: sort address by default address selection
  */
@@ -1109,3 +1114,4 @@ gai_addr2scopetype(struct sockaddr *sa)
 		return(-1);
 	}
 }
+#endif



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