Temporarily revert the "talk to netlink directly" change.
The change being reverted is http://ag/486277. Instead, use /sbin/ip again. The
code to talk to netlink fails on volantis. I.e., instead of this:
$ ip route show table 1006
default via 100.110.191.254 dev wlan0
100.110.128.0/18 dev wlan0 scope link
we end up with this:
$ ip route show table 1006
default dev wlan0 proto static
100.110.128.0/18 dev wlan0 proto static
Notice the lack of the nexthop and the addition of "proto static". I think the
netlink message is somehow not properly aligned on volantis, causing the kernel
to misinterpret it.
Bug: 15840054
Change-Id: Ief60473e337410f7cb35890de0a5a74a21723a41
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index 9716b9e..3590a9f 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -120,6 +120,8 @@
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,
@@ -222,6 +224,35 @@
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);
@@ -313,7 +344,7 @@
// route, to the main table as well.
// Returns 0 on success or negative errno on failure.
int modifyRoute(const char* interface, const char* destination, const char* nexthop,
- int action, RouteController::TableType tableType, unsigned /* uid */) {
+ int action, RouteController::TableType tableType, unsigned /* uid */) {
uint32_t table = 0;
switch (tableType) {
case RouteController::INTERFACE: {