Flush both IPv4 and IPv6 routes.

The current code unintentionally flushes only IPv4 routes
because it reuses a function that is normally used to add and
remove routes (where the IP version is implicitly specified by
the route to add or remove).

Instead of fixing the runIpRouteCommand function, add a new
flushIpRoutes function because runIpRouteCommand will be
replaced by a netlink implementation in an upcoming CL.

Change-Id: Ie96ae4124baca3edb8e0d0841e7abadb6b3ee9ab
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index a4086d9..b44a31a 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -271,7 +271,27 @@
     }
     interfaceToIndex.erase(interface);
 
-    return runIpRouteCommand("flush", table, NULL, NULL, NULL);
+    char tableString[UINT32_STRLEN];
+    snprintf(tableString, sizeof(tableString), "%u", table);
+
+    const char* version[] = {"-4", "-6"};
+    for (size_t i = 0; i < ARRAY_SIZE(version); ++i) {
+        const char* argv[] = {
+            IP_PATH,
+            version[i],
+            "route"
+            "flush",
+            "table",
+            tableString,
+        };
+        int argc = ARRAY_SIZE(argv);
+
+        if (!android_fork_execvp(argc, const_cast<char**>(argv), NULL, false, false)) {
+            return false;
+        }
+    }
+
+    return true;
 }
 
 }  // namespace