From 307c525382d5f1454e37a0ae9d785fec71306264 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Thu, 21 Jun 2018 17:52:55 +0100 Subject: [PATCH] Do not disconnect existing VPN if seamless handover fails If error happens during establishing of VPN, the cleanup logic tries to disconnect the partially-created VPN network. At the moment this is not working during VPN seamless handover since in this case no new network is created and the existing VPN will be disconnected. Fix by not disconnecting during the VPN handover case. Test: cts-tradefed run commandAndExit cts-dev -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideVpnTests Bug: 110238496 Change-Id: I8cb2ab50596e61b0ac09e89eb1048816f00180d6 --- services/core/java/com/android/server/connectivity/Vpn.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 0271d3bcb57ca..1275302cd8c94 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -1141,7 +1141,11 @@ public class Vpn { } } catch (RuntimeException e) { IoUtils.closeQuietly(tun); - agentDisconnect(); + // If this is not seamless handover, disconnect partially-established network when error + // occurs. + if (oldNetworkAgent != mNetworkAgent) { + agentDisconnect(); + } // restore old state mConfig = oldConfig; mConnection = oldConnection;