Unrevert the 'revert the "talk to netlink directly" change.'
http://ag/486277 was reverted in http://ag/491263 and is being unreverted in
this change. The bug in the original CL was a typo ("interface" instead of the
desired "ifindex"), which is now fixed.
Bug: 15840054
Change-Id: If66987c74cc86e9ba4f7a35d36f0a39afe939a68
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index 3590a9f..980968f 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -120,8 +120,6 @@
return true;
}
-#if 0
-
// Adds or deletes an IPv4 or IPv6 route.
// Returns 0 on success or negative errno on failure.
int modifyIpRoute(uint16_t action, uint32_t table, const char* interface, const char* destination,
@@ -186,7 +184,7 @@
{ &rta_dst, sizeof(rta_dst) },
{ rawAddress, static_cast<size_t>(rawLength) },
{ &rta_oif, interface ? sizeof(rta_oif) : 0 },
- { &ifindex, interface ? sizeof(interface) : 0 },
+ { &ifindex, interface ? sizeof(ifindex) : 0 },
{ &rta_gateway, nexthop ? sizeof(rta_gateway) : 0 },
{ rawNexthop, nexthop ? static_cast<size_t>(rawLength) : 0 },
};
@@ -224,35 +222,6 @@
return ret;
}
-#else
-
-int modifyIpRoute(int action, uint32_t table, const char* interface, const char* destination,
- const char* nexthop) {
- char tableString[UINT32_STRLEN];
- snprintf(tableString, sizeof(tableString), "%u", table);
-
- int argc = 0;
- const char* argv[16];
-
- argv[argc++] = IP_PATH;
- argv[argc++] = "route";
- argv[argc++] = action == RTM_NEWROUTE ? ADD : DEL;
- argv[argc++] = "table";
- argv[argc++] = tableString;
- if (destination) {
- argv[argc++] = destination;
- argv[argc++] = "dev";
- argv[argc++] = interface;
- if (nexthop) {
- argv[argc++] = "via";
- argv[argc++] = nexthop;
- }
- }
- return android_fork_execvp(argc, const_cast<char**>(argv), NULL, false, false);
-}
-
-#endif
-
bool modifyPerNetworkRules(unsigned netId, const char* interface, Permission permission, bool add,
bool modifyIptables) {
uint32_t table = getRouteTableForInterface(interface);