From addf827426f69ec4b4042a46ed3936b1b5a7d9c6 Mon Sep 17 00:00:00 2001 From: Yuuki Habu Date: Thu, 6 Sep 2018 09:37:55 +0900 Subject: [PATCH] To support skip464xlat per Network To add skip464exlat in NetworkMisc. NetworkAgent can skip to start 464xlat if need. (e.g. IMS PDN for Cellular can be disabled) Device will treat the network as IPv6-only if it is set Bug: 69949375 Test: Nat464XlatTest, ConnectivityServiceTest Change-Id: I676a02cb92530d64f29f34e89482a934f3ec4553 --- core/java/android/net/NetworkMisc.java | 9 +++++++++ .../java/com/android/server/connectivity/Nat464Xlat.java | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/java/android/net/NetworkMisc.java b/core/java/android/net/NetworkMisc.java index 69f50a272a..daa2640385 100644 --- a/core/java/android/net/NetworkMisc.java +++ b/core/java/android/net/NetworkMisc.java @@ -65,6 +65,12 @@ public class NetworkMisc implements Parcelable { */ public String subscriberId; + /** + * Set to skip 464xlat. This means the device will treat the network as IPv6-only and + * will not attempt to detect a NAT64 via RFC 7050 DNS lookups. + */ + public boolean skip464xlat; + public NetworkMisc() { } @@ -75,6 +81,7 @@ public class NetworkMisc implements Parcelable { acceptUnvalidated = nm.acceptUnvalidated; subscriberId = nm.subscriberId; provisioningNotificationDisabled = nm.provisioningNotificationDisabled; + skip464xlat = nm.skip464xlat; } } @@ -90,6 +97,7 @@ public class NetworkMisc implements Parcelable { out.writeInt(acceptUnvalidated ? 1 : 0); out.writeString(subscriberId); out.writeInt(provisioningNotificationDisabled ? 1 : 0); + out.writeInt(skip464xlat ? 1 : 0); } public static final Creator CREATOR = new Creator() { @@ -101,6 +109,7 @@ public class NetworkMisc implements Parcelable { networkMisc.acceptUnvalidated = in.readInt() != 0; networkMisc.subscriberId = in.readString(); networkMisc.provisioningNotificationDisabled = in.readInt() != 0; + networkMisc.skip464xlat = in.readInt() != 0; return networkMisc; } diff --git a/services/core/java/com/android/server/connectivity/Nat464Xlat.java b/services/core/java/com/android/server/connectivity/Nat464Xlat.java index f523d594aa..f96f6e87a9 100644 --- a/services/core/java/com/android/server/connectivity/Nat464Xlat.java +++ b/services/core/java/com/android/server/connectivity/Nat464Xlat.java @@ -93,7 +93,9 @@ public class Nat464Xlat extends BaseNetworkObserver { // We only run clat on networks that don't have a native IPv4 address. final boolean hasIPv4Address = (nai.linkProperties != null) && nai.linkProperties.hasIPv4Address(); - return supported && connected && !hasIPv4Address; + final boolean skip464xlat = + (nai.networkMisc != null) && nai.networkMisc.skip464xlat; + return supported && connected && !hasIPv4Address && !skip464xlat; } /**