Support removing specific routes from local_network

Bug: 9580643
Change-Id: Id0aaf4bc7424797e2beef03fb18a2c1885a86509
This commit is contained in:
Erik Kline
2016-07-17 21:28:39 +09:00
parent e3f28911af
commit 6599ee8b96
3 changed files with 27 additions and 2 deletions

View File

@@ -442,6 +442,7 @@ interface INetworkManagementService
void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
void removeInterfaceFromLocalNetwork(String iface);
int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);
void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges);
}

View File

@@ -2774,4 +2774,19 @@ public class NetworkManagementService extends INetworkManagementService.Stub
public void removeInterfaceFromLocalNetwork(String iface) {
modifyInterfaceInNetwork("remove", "local", iface);
}
@Override
public int removeRoutesFromLocalNetwork(List<RouteInfo> routes) {
int failures = 0;
for (RouteInfo route : routes) {
try {
modifyRoute("remove", "local", route);
} catch (IllegalStateException e) {
failures++;
}
}
return failures;
}
}

View File

@@ -157,8 +157,17 @@ class IPv6TetheringInterfaceServices {
}
} else {
if (mLastLocalRoutes != null && !mLastLocalRoutes.isEmpty()) {
// TODO: Remove only locally added network routes.
// mNMSwervice.removeInterfaceFromLocalNetwork(mIfName);
try {
final int removalFailures =
mNMService.removeRoutesFromLocalNetwork(mLastLocalRoutes);
if (removalFailures > 0) {
Log.e(TAG,
String.format("Failed to remove %d IPv6 routes from local table.",
removalFailures));
}
} catch (RemoteException e) {
Log.e(TAG, "Failed to remove IPv6 routes from local table: ", e);
}
}
}