Merge cherrypicks of [3116469, 3116470, 3116074, 3116075, 3116498, 3116499, 3117095, 3115988, 3116845, 3116471, 3116500, 3116573, 3115989, 3116501, 3116076, 3116472] into oc-mr1-release
Change-Id: I97df5de118901872a67558be50a9c40704da2899
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 1785ec7..43a2048 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -45,6 +45,7 @@
const char IPV4_FORWARDING_PROC_FILE[] = "/proc/sys/net/ipv4/ip_forward";
const char IPV6_FORWARDING_PROC_FILE[] = "/proc/sys/net/ipv6/conf/all/forwarding";
const char SEPARATOR[] = "|";
+constexpr const char kTcpBeLiberal[] = "/proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal";
bool writeToFile(const char* filename, const char* value) {
int fd = open(filename, O_WRONLY | O_CLOEXEC);
@@ -63,6 +64,11 @@
return true;
}
+// TODO: Consider altering TCP and UDP timeouts as well.
+void configureForTethering(bool enabled) {
+ writeToFile(kTcpBeLiberal, enabled ? "1" : "0");
+}
+
bool configureForIPv6Router(const char *interface) {
return (InterfaceController::setEnableIPv6(interface, 0) == 0)
&& (InterfaceController::setAcceptIPv6Ra(interface, 0) == 0)
@@ -211,6 +217,7 @@
close(pipefd[0]);
mDaemonPid = pid;
mDaemonFd = pipefd[1];
+ configureForTethering(true);
applyDnsInterfaces();
ALOGD("Tethering services running");
}
@@ -219,6 +226,7 @@
}
int TetherController::stopTethering() {
+ configureForTethering(false);
if (mDaemonPid == 0) {
ALOGE("Tethering already stopped");