Move runIptablesAlert{,Fwd}Cmd to iptables-restore.
This saves about 100ms on boot.
(cherry picked from commit 546fe48d36859e1ef2a0df2ffc1067dc2916ba44)
Bug: 37641280
Test: marlin builds and boots
Test: netd_{unit,integration}_test pass
Test: iptables rules look identical to other marlin running oc-release
Test: Enabling/disabling tethering adds/removes the forward rule
Change-Id: I8e15940565894d44a819b9cef25790d443b25df5
Merged-In: I56ce20a0efef8b1aba5f55bc823926447b21a614
diff --git a/server/BandwidthControllerTest.cpp b/server/BandwidthControllerTest.cpp
index 85c6b96..487b7d8 100644
--- a/server/BandwidthControllerTest.cpp
+++ b/server/BandwidthControllerTest.cpp
@@ -401,30 +401,38 @@
TEST_F(BandwidthControllerTest, IptablesAlertCmd) {
std::vector<std::string> expected = {
- "-I bw_INPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert",
- "-I bw_OUTPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert",
+ "*filter\n"
+ "-I bw_INPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "-I bw_OUTPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, runIptablesAlertCmd(IptOp::IptOpInsert, "MyWonderfulAlert", 123456));
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
expected = {
- "-D bw_INPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert",
- "-D bw_OUTPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert",
+ "*filter\n"
+ "-D bw_INPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "-D bw_OUTPUT -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, runIptablesAlertCmd(IptOp::IptOpDelete, "MyWonderfulAlert", 123456));
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
}
TEST_F(BandwidthControllerTest, IptablesAlertFwdCmd) {
std::vector<std::string> expected = {
- "-I bw_FORWARD -m quota2 ! --quota 123456 --name MyWonderfulAlert",
+ "*filter\n"
+ "-I bw_FORWARD -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, runIptablesAlertFwdCmd(IptOp::IptOpInsert, "MyWonderfulAlert", 123456));
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
expected = {
- "-D bw_FORWARD -m quota2 ! --quota 123456 --name MyWonderfulAlert",
+ "*filter\n"
+ "-D bw_FORWARD -m quota2 ! --quota 123456 --name MyWonderfulAlert\n"
+ "COMMIT\n"
};
EXPECT_EQ(0, runIptablesAlertFwdCmd(IptOp::IptOpDelete, "MyWonderfulAlert", 123456));
- expectIptablesCommands(expected);
+ expectIptablesRestoreCommands(expected);
}