summaryrefslogtreecommitdiffstats
path: root/libc/netbsd/net
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-11-21 15:14:19 -0800
committerRobert Greenwalt <rgreenwalt@google.com>2011-11-22 15:24:44 -0800
commitca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d (patch)
treec8644c6e427f477c9f7ed31a8dd0ade1b81a94a7 /libc/netbsd/net
parent7e2daefe6cec40e143f519c46aec877ee053b407 (diff)
downloadbionic-ca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d.zip
bionic-ca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d.tar.gz
bionic-ca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d.tar.bz2
Request both v4 and v6 dns when on secondary net
We can't easily tell the protocol family of the secondary network, so try both and trust that the carrier has configured dns servers according to the protocols supported on its network. bug:5468224 Change-Id: If4f017573d313a6ad8354574076de6d63d43b444
Diffstat (limited to 'libc/netbsd/net')
-rw-r--r--libc/netbsd/net/getaddrinfo.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index ace8c1a..6ae6e3e 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -1867,6 +1867,19 @@ error:
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*/
static int
_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);
int query_ipv6 = 1, query_ipv4 = 1;
if (pai->ai_flags & AI_ADDRCONFIG) {
- query_ipv6 = _have_ipv6();
- query_ipv4 = _have_ipv4();
- if (query_ipv6 == 0 && query_ipv4 == 0) {
- // Both our IPv4 and IPv6 connectivity probes failed, which indicates
- // that we have neither an IPv4 or an IPv6 default route (and thus no
- // global IPv4 or IPv6 connectivity). We might be in a walled garden.
- // Throw up our arms and ask for both A and AAAA.
- query_ipv6 = query_ipv4 = 1;
+ // Only implement AI_ADDRCONFIG if the application is not
+ // using its own DNS servers, since our implementation
+ // only works on the default connection.
+ if (!_using_alt_dns()) {
+ query_ipv6 = _have_ipv6();
+ query_ipv4 = _have_ipv4();
}
}
if (query_ipv6) {