From 4a243f5ea171ba5868bc2854ef8e0178171b78e3 Mon Sep 17 00:00:00 2001 From: Chia-chi Yeh Date: Mon, 15 Aug 2011 15:19:40 -0700 Subject: [PATCH] VPN: reset legacy VPN when resetting IPv4 addresses. Currently legacy VPN only works on IPv4, and it should always turn down when the addresses are changed. It assumed that the interface will be brought down and up, so the event can be detected via interfaceStatusChanged(). However, the assumption was incorrect and the event is actually driver-dependent. To fix this issue, ConnectivityService now tells VPN that the interface is down when resetting IPv4 addresses. Change-Id: I76d15e56552d86635c5b274ca980be5da905a6fb --- .../java/com/android/server/ConnectivityService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index a5066367e2..81dc1a89c8 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -1780,14 +1780,20 @@ public class ConnectivityService extends IConnectivityManager.Stub { mCurrentLinkProperties[netType] = newLp; boolean resetDns = updateRoutes(newLp, curLp, mNetConfigs[netType].isDefault()); - if (doReset || resetMask != 0 || resetDns) { + if (resetMask != 0 || resetDns) { LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties(); if (linkProperties != null) { String iface = linkProperties.getInterfaceName(); if (TextUtils.isEmpty(iface) == false) { - if (doReset || resetMask != 0) { + 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); + } } if (resetDns) { if (DBG) log("resetting DNS cache for " + iface);