From 8b1352fdaa0c98f8ed629ba4937a0558dc77d0fb Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Tue, 19 Feb 2019 16:56:47 +0000 Subject: [PATCH] Skip unreachable route when estimating VPN destinations Bug: 122652441 Test: atest com.android.server.connectivity.VpnTest Test: Establish a IPv4 VPN with minimal routes and check (dumpsys connectivity) the VPN network does not have INTERNET capability. Change-Id: Ic7f19ebb7b7f78a6ffb2a8ec3fc3eca5e5421f57 --- .../com/android/server/connectivity/VpnTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/net/java/com/android/server/connectivity/VpnTest.java b/tests/net/java/com/android/server/connectivity/VpnTest.java index 46de3d0608..03fe007d2a 100644 --- a/tests/net/java/com/android/server/connectivity/VpnTest.java +++ b/tests/net/java/com/android/server/connectivity/VpnTest.java @@ -28,6 +28,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_VPN; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; +import static android.net.RouteInfo.RTN_UNREACHABLE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -89,6 +90,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.net.Inet4Address; +import java.net.Inet6Address; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; @@ -775,6 +777,16 @@ public class VpnTest { // V4 does not, but V6 has sufficient coverage again lp.addRoute(new RouteInfo(new IpPrefix("::/1"))); assertTrue(Vpn.providesRoutesToMostDestinations(lp)); + + lp.clear(); + // V4-unreachable route should not be treated as sufficient coverage + lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), RTN_UNREACHABLE)); + assertFalse(Vpn.providesRoutesToMostDestinations(lp)); + + lp.clear(); + // V6-unreachable route should not be treated as sufficient coverage + lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), RTN_UNREACHABLE)); + assertFalse(Vpn.providesRoutesToMostDestinations(lp)); } @Test