diff options
| author | 2013-07-30 09:57:21 -0700 | |
|---|---|---|
| committer | 2013-07-30 09:57:21 -0700 | |
| commit | cc4bee55fa58193073f5ba5ccebc0cc24fdb45c7 (patch) | |
| tree | 54789fdc6b61d6b476f8bd4b77caf0d84f71fb29 | |
| parent | 6c3e7b5f0578aee0c49fa2bd4c1ba2572a9d0726 (diff) | |
| parent | 8fcad020e0c256be1948e42df19d43f53f9f5804 (diff) | |
am 8fcad020: Merge "Make legacy VPN work over stacked interfaces."
* commit '8fcad020e0c256be1948e42df19d43f53f9f5804':
Make legacy VPN work over stacked interfaces.
| -rw-r--r-- | services/java/com/android/server/connectivity/Vpn.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java index 2fc972fc2152..63d39588bb5d 100644 --- a/services/java/com/android/server/connectivity/Vpn.java +++ b/services/java/com/android/server/connectivity/Vpn.java @@ -467,15 +467,15 @@ public class Vpn extends BaseNetworkStateTracker { private native int jniCheck(String interfaze); private native void jniProtect(int socket, String interfaze); - private static String findLegacyVpnGateway(LinkProperties prop) { - for (RouteInfo route : prop.getRoutes()) { + private static RouteInfo findIPv4DefaultRoute(LinkProperties prop) { + for (RouteInfo route : prop.getAllRoutes()) { // Currently legacy VPN only works on IPv4. if (route.isDefaultRoute() && route.getGateway() instanceof Inet4Address) { - return route.getGateway().getHostAddress(); + return route; } } - throw new IllegalStateException("Unable to find suitable gateway"); + throw new IllegalStateException("Unable to find IPv4 default gateway"); } /** @@ -488,8 +488,9 @@ public class Vpn extends BaseNetworkStateTracker { throw new IllegalStateException("KeyStore isn't unlocked"); } - final String iface = egress.getInterfaceName(); - final String gateway = findLegacyVpnGateway(egress); + final RouteInfo ipv4DefaultRoute = findIPv4DefaultRoute(egress); + final String gateway = ipv4DefaultRoute.getGateway().getHostAddress(); + final String iface = ipv4DefaultRoute.getInterface(); // Load certificates. String privateKey = ""; |