diff options
| author | 2013-03-28 14:13:43 +0900 | |
|---|---|---|
| committer | 2013-03-28 14:45:36 +0900 | |
| commit | d2ef1e50c491239e43c7b557ea1f7fc03e84f8f9 (patch) | |
| tree | 54d450e7e471a78f416f000f51bf218c42073c0f | |
| parent | 7e81e223f5d6152e35b8a441330e142734fb7afa (diff) | |
Stop clat if it's no longer in use.
Normally, clatd is stopped when a connection disconnects.
However, if the connection's LinkProperties change, or if the
disconnect somehow gets lost (e.g., because of bug 8486114),
then we need to stop it (and possibly restart it).
Bug: 8276725
Change-Id: Ib8ad0d653ed8d0cd70b7414bcaa8fdaef8ba5fcc
| -rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 10 | ||||
| -rw-r--r-- | services/java/com/android/server/connectivity/Nat464Xlat.java | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 6dcb4034e500..9daf0386a9ff 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -2284,9 +2284,17 @@ public class ConnectivityService extends IConnectivityManager.Stub { } // Update 464xlat state. - // TODO: Move to handleConnect() NetworkStateTracker tracker = mNetTrackers[netType]; if (mClat.requiresClat(netType, tracker)) { + // If the connection was previously using clat, but is not using it now, stop the clat + // daemon. Normally, this happens automatically when the connection disconnects, but if + // the disconnect is not reported, or if the connection's LinkProperties changed for + // some other reason (e.g., handoff changes the IP addresses on the link), it would + // still be running. If it's not running, then stopping it is a no-op. + if (Nat464Xlat.isRunningClat(curLp) && !Nat464Xlat.isRunningClat(newLp)) { + mClat.stopClat(); + } + // If the link requires clat to be running, then start the daemon now. if (mNetTrackers[netType].getNetworkInfo().isConnected()) { mClat.startClat(tracker); } else { diff --git a/services/java/com/android/server/connectivity/Nat464Xlat.java b/services/java/com/android/server/connectivity/Nat464Xlat.java index 2884eafd07f6..59403c559dfa 100644 --- a/services/java/com/android/server/connectivity/Nat464Xlat.java +++ b/services/java/com/android/server/connectivity/Nat464Xlat.java @@ -87,6 +87,10 @@ public class Nat464Xlat extends BaseNetworkObserver { return netType == TYPE_MOBILE && !lp.hasIPv4Address(); } + public static boolean isRunningClat(LinkProperties lp) { + return lp != null && lp.getAllInterfaceNames().contains(CLAT_INTERFACE_NAME); + } + /** * Starts the clat daemon. * @param lp The link properties of the interface to start clatd on. |