diff options
Diffstat (limited to 'server/TetherController.cpp')
| -rw-r--r-- | server/TetherController.cpp | 12 |
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; } |
