Don't flush DNS cache on route changes.
Since Lollipop, routes are isolated within Networks. Flushing a Network's DNS cache whenever that same Network's routes are updated doesn't provide any benefit. Any system components depending on this behaviour need to uncovered and fixed. Additionally, clean up no-longer-used flushNetworkDnsCache(). This should be replaced, when needed, by a proper binder interface to netd. Change-Id: I34bf79e4839da014d466058a876d754209d0c007
This commit is contained in:
@@ -4134,8 +4134,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// }
|
// }
|
||||||
updateTcpBufferSizes(networkAgent);
|
updateTcpBufferSizes(networkAgent);
|
||||||
|
|
||||||
final boolean flushDns = updateRoutes(newLp, oldLp, netId);
|
updateRoutes(newLp, oldLp, netId);
|
||||||
updateDnses(newLp, oldLp, netId, flushDns);
|
updateDnses(newLp, oldLp, netId);
|
||||||
|
|
||||||
updateClat(newLp, oldLp, networkAgent);
|
updateClat(newLp, oldLp, networkAgent);
|
||||||
if (isDefaultNetwork(networkAgent)) {
|
if (isDefaultNetwork(networkAgent)) {
|
||||||
@@ -4238,30 +4238,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return !routeDiff.added.isEmpty() || !routeDiff.removed.isEmpty();
|
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)) {
|
||||||
if (oldLp == null || (newLp.isIdenticalDnses(oldLp) == false)) {
|
return; // no updating necessary
|
||||||
Collection<InetAddress> dnses = newLp.getDnsServers();
|
|
||||||
if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses);
|
|
||||||
try {
|
|
||||||
mNetd.setDnsServersForNetwork(netId, NetworkUtils.makeStrings(dnses),
|
|
||||||
newLp.getDomains());
|
|
||||||
} catch (Exception e) {
|
|
||||||
loge("Exception in setDnsServersForNetwork: " + e);
|
|
||||||
}
|
|
||||||
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
|
||||||
if (defaultNai != null && defaultNai.network.netId == netId) {
|
|
||||||
setDefaultDnsSystemProperties(dnses);
|
|
||||||
}
|
|
||||||
flushVmDnsCache();
|
|
||||||
} else if (flush) {
|
|
||||||
try {
|
|
||||||
mNetd.flushNetworkDnsCache(netId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
loge("Exception in flushNetworkDnsCache: " + e);
|
|
||||||
}
|
|
||||||
flushVmDnsCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collection<InetAddress> dnses = newLp.getDnsServers();
|
||||||
|
if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses);
|
||||||
|
try {
|
||||||
|
mNetd.setDnsServersForNetwork(
|
||||||
|
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
|
||||||
|
} catch (Exception e) {
|
||||||
|
loge("Exception in setDnsServersForNetwork: " + e);
|
||||||
|
}
|
||||||
|
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||||
|
if (defaultNai != null && defaultNai.network.netId == netId) {
|
||||||
|
setDefaultDnsSystemProperties(dnses);
|
||||||
|
}
|
||||||
|
flushVmDnsCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultDnsSystemProperties(Collection<InetAddress> dnses) {
|
private void setDefaultDnsSystemProperties(Collection<InetAddress> dnses) {
|
||||||
|
|||||||
Reference in New Issue
Block a user