Add an IPC that writes to the tcp_{rmem, wmem}
The system server is controlling the tcp buffer now by writing to
/sys/kernel/ipv4/tcp_{rmem,wmem}_{min,def,max}. Those files are
basically the same as /proc/sys/net/ipv4/tcp_{rmem,wmem} except those
latter ones contain all three values in one file. Netd can directly write
to those files instead of depending on the android specific implementation.
Test: netd_integration_test
Bug: 118572798
Change-Id: I588b48be29ecf61fd5bbf94f97f63738be4eae25
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index fdf55b4..7c6e4a1 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -21,6 +21,7 @@
#include <tuple>
#include <vector>
+#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <cutils/properties.h>
@@ -48,6 +49,7 @@
#include "netid_client.h" // NETID_UNSET
using android::base::StringPrintf;
+using android::base::WriteStringToFile;
using android::net::TetherStatsParcel;
using android::net::UidRangeParcel;
using android::os::ParcelFileDescriptor;
@@ -1479,5 +1481,24 @@
return statusFromErrcode(res);
}
+binder::Status NetdNativeService::setTcpRWmemorySize(const std::string& rmemValues,
+ const std::string& wmemValues) {
+ ENFORCE_PERMISSION(NETWORK_STACK);
+ auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).args(rmemValues, wmemValues);
+ if (!WriteStringToFile(rmemValues, TCP_RMEM_PROC_FILE)) {
+ int ret = -errno;
+ gLog.log(entry.returns(ret).withAutomaticDuration());
+ return statusFromErrcode(ret);
+ }
+
+ if (!WriteStringToFile(wmemValues, TCP_WMEM_PROC_FILE)) {
+ int ret = -errno;
+ gLog.log(entry.returns(ret).withAutomaticDuration());
+ return statusFromErrcode(ret);
+ }
+ gLog.log(entry.withAutomaticDuration());
+ return binder::Status::ok();
+}
+
} // namespace net
} // namespace android