Support legacy routes added by apps via ensureRouteToHost().
This adds the routes to two fixed tables:
+ LEGACY, which has higher priority than other non-explicit lookup tables
(per-network and default network).
+ PRIVILEGED_LEGACY, available only to system apps and has higher priority than
VPNs (system apps are those with the CONNECTIVITY_INTERNAL permission).
This will be changed to per-UID tables once the kernel supports UID-based
routing, so that these legacy routes are scoped to each app and not global.
Also, fix a TODO: The framework (as of http://ag/471599) will not set the
gateway argument if it's actually a direct-connected route.
Change-Id: I0ee1ca89fdc859d75a89021ca8c1902811b1e4a9
diff --git a/server/RouteController.h b/server/RouteController.h
index 6d66ed7..7292579 100644
--- a/server/RouteController.h
+++ b/server/RouteController.h
@@ -21,6 +21,13 @@
class RouteController {
public:
+ // How the routing table number is determined for route modification requests.
+ enum TableType {
+ INTERFACE, // Compute the table number based on the interface index.
+ LEGACY, // Based on the UID; such tables can override the default network routes.
+ PRIVILEGED_LEGACY, // Based on the UID; such tables can bypass VPNs.
+ };
+
static const int ROUTE_TABLE_OFFSET_FROM_INDEX = 1000;
static void Init();
@@ -34,8 +41,10 @@
static bool addToDefaultNetwork(const char* interface, Permission permission);
static bool removeFromDefaultNetwork(const char* interface, Permission permission);
- static bool addRoute(const char* interface, const char* destination, const char* nexthop);
- static bool removeRoute(const char* interface, const char* destination, const char* nexthop);
+ static bool addRoute(const char* interface, const char* destination, const char* nexthop,
+ TableType tableType, unsigned uid);
+ static bool removeRoute(const char* interface, const char* destination, const char* nexthop,
+ TableType tableType, unsigned uid);
};
#endif // NETD_SERVER_ROUTE_CONTROLLER_H