Fix the detection of alt-network in dns resolver.
Used to determine proper A/AAAA record request. bug:10132565 Change-Id: I7229f6672e879920a6fae58672cddd72db78546c
This commit is contained in:
parent
3287dccf2e
commit
1d8d9a308c
|
@ -93,6 +93,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include "resolv_private.h"
|
#include "resolv_private.h"
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -1864,17 +1865,19 @@ error:
|
||||||
free(elems);
|
free(elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _using_alt_dns()
|
static bool _using_default_dns(const char *iface)
|
||||||
{
|
{
|
||||||
char propname[PROP_NAME_MAX];
|
char buf[IF_NAMESIZE+1];
|
||||||
char propvalue[PROP_VALUE_MAX];
|
size_t if_len;
|
||||||
|
|
||||||
propvalue[0] = 0;
|
// common case
|
||||||
snprintf(propname, sizeof(propname), "net.dns1.%d", getpid());
|
if (iface == NULL || *iface == '\0') return true;
|
||||||
if (__system_property_get(propname, propvalue) > 0 ) {
|
|
||||||
return 1;
|
if_len = _resolv_get_default_iface(buf, sizeof(buf));
|
||||||
|
if (if_len + 1 <= sizeof(buf)) {
|
||||||
|
if (strcmp(buf, iface) != 0) return false;
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
|
@ -1924,7 +1927,7 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||||
// Only implement AI_ADDRCONFIG if the application is not
|
// Only implement AI_ADDRCONFIG if the application is not
|
||||||
// using its own DNS servers, since our implementation
|
// using its own DNS servers, since our implementation
|
||||||
// only works on the default connection.
|
// only works on the default connection.
|
||||||
if (!_using_alt_dns()) {
|
if (_using_default_dns(iface)) {
|
||||||
query_ipv6 = _have_ipv6();
|
query_ipv6 = _have_ipv6();
|
||||||
query_ipv4 = _have_ipv4();
|
query_ipv4 = _have_ipv4();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue