ClatdController - iptables drop including interface name
This is a very minor bug fix. Technically we could have duplicate
src/dst ip's on different interfaces and then we'd end up with the second
add failing and the first remove succeeding and there being nothing left
for the second remove...
Test: atest bpf_module_test clatd_test libbpf_android_test libnetdbpf_test
netd_integration_test netd_unit_test netdutils_test resolv_integration_test
resolv_unit_test
Related-Bug: 136696213
Bug: 65674744
Bug: 79546774
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I76a4b8de70e9d9df1e17bd7fb7461b3ec9eb898b
diff --git a/server/ClatdControllerTest.cpp b/server/ClatdControllerTest.cpp
index 771bbab..dc71a03 100644
--- a/server/ClatdControllerTest.cpp
+++ b/server/ClatdControllerTest.cpp
@@ -70,9 +70,9 @@
protected:
ClatdController mClatdCtrl;
bool isEbpfDisabled() { return mClatdCtrl.getEbpfMode() == ClatdController::ClatEbpfDisabled; }
- void setIptablesDropRule(bool a, const char* b, const char* c) {
+ void setIptablesDropRule(bool a, const char* b, const char* c, const char* d) {
std::lock_guard guard(mClatdCtrl.mutex);
- return mClatdCtrl.setIptablesDropRule(a, b, c);
+ return mClatdCtrl.setIptablesDropRule(a, b, c, d);
}
void setIpv4AddressFreeFunc(bool (*func)(in_addr_t)) {
ClatdController::isIpv4AddressFreeFunc = func;
@@ -188,20 +188,20 @@
}
TEST_F(ClatdControllerTest, AddIptablesRule) {
- setIptablesDropRule(true, "64:ff9b::", "2001:db8::1:2:3:4");
+ setIptablesDropRule(true, "wlan0", "64:ff9b::", "2001:db8::1:2:3:4");
expectIptablesRestoreCommands((ExpectedIptablesCommands){
{V6,
"*raw\n"
- "-A clat_raw_PREROUTING -s 64:ff9b::/96 -d 2001:db8::1:2:3:4 -j DROP\n"
+ "-A clat_raw_PREROUTING -i wlan0 -s 64:ff9b::/96 -d 2001:db8::1:2:3:4 -j DROP\n"
"COMMIT\n"}});
}
TEST_F(ClatdControllerTest, RemoveIptablesRule) {
- setIptablesDropRule(false, "64:ff9b::", "2001:db8::a:b:c:d");
+ setIptablesDropRule(false, "wlan0", "64:ff9b::", "2001:db8::a:b:c:d");
expectIptablesRestoreCommands((ExpectedIptablesCommands){
{V6,
"*raw\n"
- "-D clat_raw_PREROUTING -s 64:ff9b::/96 -d 2001:db8::a:b:c:d -j DROP\n"
+ "-D clat_raw_PREROUTING -i wlan0 -s 64:ff9b::/96 -d 2001:db8::a:b:c:d -j DROP\n"
"COMMIT\n"}});
}