Nat-related commands refine
We need this to ensure that the tethering IPCs don't need to grab the
lock in two different controllers
The idea is that always having a global_alert rule in bw_global_alert
chain.
TetherController will enable/disable the reference of bw_global_alert
chain.
[childchain order of filter FORWARD chain]
Chain FORWARD
nm_mdmprxy_iface_pkt_fwder
oem_fwd
fw_FORWARD
bw_FORWARD
tetherctrl_FORWARD
--Simple rule comparison--
[Before]
Chain bw_FORWARD
Alert rule
... other rules
Chain tetherctrl_FORWARD
... other rules
[After]
Chain bw_FORWARD
No Alert rule
... other rules
Chain tetherctrl_FORWARD
Jump to bw_global_alert
... other rules
Chain bw_global_alert
Alert rule
The exact rule comparison is shown in the bug.
Bug:119735985
Test: built, flashed, booted
system/netd/tests/runtests.sh passes
Change-Id: Ibf752d0c8de9170689fc74c89c0424d2642853ec
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 7647e20..ebf1788 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -1493,10 +1493,6 @@
auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).args(intIface, extIface);
int res = gCtls->tetherCtrl.enableNat(intIface.c_str(), extIface.c_str());
- if (!res) {
- std::lock_guard lock(gCtls->bandwidthCtrl.lock);
- res = gCtls->bandwidthCtrl.setGlobalAlertInForwardChain();
- }
gLog.log(entry.returns(res).withAutomaticDuration());
return statusFromErrcode(res);
}
@@ -1504,11 +1500,9 @@
binder::Status NetdNativeService::tetherRemoveForward(const std::string& intIface,
const std::string& extIface) {
NETD_LOCKING_RPC(NETWORK_STACK, gCtls->tetherCtrl.lock);
- std::lock_guard lock(gCtls->bandwidthCtrl.lock);
auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).args(intIface, extIface);
- int res = gCtls->bandwidthCtrl.removeGlobalAlertInForwardChain();
- res |= gCtls->tetherCtrl.disableNat(intIface.c_str(), extIface.c_str());
+ int res = gCtls->tetherCtrl.disableNat(intIface.c_str(), extIface.c_str());
gLog.log(entry.returns(res).withAutomaticDuration());
return statusFromErrcode(res);
}