From 58a944859781731de308939e914ea3ba27465f25 Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Fri, 2 Oct 2015 17:52:37 +0900 Subject: [PATCH] Always add costly interfaces to the bw_FORWARD chain This adds a jump to bw_costly_ for traffic forwarded out interface to the bw_FORWARD chain, regardless of tethering state (as having it safely in place is harmless). Bug: 24497044 Change-Id: I165724c319051ddf29a2833912eb286368b0570d --- server/BandwidthController.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 @@ int BandwidthController::prepCostlyIface(const char *ifn, QuotaType quotaType) { 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 @@ int BandwidthController::cleanupCostlyIface(const char *ifn, QuotaType quotaType 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) { -- 2.11.0