From 6383982582abac178f2e0fcb17c35304d23e6d09 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Wed, 20 Mar 2013 19:22:58 +0900 Subject: [PATCH] Reset connections on all stacked interfaces. Bug: 8276725 Change-Id: I7fe99c6ea123037cef3e89e3c2c17ed43cc0b1ea --- core/java/android/net/LinkProperties.java | 9 +++++ .../android/server/ConnectivityService.java | 37 ++++++++++--------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index 4457a22844..e5227548b5 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -119,6 +119,15 @@ public class LinkProperties implements Parcelable { return mIfaceName; } + public Collection getAllInterfaceNames() { + Collection interfaceNames = new ArrayList(mStackedLinks.size() + 1); + interfaceNames.add(new String(mIfaceName)); + for (LinkProperties stacked: mStackedLinks.values()) { + interfaceNames.addAll(stacked.getAllInterfaceNames()); + } + return interfaceNames; + } + public Collection getAddresses() { Collection addresses = new ArrayList(); for (LinkAddress linkAddress : mLinkAddresses) { diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 72d249aa28..6dcb4034e5 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -2256,26 +2256,27 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (resetMask != 0 || resetDns) { LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties(); if (linkProperties != null) { - String iface = linkProperties.getInterfaceName(); - if (TextUtils.isEmpty(iface) == false) { - if (resetMask != 0) { - if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")"); - NetworkUtils.resetConnections(iface, resetMask); + for (String iface : linkProperties.getAllInterfaceNames()) { + if (TextUtils.isEmpty(iface) == false) { + if (resetMask != 0) { + if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")"); + NetworkUtils.resetConnections(iface, resetMask); - // Tell VPN the interface is down. It is a temporary - // but effective fix to make VPN aware of the change. - if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) { - mVpn.interfaceStatusChanged(iface, false); + // Tell VPN the interface is down. It is a temporary + // but effective fix to make VPN aware of the change. + if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) { + mVpn.interfaceStatusChanged(iface, false); + } } - } - if (resetDns) { - flushVmDnsCache(); - if (VDBG) log("resetting DNS cache for " + iface); - try { - mNetd.flushInterfaceDnsCache(iface); - } catch (Exception e) { - // never crash - catch them all - if (DBG) loge("Exception resetting dns cache: " + e); + if (resetDns) { + flushVmDnsCache(); + if (VDBG) log("resetting DNS cache for " + iface); + try { + mNetd.flushInterfaceDnsCache(iface); + } catch (Exception e) { + // never crash - catch them all + if (DBG) loge("Exception resetting dns cache: " + e); + } } } }