Add VTI Netlink Interface in NetD
Includes the logic to add / update / remove Virtual Tunnel Inteface
in RouteController.
Bug: 63589711
Test: Ran runtest -x "system/netd/tests/netd_integration_test.cpp"
Change-Id: I49a86f2eceecaf34fbb1e5dc05a888447437bef0
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index fd2d0d5..6f87745 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -243,6 +243,40 @@
EXPECT_EQ(false, ret);
}
+TEST_F(BinderTest, TestVirtualTunnelInterface) {
+ static const struct TestData {
+ const std::string& family;
+ const std::string& deviceName;
+ const std::string& localAddress;
+ const std::string& remoteAddress;
+ int32_t iKey;
+ int32_t oKey;
+ } kTestData[] = {
+ { "IPV4", "test_vti", "127.0.0.1", "8.8.8.8", 0x1234 + 53, 0x1234 + 53 },
+ { "IPV6", "test_vti6", "::1", "2001:4860:4860::8888", 0x1234 + 50, 0x1234 + 50 },
+ };
+
+ for (unsigned int i = 0; i < arraysize(kTestData); i++) {
+ const auto &td = kTestData[i];
+
+ binder::Status status;
+
+ // Create Virtual Tunnel Interface.
+ status = mNetd->addVirtualTunnelInterface(td.deviceName, td.localAddress,
+ td.remoteAddress, td.iKey, td.oKey);
+ EXPECT_TRUE(status.isOk()) << td.family << status.exceptionMessage();
+
+ // Update Virtual Tunnel Interface.
+ status = mNetd->updateVirtualTunnelInterface(td.deviceName, td.localAddress,
+ td.remoteAddress, td.iKey, td.oKey);
+ EXPECT_TRUE(status.isOk()) << td.family << status.exceptionMessage();
+
+ // Remove Virtual Tunnel Interface.
+ status = mNetd->removeVirtualTunnelInterface(td.deviceName);
+ EXPECT_TRUE(status.isOk()) << td.family << status.exceptionMessage();
+ }
+}
+
static int bandwidthDataSaverEnabled(const char *binary) {
std::vector<std::string> lines = listIptablesRule(binary, "bw_data_saver");