Flush (delete) routing tables when destroying a network.

(cherry picked from commit 7ee2c3fe24f9a643584ddf5f759a7acb73e35e8d)

Change-Id: I1b222b474b1ae7a551250f8f02d7900c493b5b16
diff --git a/RouteController.cpp b/RouteController.cpp
index ec82d1a..e7b2123 100644
--- a/RouteController.cpp
+++ b/RouteController.cpp
@@ -190,6 +190,15 @@
     return runIpRouteCommand(add ? ADD : DEL, table, interface, destination, nexthop);
 }
 
+bool flushRoutes(const char* interface) {
+    uint32_t table = getRouteTableForInterface(interface);
+    if (!table) {
+        return false;
+    }
+
+    return runIpRouteCommand("flush", table, NULL, NULL, NULL);
+}
+
 }  // namespace
 
 bool RouteController::createNetwork(unsigned netId, const char* interface, Permission permission) {
@@ -197,8 +206,8 @@
 }
 
 bool RouteController::destroyNetwork(unsigned netId, const char* interface, Permission permission) {
-    return modifyPerNetworkRules(netId, interface, permission, false, true);
-    // TODO: Flush the routing table.
+    return modifyPerNetworkRules(netId, interface, permission, false, true) &&
+           flushRoutes(interface);
 }
 
 bool RouteController::modifyNetworkPermission(unsigned netId, const char* interface,