Author: ume
Date: Thu Jan 17 16:11:38 2013
New Revision: 245553
URL: http://svnweb.freebsd.org/changeset/base/245553

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

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

Modified: stable/9/lib/libc/net/name6.c
==============================================================================
--- stable/9/lib/libc/net/name6.c       Thu Jan 17 15:45:45 2013        
(r245552)
+++ stable/9/lib/libc/net/name6.c       Thu Jan 17 16:11:38 2013        
(r245553)
@@ -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
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to