diff options
| author | 2014-08-06 15:51:33 -0400 | |
|---|---|---|
| committer | 2014-08-06 22:39:40 -0400 | |
| commit | 5fb2c6ffe75d4089ec57ae42f2e5c7423c648dec (patch) | |
| tree | 3e5eae3cfbd5c6c343baafd7ecfeee4f27b47c87 | |
| parent | b69a3a8eaade042aa5b4d17f9b0dfd565c2e4a97 (diff) | |
Flush DNS cache when routes change.
We used to do this but the change got lost in the NetworkAgent
upgrade. This brings it back. ConnectivityService has netd do
the actual flushing.
bug:16549455
Change-Id: I11ddd55fcb9d1ed1d2c6a9be7eb8c57e41bdbdb8
| -rw-r--r-- | services/core/java/com/android/server/ConnectivityService.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index a00fbf353315..9ca795586352 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -4246,8 +4246,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { // for (LinkProperties lp : newLp.getStackedLinks()) { // updateMtu(lp, null); // } - updateRoutes(newLp, oldLp, netId); - updateDnses(newLp, oldLp, netId); + final boolean flushDns = updateRoutes(newLp, oldLp, netId); + updateDnses(newLp, oldLp, netId, flushDns); updateClat(newLp, oldLp, networkAgent); } @@ -4295,7 +4295,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - private void updateRoutes(LinkProperties newLp, LinkProperties oldLp, int netId) { + /** + * Have netd update routes from oldLp to newLp. + * @return true if routes changed between oldLp and newLp + */ + private boolean updateRoutes(LinkProperties newLp, LinkProperties oldLp, int netId) { CompareResult<RouteInfo> routeDiff = new CompareResult<RouteInfo>(); if (oldLp != null) { routeDiff = oldLp.compareAllRoutes(newLp); @@ -4330,8 +4334,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("Exception in removeRoute: " + e); } } + return !routeDiff.added.isEmpty() || !routeDiff.removed.isEmpty(); } - private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId) { + private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId, boolean flush) { if (oldLp == null || (newLp.isIdenticalDnses(oldLp) == false)) { Collection<InetAddress> dnses = newLp.getDnsServers(); if (dnses.size() == 0 && mDefaultDns != null) { @@ -4352,6 +4357,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { setDefaultDnsSystemProperties(dnses); } flushVmDnsCache(); + } else if (flush) { + try { + mNetd.flushNetworkDnsCache(netId); + } catch (Exception e) { + loge("Exception in flushNetworkDnsCache: " + e); + } + flushVmDnsCache(); } } |