Merge "Eschew unspecified IP addresses for DNS servers"
diff --git a/services/net/java/android/net/ip/IpManager.java b/services/net/java/android/net/ip/IpManager.java
index 87018ec..abdf683 100644
--- a/services/net/java/android/net/ip/IpManager.java
+++ b/services/net/java/android/net/ip/IpManager.java
@@ -865,13 +865,7 @@
for (RouteInfo route : netlinkLinkProperties.getRoutes()) {
newLp.addRoute(route);
}
- for (InetAddress dns : netlinkLinkProperties.getDnsServers()) {
- // Only add likely reachable DNS servers.
- // TODO: investigate deleting this.
- if (newLp.isReachable(dns)) {
- newLp.addDnsServer(dns);
- }
- }
+ addAllReachableDnsServers(newLp, netlinkLinkProperties.getDnsServers());
// [3] Add in data from DHCPv4, if available.
//
@@ -881,13 +875,7 @@
for (RouteInfo route : mDhcpResults.getRoutes(mInterfaceName)) {
newLp.addRoute(route);
}
- for (InetAddress dns : mDhcpResults.dnsServers) {
- // Only add likely reachable DNS servers.
- // TODO: investigate deleting this.
- if (newLp.isReachable(dns)) {
- newLp.addDnsServer(dns);
- }
- }
+ addAllReachableDnsServers(newLp, mDhcpResults.dnsServers);
newLp.setDomains(mDhcpResults.domains);
if (mDhcpResults.mtu != 0) {
@@ -909,6 +897,18 @@
return newLp;
}
+ private static void addAllReachableDnsServers(
+ LinkProperties lp, Iterable<InetAddress> dnses) {
+ // TODO: Investigate deleting this reachability check. We should be
+ // able to pass everything down to netd and let netd do evaluation
+ // and RFC6724-style sorting.
+ for (InetAddress dns : dnses) {
+ if (!dns.isAnyLocalAddress() && lp.isReachable(dns)) {
+ lp.addDnsServer(dns);
+ }
+ }
+ }
+
// Returns false if we have lost provisioning, true otherwise.
private boolean handleLinkPropertiesUpdate(boolean sendCallbacks) {
final LinkProperties newLp = assembleLinkProperties();