Reset connections on all stacked interfaces.

Bug: 8276725
Change-Id: I7fe99c6ea123037cef3e89e3c2c17ed43cc0b1ea
This commit is contained in:
Lorenzo Colitti
2013-03-20 19:22:58 +09:00
parent 52a5edce45
commit 6383982582
2 changed files with 28 additions and 18 deletions

View File

@@ -119,6 +119,15 @@ public class LinkProperties implements Parcelable {
return mIfaceName; return mIfaceName;
} }
public Collection<String> getAllInterfaceNames() {
Collection interfaceNames = new ArrayList<String>(mStackedLinks.size() + 1);
interfaceNames.add(new String(mIfaceName));
for (LinkProperties stacked: mStackedLinks.values()) {
interfaceNames.addAll(stacked.getAllInterfaceNames());
}
return interfaceNames;
}
public Collection<InetAddress> getAddresses() { public Collection<InetAddress> getAddresses() {
Collection<InetAddress> addresses = new ArrayList<InetAddress>(); Collection<InetAddress> addresses = new ArrayList<InetAddress>();
for (LinkAddress linkAddress : mLinkAddresses) { for (LinkAddress linkAddress : mLinkAddresses) {

View File

@@ -2256,26 +2256,27 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (resetMask != 0 || resetDns) { if (resetMask != 0 || resetDns) {
LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties(); LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties();
if (linkProperties != null) { if (linkProperties != null) {
String iface = linkProperties.getInterfaceName(); for (String iface : linkProperties.getAllInterfaceNames()) {
if (TextUtils.isEmpty(iface) == false) { if (TextUtils.isEmpty(iface) == false) {
if (resetMask != 0) { if (resetMask != 0) {
if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")"); if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")");
NetworkUtils.resetConnections(iface, resetMask); NetworkUtils.resetConnections(iface, resetMask);
// Tell VPN the interface is down. It is a temporary // Tell VPN the interface is down. It is a temporary
// but effective fix to make VPN aware of the change. // but effective fix to make VPN aware of the change.
if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) { if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) {
mVpn.interfaceStatusChanged(iface, false); mVpn.interfaceStatusChanged(iface, false);
}
} }
} if (resetDns) {
if (resetDns) { flushVmDnsCache();
flushVmDnsCache(); if (VDBG) log("resetting DNS cache for " + iface);
if (VDBG) log("resetting DNS cache for " + iface); try {
try { mNetd.flushInterfaceDnsCache(iface);
mNetd.flushInterfaceDnsCache(iface); } catch (Exception e) {
} catch (Exception e) { // never crash - catch them all
// never crash - catch them all if (DBG) loge("Exception resetting dns cache: " + e);
if (DBG) loge("Exception resetting dns cache: " + e); }
} }
} }
} }