summaryrefslogtreecommitdiff
path: root/core/java/android/net/RouteInfo.java
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2020-03-30 14:37:05 +0100
committerRubin Xu <rubinxu@google.com>2020-04-01 09:36:29 +0100
commit080f217945ad2c72369b2cd23c768055a239a9dd (patch)
tree8d63200da51f2ee4c01ddda5f0b207623dc50d5b /core/java/android/net/RouteInfo.java
parent2ec47eeb7c6375d87438ede3cc100085cb890bc5 (diff)
Only apply VPN isolation if it's fully routed
VPN is considered fully routed if both IPv4 and IPv6 have either a default route or a prohibit route. Bug: 145332510 Test: atest FrameworksNetTests Change-Id: I59cf48552bca98092d1212e3d718fd420add5458
Diffstat (limited to 'core/java/android/net/RouteInfo.java')
-rw-r--r--core/java/android/net/RouteInfo.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index dbdaa4c2da67..e550f85e6b9a 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -426,6 +426,16 @@ public final class RouteInfo implements Parcelable {
}
/**
+ * Indicates if this route is an unreachable default route.
+ *
+ * @return {@code true} if it's an unreachable route with prefix length of 0.
+ * @hide
+ */
+ private boolean isUnreachableDefaultRoute() {
+ return mType == RTN_UNREACHABLE && mDestination.getPrefixLength() == 0;
+ }
+
+ /**
* Indicates if this route is an IPv4 default route.
* @hide
*/
@@ -434,6 +444,14 @@ public final class RouteInfo implements Parcelable {
}
/**
+ * Indicates if this route is an IPv4 unreachable default route.
+ * @hide
+ */
+ public boolean isIPv4UnreachableDefault() {
+ return isUnreachableDefaultRoute() && mDestination.getAddress() instanceof Inet4Address;
+ }
+
+ /**
* Indicates if this route is an IPv6 default route.
* @hide
*/
@@ -442,6 +460,14 @@ public final class RouteInfo implements Parcelable {
}
/**
+ * Indicates if this route is an IPv6 unreachable default route.
+ * @hide
+ */
+ public boolean isIPv6UnreachableDefault() {
+ return isUnreachableDefaultRoute() && mDestination.getAddress() instanceof Inet6Address;
+ }
+
+ /**
* Indicates if this route is a host route (ie, matches only a single host address).
*
* @return {@code true} if the destination has a prefix length of 32 or 128 for IPv4 or IPv6,