Merge "Fail fast if somebody is adding default routes" into jb-mr2-dev

This commit is contained in:
Robert Greenwalt
2013-03-14 23:02:28 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 2 deletions

View File

@@ -2306,6 +2306,20 @@ public class ConnectivityService extends IConnectivityManager.Stub {
boolean routesChanged = (routeDiff.removed.size() != 0 || routeDiff.added.size() != 0);
// look for a radio-added default route (v4-only for now TODO)
RouteInfo[] routes = new RouteInfo[0];
try {
routes = mNetd.getRoutes(newLp.getInterfaceName());
} catch (Exception e) {}
for (RouteInfo route : routes) {
if (route.isDefaultRoute() && route.getGateway() instanceof Inet4Address &&
mAddedRoutes.contains(route) == false) {
throw new IllegalStateException("Unexpected default route found for interface "
+ newLp.getInterfaceName());
}
}
for (RouteInfo r : routeDiff.removed) {
if (isLinkDefault || ! r.isDefaultRoute()) {
removeRoute(curLp, r, TO_DEFAULT_TABLE);

View File

@@ -711,7 +711,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
InetAddress gatewayAddr =
NetworkUtils.intToInetAddress((int)Long.parseLong(gate, 16));
RouteInfo route = new RouteInfo(linkAddress, gatewayAddr);
RouteInfo route = new RouteInfo(linkAddress, gatewayAddr, iface);
routes.add(route);
} catch (Exception e) {
Log.e(TAG, "Error parsing route " + s + " : " + e);
@@ -743,7 +743,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
InetAddress gateAddr = NetworkUtils.hexToInet6Address(gate);
RouteInfo route = new RouteInfo(linkAddress, gateAddr);
RouteInfo route = new RouteInfo(linkAddress, gateAddr, iface);
routes.add(route);
} catch (Exception e) {
Log.e(TAG, "Error parsing route " + s + " : " + e);