OSDN Git Service

Flush (delete) routing tables when destroying a network.
authorSreeram Ramachandran <sreeram@google.com>
Tue, 15 Apr 2014 21:28:55 +0000 (14:28 -0700)
committerSreeram Ramachandran <sreeram@google.com>
Wed, 14 May 2014 03:01:09 +0000 (03:01 +0000)
(cherry picked from commit 7ee2c3fe24f9a643584ddf5f759a7acb73e35e8d)

Change-Id: I1b222b474b1ae7a551250f8f02d7900c493b5b16

RouteController.cpp

index ec82d1a..e7b2123 100644 (file)
@@ -190,6 +190,15 @@ bool modifyRoute(const char* interface, const char* destination, const char* nex
     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::createNetwork(unsigned netId, const char* interface, Permi
 }
 
 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,