From: Sreeram Ramachandran Date: Tue, 15 Apr 2014 21:28:55 +0000 (-0700) Subject: Flush (delete) routing tables when destroying a network. X-Git-Tag: android-x86-7.1-r1~287 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=92b66c4990b4a0ab608aa9c31da946f36085203b;p=android-x86%2Fsystem-netd.git 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 @@ 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,