Don't fail when trying to add routes that already exist.
Previously, we suppressed failures for the special case of
requestRouteToHost() being called multiple times. Turns out that other
parts of the system also try to add duplicate routes, so just suppress
EEXIST errors in general (as far as adding routes is concerned). For
example, this happens when the WiFi P2P DHCP client renews its lease
and blindly requests to add a route that it had already added before.
Bug: 17205769
Change-Id: I3de557ddb82c95899623aa31b4b3ec7c955f5609
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index 140c0d3..c3a600d 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -813,11 +813,8 @@
}
int ret = modifyIpRoute(action, table, interface, destination, nexthop);
- // We allow apps to call requestRouteToHost() multiple times with the same route, so ignore
- // EEXIST failures when adding routes to legacy tables.
- if (ret && !(action == RTM_NEWROUTE && ret == -EEXIST &&
- (tableType == RouteController::LEGACY_NETWORK ||
- tableType == RouteController::LEGACY_SYSTEM))) {
+ // Trying to add a route that already exists shouldn't cause an error.
+ if (ret && !(action == RTM_NEWROUTE && ret == -EEXIST)) {
return ret;
}