Always add costly interfaces to the bw_FORWARD chain
This adds a jump to bw_costly_<ifname> for traffic forwarded out
interface <ifname> to the bw_FORWARD chain, regardless of tethering
state (as having it safely in place is harmless).
Bug: 24497044
Change-Id: I165724c319051ddf29a2833912eb286368b0570d
diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp
index d71ce3b..a9bd5e2 100644
--- a/server/BandwidthController.cpp
+++ b/server/BandwidthController.cpp
@@ -555,6 +555,12 @@
snprintf(cmd, sizeof(cmd), "-I bw_OUTPUT %d -o %s --jump %s", ruleInsertPos, ifn, costCString);
res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
+
+ snprintf(cmd, sizeof(cmd), "-D bw_FORWARD -o %s --jump %s", ifn, costCString);
+ runIpxtablesCmd(cmd, IptJumpNoAdd, IptFailHide);
+ snprintf(cmd, sizeof(cmd), "-A bw_FORWARD -o %s --jump %s", ifn, costCString);
+ res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
+
return res;
}
@@ -580,8 +586,10 @@
snprintf(cmd, sizeof(cmd), "-D bw_INPUT -i %s --jump %s", ifn, costCString);
res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
- snprintf(cmd, sizeof(cmd), "-D bw_OUTPUT -o %s --jump %s", ifn, costCString);
- res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
+ for (const auto tableName : {LOCAL_OUTPUT, LOCAL_FORWARD}) {
+ snprintf(cmd, sizeof(cmd), "-D %s -o %s --jump %s", tableName, ifn, costCString);
+ res |= runIpxtablesCmd(cmd, IptJumpNoAdd);
+ }
/* The "-N bw_costly_shared" is created upfront, no need to handle it here. */
if (quotaType == QuotaUnique) {