Revert "Use framework hints to determine dns query type."
Change Ife82a8d8 broke IPv6 on wifi. Change I4e3a69ea is an alternate approach that does not require any framework changes. Bug: 5284168 Change-Id: Ib52614be3875a2ae2eaedd1be265f90e506eda41
This commit is contained in:
parent
0096491274
commit
b82532d11a
@ -377,20 +377,9 @@ _test_connect(int pf, struct sockaddr *addr, size_t addrlen) {
|
|||||||
* available, but whether addresses of the specified family are "configured
|
* available, but whether addresses of the specified family are "configured
|
||||||
* on the local system". However, bionic doesn't currently support getifaddrs,
|
* on the local system". However, bionic doesn't currently support getifaddrs,
|
||||||
* so checking for connectivity is the next best thing.
|
* so checking for connectivity is the next best thing.
|
||||||
*
|
|
||||||
* Note that simply checking connectivity is going to do the wrong thing on
|
|
||||||
* multihomed devices. Now we pass in a hint from the framework about what
|
|
||||||
* to use for this request ("v4", "v4v6", or "v6").
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_have_ipv6(const char *propvalue) {
|
_have_ipv6() {
|
||||||
if (*propvalue != 0) {
|
|
||||||
if ((strcmp(propvalue, "v4v6") == 0) || (strcmp(propvalue, "v6") == 0)) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
static const struct sockaddr_in6 sin6_test = {
|
static const struct sockaddr_in6 sin6_test = {
|
||||||
.sin6_family = AF_INET6,
|
.sin6_family = AF_INET6,
|
||||||
.sin6_addr.s6_addr = { // 2000::
|
.sin6_addr.s6_addr = { // 2000::
|
||||||
@ -398,21 +387,16 @@ _have_ipv6(const char *propvalue) {
|
|||||||
};
|
};
|
||||||
sockaddr_union addr = { .in6 = sin6_test };
|
sockaddr_union addr = { .in6 = sin6_test };
|
||||||
return _test_connect(PF_INET6, &addr.generic, sizeof(addr.in6));
|
return _test_connect(PF_INET6, &addr.generic, sizeof(addr.in6));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_have_ipv4(const char *propvalue) {
|
_have_ipv4() {
|
||||||
if (*propvalue != 0) {
|
|
||||||
return (strncmp(propvalue, "v4", 2) == 0);
|
|
||||||
} else {
|
|
||||||
static const struct sockaddr_in sin_test = {
|
static const struct sockaddr_in sin_test = {
|
||||||
.sin_family = AF_INET,
|
.sin_family = AF_INET,
|
||||||
.sin_addr.s_addr = __constant_htonl(0x08080808L) // 8.8.8.8
|
.sin_addr.s_addr = __constant_htonl(0x08080808L) // 8.8.8.8
|
||||||
};
|
};
|
||||||
sockaddr_union addr = { .in = sin_test };
|
sockaddr_union addr = { .in = sin_test };
|
||||||
return _test_connect(PF_INET, &addr.generic, sizeof(addr.in));
|
return _test_connect(PF_INET, &addr.generic, sizeof(addr.in));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns 0 on success, else returns non-zero on error (in which case
|
// Returns 0 on success, else returns non-zero on error (in which case
|
||||||
@ -1925,16 +1909,8 @@ _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) {
|
||||||
/* check if the fwk gave us a hint */
|
query_ipv6 = _have_ipv6();
|
||||||
char propname[PROP_NAME_MAX];
|
query_ipv4 = _have_ipv4();
|
||||||
char propvalue[PROP_VALUE_MAX];
|
|
||||||
propvalue[0] = 0;
|
|
||||||
snprintf(propname, sizeof(propname), "net.dnsproto.%d", getpid());
|
|
||||||
if (__system_property_get(propname, propvalue) <= 0) {
|
|
||||||
__system_property_get("net.dnsproto", propvalue);
|
|
||||||
}
|
|
||||||
query_ipv6 = _have_ipv6(propvalue);
|
|
||||||
query_ipv4 = _have_ipv4(propvalue);
|
|
||||||
}
|
}
|
||||||
if (query_ipv6) {
|
if (query_ipv6) {
|
||||||
q.qtype = T_AAAA;
|
q.qtype = T_AAAA;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user