Merge "Request both v4 and v6 dns when on secondary net"

This commit is contained in:
Robert Greenwalt 2011-11-29 15:48:48 -08:00 committed by Android (Google) Code Review
commit e796d39d80

View File

@ -1867,6 +1867,19 @@ error:
free(elems); free(elems);
} }
static int _using_alt_dns()
{
char propname[PROP_NAME_MAX];
char propvalue[PROP_VALUE_MAX];
propvalue[0] = 0;
snprintf(propname, sizeof(propname), "net.dns1.%d", getpid());
if (__system_property_get(propname, propvalue) > 0 ) {
return 1;
}
return 0;
}
/*ARGSUSED*/ /*ARGSUSED*/
static int static int
_dns_getaddrinfo(void *rv, void *cb_data, va_list ap) _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
@ -1909,14 +1922,12 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
q.anslen = sizeof(buf->buf); q.anslen = sizeof(buf->buf);
int query_ipv6 = 1, query_ipv4 = 1; int query_ipv6 = 1, query_ipv4 = 1;
if (pai->ai_flags & AI_ADDRCONFIG) { if (pai->ai_flags & AI_ADDRCONFIG) {
query_ipv6 = _have_ipv6(); // Only implement AI_ADDRCONFIG if the application is not
query_ipv4 = _have_ipv4(); // using its own DNS servers, since our implementation
if (query_ipv6 == 0 && query_ipv4 == 0) { // only works on the default connection.
// Both our IPv4 and IPv6 connectivity probes failed, which indicates if (!_using_alt_dns()) {
// that we have neither an IPv4 or an IPv6 default route (and thus no query_ipv6 = _have_ipv6();
// global IPv4 or IPv6 connectivity). We might be in a walled garden. query_ipv4 = _have_ipv4();
// Throw up our arms and ask for both A and AAAA.
query_ipv6 = query_ipv4 = 1;
} }
} }
if (query_ipv6) { if (query_ipv6) {