OSDN Git Service

Unrevert the 'revert the "talk to netlink directly" change.'
authorSreeram Ramachandran <sreeram@google.com>
Tue, 24 Jun 2014 23:09:21 +0000 (16:09 -0700)
committerSreeram Ramachandran <sreeram@google.com>
Tue, 24 Jun 2014 23:09:21 +0000 (16:09 -0700)
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

server/RouteController.cpp

index 3590a9f..980968f 100644 (file)
@@ -120,8 +120,6 @@ 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,
@@ -186,7 +184,7 @@ int modifyIpRoute(uint16_t action, uint32_t table, const char* interface, const
         { &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 @@ 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);