Switch costly alerts to iptables-restore.
Costly alerts appear to be currently unused, but they are the
last user of iptables commands in BandwidthController, so
migrating them to iptables-restore will allow us to delete
the iptables-specific code in BandwidthController.
Bug: 28362720
Test: netd_{unit,integration}_test pass
Change-Id: I07c6df6df347fd6485e6d0740b7d6165a423e34b
diff --git a/server/BandwidthControllerTest.cpp b/server/BandwidthControllerTest.cpp
index becfe49..066f9eb 100644
--- a/server/BandwidthControllerTest.cpp
+++ b/server/BandwidthControllerTest.cpp
@@ -585,24 +585,28 @@
int64_t alertBytes = 0;
std::vector<std::string> expected = {
- "-A bw_costly_shared -m quota2 ! --quota 123456 --name sharedAlert\n",
+ "*filter\n"
+ "-A bw_costly_shared -m quota2 ! --quota 123456 --name sharedAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, setCostlyAlert("shared", kQuota, &alertBytes));
EXPECT_EQ(kQuota, alertBytes);
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
expected = {};
expectUpdateQuota(kQuota);
EXPECT_EQ(0, setCostlyAlert("shared", kQuota + 1, &alertBytes));
EXPECT_EQ(kQuota + 1, alertBytes);
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
expected = {
+ "*filter\n"
"-D bw_costly_shared -m quota2 ! --quota 123457 --name sharedAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, removeCostlyAlert("shared", &alertBytes));
EXPECT_EQ(0, alertBytes);
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
}
TEST_F(BandwidthControllerTest, ManipulateSpecialApps) {