Don't fail when adding a duplicate legacy route.

This only affects calls to requestRouteToHost() by apps. We still fail if the
framework itself tries to add a non-legacy duplicate route, since the framework
should know better (we can consider relaxing that too in the future).

Bug: 15925532
Change-Id: I9ee434277e462d570f88e6fe63a096e5ae41eee9
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index 51d9011..90a9399 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -392,7 +392,11 @@
     }
 
     int ret = modifyIpRoute(action, table, interface, destination, nexthop);
-    if (ret != 0) {
+    // We allow apps to call requestRouteToHost() multiple times with the same route, so ignore
+    // EEXIST failures when adding routes to legacy tables.
+    if (ret != 0 && !(action == RTM_NEWROUTE && ret == -EEXIST &&
+                      (tableType == RouteController::LEGACY ||
+                       tableType == RouteController::PRIVILEGED_LEGACY))) {
         return ret;
     }