netd: Route MTU
- Route may include optional MTU parameter
- Change route is added so routes don't need to be deleted then re-added
- Add/Del/Change functions to pass route info as parcel
Bug: 142892223
Test: new unit tests
Change-Id: Idc32ecb0520b1f4136b3fe0e3f7b6800fb3005a6
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 322604a..c951c24 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -969,6 +969,39 @@
return binder::Status::ok();
}
+binder::Status NetdNativeService::networkAddRouteParcel(int32_t netId,
+ const RouteInfoParcel& route) {
+ // Public methods of NetworkController are thread-safe.
+ ENFORCE_NETWORK_STACK_PERMISSIONS();
+ bool legacy = false;
+ uid_t uid = 0; // UID is only meaningful for legacy routes.
+
+ // convert Parcel to parameters
+ int res = gCtls->netCtrl.addRoute(netId, route.ifName.c_str(), route.destination.c_str(),
+ route.nextHop.empty() ? nullptr : route.nextHop.c_str(),
+ legacy, uid, route.mtu);
+ return statusFromErrcode(res);
+}
+
+binder::Status NetdNativeService::networkUpdateRouteParcel(int32_t netId,
+ const RouteInfoParcel& route) {
+ // Public methods of NetworkController are thread-safe.
+ ENFORCE_NETWORK_STACK_PERMISSIONS();
+ bool legacy = false;
+ uid_t uid = 0; // UID is only meaningful for legacy routes.
+
+ // convert Parcel to parameters
+ int res = gCtls->netCtrl.updateRoute(netId, route.ifName.c_str(), route.destination.c_str(),
+ route.nextHop.empty() ? nullptr : route.nextHop.c_str(),
+ legacy, uid, route.mtu);
+ return statusFromErrcode(res);
+}
+
+binder::Status NetdNativeService::networkRemoveRouteParcel(int32_t netId,
+ const RouteInfoParcel& route) {
+ return networkRemoveRoute(netId, route.ifName, route.destination, route.nextHop);
+}
+
binder::Status NetdNativeService::networkAddRoute(int32_t netId, const std::string& ifName,
const std::string& destination,
const std::string& nextHop) {
@@ -977,7 +1010,7 @@
bool legacy = false;
uid_t uid = 0; // UID is only meaningful for legacy routes.
int res = gCtls->netCtrl.addRoute(netId, ifName.c_str(), destination.c_str(),
- nextHop.empty() ? nullptr : nextHop.c_str(), legacy, uid);
+ nextHop.empty() ? nullptr : nextHop.c_str(), legacy, uid, 0);
return statusFromErrcode(res);
}
@@ -999,7 +1032,7 @@
bool legacy = true;
int res = gCtls->netCtrl.addRoute(netId, ifName.c_str(), destination.c_str(),
nextHop.empty() ? nullptr : nextHop.c_str(), legacy,
- (uid_t) uid);
+ (uid_t)uid, 0);
return statusFromErrcode(res);
}