diff options
| author | 2023-03-11 07:15:57 +0000 | |
|---|---|---|
| committer | 2023-03-15 03:30:03 +0000 | |
| commit | 454fbe188d6ec39328e761bcb7df5a698545b82b (patch) | |
| tree | 9faa909800b69bd6662b48b81d281a789d42af30 | |
| parent | 4c195ab20e7f5e58042285c026a99512b6092014 (diff) | |
Honor IP protocol set by client in non-auto IP selection mode
If automatic IP version selection is not enabled and VPN clients
set the IP version and encap type in the IkeSessionParams, VPN
should use the value set by clients instead of always setting them
to auto.
Test: atest FrameworksNetTests
Change-Id: Icd76b06cb9155b0d1fc62811daeafe89d2e45149
| -rw-r--r-- | services/core/java/com/android/server/connectivity/Vpn.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 4d6c97854126..1e9352d10956 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -3558,10 +3558,22 @@ public class Vpn { + mCurrentToken + " to network " + underlyingNetwork); - final int ipVersion = mProfile.isAutomaticIpVersionSelectionEnabled() - ? guessEspIpVersionForNetwork() : ESP_IP_VERSION_AUTO; - final int encapType = mProfile.isAutomaticIpVersionSelectionEnabled() - ? guessEspEncapTypeForNetwork() : ESP_ENCAP_TYPE_AUTO; + + final int ipVersion; + final int encapType; + if (mProfile.isAutomaticIpVersionSelectionEnabled()) { + ipVersion = guessEspIpVersionForNetwork(); + encapType = guessEspEncapTypeForNetwork(); + } else if (mProfile.getIkeTunnelConnectionParams() != null) { + ipVersion = mProfile.getIkeTunnelConnectionParams() + .getIkeSessionParams().getIpVersion(); + encapType = mProfile.getIkeTunnelConnectionParams() + .getIkeSessionParams().getEncapType(); + } else { + ipVersion = ESP_IP_VERSION_AUTO; + encapType = ESP_ENCAP_TYPE_AUTO; + } + final int keepaliveDelaySeconds; if (mProfile.isAutomaticNattKeepaliveTimerEnabled()) { keepaliveDelaySeconds = guessNattKeepaliveTimerForNetwork(); |