diff options
| author | Sreeram Ramachandran <sreeram@google.com> | 2014-06-24 15:03:52 -0700 |
|---|---|---|
| committer | Sreeram Ramachandran <sreeram@google.com> | 2014-06-24 15:03:52 -0700 |
| commit | ab359feb1a4d3a1898e32a7da47dcde3da4c1ed6 (patch) | |
| tree | 9348b4f9f811f8073b2d8cfdffc21e99afdc8141 /server/RouteController.cpp | |
| parent | 7b64cdee0f468a5b66ae2439f84364815ae9a795 (diff) | |
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
Diffstat (limited to 'server/RouteController.cpp')
| -rw-r--r-- | server/RouteController.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/server/RouteController.cpp b/server/RouteController.cpp index 9716b9ea..3590a9f6 100644 --- a/server/RouteController.cpp +++ b/server/RouteController.cpp @@ -120,6 +120,8 @@ bool runIpRuleCommand(const char* action, uint32_t priority, uint32_t table, uin 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 @@ int modifyIpRoute(uint16_t action, uint32_t table, const char* interface, const 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 @@ bool modifyDefaultNetworkRules(const char* interface, Permission permission, con // 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: { |
