From a79f6182a338621a32f350d7c2985c6872cccf84 Mon Sep 17 00:00:00 2001 From: Sreeram Ramachandran Date: Thu, 24 Apr 2014 15:55:26 -0700 Subject: [PATCH] Fixes for stupid mistakes (by me). + Only remove netId/permission after doing everything that references them. + Return success/failure correctly based on return value of fork/exec. Conflicts: NetworkController.cpp Change-Id: Iddb8ccdffc104ffed1058ecc2421006beebd568d --- NetworkController.cpp | 5 +++-- RouteController.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NetworkController.cpp b/NetworkController.cpp index 395798d..93e1c1b 100644 --- a/NetworkController.cpp +++ b/NetworkController.cpp @@ -183,8 +183,6 @@ bool NetworkController::destroyNetwork(unsigned netId) { status = false; } } - mPermissionsController->setPermissionForNetwork(PERMISSION_NONE, netId); - mNetIdToInterfaces.erase(netId); if (netId == getDefaultNetwork()) { // Could the default network have changed from below us, after we evaluated the 'if', making @@ -194,6 +192,9 @@ bool NetworkController::destroyNetwork(unsigned netId) { setDefaultNetwork(NETID_UNSET); } + mPermissionsController->setPermissionForNetwork(PERMISSION_NONE, netId); + mNetIdToInterfaces.erase(netId); + // TODO: Uncomment once this API has been added to bionic. #if 0 _resolv_delete_cache_for_net(netId); diff --git a/RouteController.cpp b/RouteController.cpp index 2a6ef3d..e3bbef4 100644 --- a/RouteController.cpp +++ b/RouteController.cpp @@ -115,7 +115,7 @@ bool runIpRouteCommand(const char* action, uint32_t table, const char* interface } } - return android_fork_execvp(argc, const_cast(argv), NULL, false, false); + return !android_fork_execvp(argc, const_cast(argv), NULL, false, false); } bool modifyPerNetworkRules(unsigned netId, const char* interface, Permission permission, bool add, -- 2.11.0