Merge changes I97ba5903,Icd80b368 into rvc-dev
* changes: Make VpnProfile.maxMtu default value match Ikev2VpnProfile Add negotiated DNS servers to VPN config
This commit is contained in:
committed by
Android (Google) Code Review
commit
7df7129b40
@@ -562,7 +562,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
@NonNull private List<String> mAllowedAlgorithms = new ArrayList<>();
|
@NonNull private List<String> mAllowedAlgorithms = new ArrayList<>();
|
||||||
private boolean mIsBypassable = false;
|
private boolean mIsBypassable = false;
|
||||||
private boolean mIsMetered = true;
|
private boolean mIsMetered = true;
|
||||||
private int mMaxMtu = 1360;
|
private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.
|
* Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public abstract class PlatformVpnProfile {
|
|||||||
public static final int TYPE_IKEV2_IPSEC_PSK = VpnProfile.TYPE_IKEV2_IPSEC_PSK;
|
public static final int TYPE_IKEV2_IPSEC_PSK = VpnProfile.TYPE_IKEV2_IPSEC_PSK;
|
||||||
public static final int TYPE_IKEV2_IPSEC_RSA = VpnProfile.TYPE_IKEV2_IPSEC_RSA;
|
public static final int TYPE_IKEV2_IPSEC_RSA = VpnProfile.TYPE_IKEV2_IPSEC_RSA;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final int MAX_MTU_DEFAULT = 1360;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@PlatformVpnType protected final int mType;
|
@PlatformVpnType protected final int mType;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.internal.net;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.net.Ikev2VpnProfile;
|
import android.net.Ikev2VpnProfile;
|
||||||
|
import android.net.PlatformVpnProfile;
|
||||||
import android.net.ProxyInfo;
|
import android.net.ProxyInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -133,7 +134,7 @@ public final class VpnProfile implements Cloneable, Parcelable {
|
|||||||
private List<String> mAllowedAlgorithms = new ArrayList<>(); // 19
|
private List<String> mAllowedAlgorithms = new ArrayList<>(); // 19
|
||||||
public boolean isBypassable = false; // 20
|
public boolean isBypassable = false; // 20
|
||||||
public boolean isMetered = false; // 21
|
public boolean isMetered = false; // 21
|
||||||
public int maxMtu = 1400; // 22
|
public int maxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT; // 22
|
||||||
public boolean areAuthParamsInline = false; // 23
|
public boolean areAuthParamsInline = false; // 23
|
||||||
|
|
||||||
// Helper fields.
|
// Helper fields.
|
||||||
|
|||||||
@@ -2248,12 +2248,16 @@ public class Vpn {
|
|||||||
final String interfaceName = mTunnelIface.getInterfaceName();
|
final String interfaceName = mTunnelIface.getInterfaceName();
|
||||||
final int maxMtu = mProfile.getMaxMtu();
|
final int maxMtu = mProfile.getMaxMtu();
|
||||||
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
|
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
|
||||||
|
final List<String> dnsAddrStrings = new ArrayList<>();
|
||||||
|
|
||||||
final Collection<RouteInfo> newRoutes = VpnIkev2Utils.getRoutesFromTrafficSelectors(
|
final Collection<RouteInfo> newRoutes = VpnIkev2Utils.getRoutesFromTrafficSelectors(
|
||||||
childConfig.getOutboundTrafficSelectors());
|
childConfig.getOutboundTrafficSelectors());
|
||||||
for (final LinkAddress address : internalAddresses) {
|
for (final LinkAddress address : internalAddresses) {
|
||||||
mTunnelIface.addAddress(address.getAddress(), address.getPrefixLength());
|
mTunnelIface.addAddress(address.getAddress(), address.getPrefixLength());
|
||||||
}
|
}
|
||||||
|
for (InetAddress addr : childConfig.getInternalDnsServers()) {
|
||||||
|
dnsAddrStrings.add(addr.getHostAddress());
|
||||||
|
}
|
||||||
|
|
||||||
final NetworkAgent networkAgent;
|
final NetworkAgent networkAgent;
|
||||||
final LinkProperties lp;
|
final LinkProperties lp;
|
||||||
@@ -2269,7 +2273,9 @@ public class Vpn {
|
|||||||
mConfig.routes.clear();
|
mConfig.routes.clear();
|
||||||
mConfig.routes.addAll(newRoutes);
|
mConfig.routes.addAll(newRoutes);
|
||||||
|
|
||||||
// TODO: Add DNS servers from negotiation
|
if (mConfig.dnsServers == null) mConfig.dnsServers = new ArrayList<>();
|
||||||
|
mConfig.dnsServers.clear();
|
||||||
|
mConfig.dnsServers.addAll(dnsAddrStrings);
|
||||||
|
|
||||||
networkAgent = mNetworkAgent;
|
networkAgent = mNetworkAgent;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class VpnProfileTest {
|
|||||||
assertTrue(p.getAllowedAlgorithms() != null && p.getAllowedAlgorithms().isEmpty());
|
assertTrue(p.getAllowedAlgorithms() != null && p.getAllowedAlgorithms().isEmpty());
|
||||||
assertFalse(p.isBypassable);
|
assertFalse(p.isBypassable);
|
||||||
assertFalse(p.isMetered);
|
assertFalse(p.isMetered);
|
||||||
assertEquals(1400, p.maxMtu);
|
assertEquals(1360, p.maxMtu);
|
||||||
assertFalse(p.areAuthParamsInline);
|
assertFalse(p.areAuthParamsInline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user