Add general /proc/sys/net/ipv[46]/{conf,neigh}/ interface
Bug: 21859053
Bug: 28135208
(cherry picked from commit b218a87e0777d3d2c93231e03ef7315d783e3279)
Change-Id: Ie32c86511b97358d208a4c84a1c69a75c703bf3b
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 8dc4d93..f8f300a 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -29,6 +29,7 @@
#include "Controllers.h"
#include "DumpWriter.h"
+#include "InterfaceController.h"
#include "NetdConstants.h"
#include "NetdNativeService.h"
#include "RouteController.h"
@@ -235,5 +236,44 @@
return binder::Status::ok();
}
+binder::Status NetdNativeService::setProcSysNet(
+ int32_t family, int32_t which, const std::string &ifname, const std::string ¶meter,
+ const std::string &value) {
+ ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
+
+ const char *familyStr;
+ switch (family) {
+ case INetd::IPV4:
+ familyStr = "ipv4";
+ break;
+ case INetd::IPV6:
+ familyStr = "ipv6";
+ break;
+ default:
+ return binder::Status::fromServiceSpecificError(EAFNOSUPPORT, String8("Bad family"));
+ }
+
+ const char *whichStr;
+ switch (which) {
+ case INetd::CONF:
+ whichStr = "conf";
+ break;
+ case INetd::NEIGH:
+ whichStr = "neigh";
+ break;
+ default:
+ return binder::Status::fromServiceSpecificError(EINVAL, String8("Bad category"));
+ }
+
+ const int err = InterfaceController::setParameter(
+ familyStr, whichStr, ifname.c_str(), parameter.c_str(),
+ value.c_str());
+ if (err != 0) {
+ return binder::Status::fromServiceSpecificError(-err,
+ String8::format("ResolverController error: %s", strerror(-err)));
+ }
+ return binder::Status::ok();
+}
+
} // namespace net
} // namespace android