From 683ce91486048484979746c9174be303ab45ba33 Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Mon, 17 Feb 2020 17:46:23 -0800 Subject: [PATCH] Pass server address directly to IKE. This change updates the buildIkeSessionParams() method to use the new IKE API that allows the VPN to pass the server address, and let IKE do the DNS resolution. Bug: 149356682 Test: FrameworksNetTests passing Change-Id: Ic1077c6eb1f49bca9331e49555b3787cee02788c Merged-In: Ic1077c6eb1f49bca9331e49555b3787cee02788c --- services/core/java/com/android/server/connectivity/Vpn.java | 5 +++-- .../java/com/android/server/connectivity/VpnIkev2Utils.java | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 84ed7fbc73e59..e6c1aa4753215 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -2353,10 +2353,11 @@ public class Vpn { // TODO: Remove the need for adding two unused addresses with // IPsec tunnels. + final InetAddress address = InetAddress.getLocalHost(); mTunnelIface = mIpSecManager.createIpSecTunnelInterface( - ikeSessionParams.getServerAddress() /* unused */, - ikeSessionParams.getServerAddress() /* unused */, + address /* unused */, + address /* unused */, network); mNetd.setInterfaceUp(mTunnelIface.getInterfaceName()); diff --git a/services/core/java/com/android/server/connectivity/VpnIkev2Utils.java b/services/core/java/com/android/server/connectivity/VpnIkev2Utils.java index 1e20ae752709b..3da304c07910e 100644 --- a/services/core/java/com/android/server/connectivity/VpnIkev2Utils.java +++ b/services/core/java/com/android/server/connectivity/VpnIkev2Utils.java @@ -85,16 +85,12 @@ import java.util.List; public class VpnIkev2Utils { static IkeSessionParams buildIkeSessionParams( @NonNull Context context, @NonNull Ikev2VpnProfile profile, @NonNull Network network) { - // TODO(b/149356682): Update this based on new IKE API. Only numeric addresses supported - // until then. All others throw IAE (caught by caller). - final InetAddress serverAddr = InetAddresses.parseNumericAddress(profile.getServerAddr()); final IkeIdentification localId = parseIkeIdentification(profile.getUserIdentity()); final IkeIdentification remoteId = parseIkeIdentification(profile.getServerAddr()); - // TODO(b/149356682): Update this based on new IKE API. final IkeSessionParams.Builder ikeOptionsBuilder = new IkeSessionParams.Builder(context) - .setServerAddress(serverAddr) + .setServerHostname(profile.getServerAddr()) .setNetwork(network) .setLocalIdentification(localId) .setRemoteIdentification(remoteId);