Fail fast if somebody is adding default routes
bug:2655011 Change-Id: I25da940e024825bc6e1d1ac5fe7b0d951609c1c1
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user