summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2020-04-06 21:09:53 -0700
committerMaciej Żenczykowski <maze@google.com>2020-04-07 15:23:27 +0000
commitdde0c026a156858d0ac6df5ae08118f46a9a681b (patch)
treea69ec9ec03b51b0e9fa501f5a99187ffb685b9bf /server/TetherController.cpp
parent1e5912d1b05e5b3b616ef1643711689dfe3011d6 (diff)
TetherController - bpf offload should only be enabled once per upstream
Bug: 153437886 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If8588c0ebc2893ccea89db3c68e9a08fbdec06fc
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 144d24f4..dd8622bb 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -606,7 +606,8 @@ int TetherController::enableNat(const char* intIface, const char* extIface) {
}
// add this if we are the first enabled nat for this upstream
- if (!isAnyForwardingEnabledOnUpstream(extIface)) {
+ bool firstDownstreamForThisUpstream = !isAnyForwardingEnabledOnUpstream(extIface);
+ if (firstDownstreamForThisUpstream) {
std::vector<std::string> v4Cmds = {
"*nat",
StringPrintf("-A %s -o %s -j MASQUERADE", LOCAL_NAT_POSTROUTING, extIface),
@@ -632,7 +633,7 @@ int TetherController::enableNat(const char* intIface, const char* extIface) {
return -ENODEV;
}
- maybeStartBpf(extIface);
+ if (firstDownstreamForThisUpstream) maybeStartBpf(extIface);
return 0;
}
@@ -816,11 +817,8 @@ int TetherController::disableNat(const char* intIface, const char* extIface) {
}
setForwardRules(false, intIface, extIface);
- if (!isAnyForwardingPairEnabled()) {
- setDefaults();
- }
-
- maybeStopBpf(extIface);
+ if (!isAnyForwardingEnabledOnUpstream(extIface)) maybeStopBpf(extIface);
+ if (!isAnyForwardingPairEnabled()) setDefaults();
return 0;
}