diff options
author | Nathan Harold <nharold@google.com> | 2018-04-25 12:56:56 -0700 |
---|---|---|
committer | Nathan Harold <nharold@google.com> | 2018-04-25 13:36:27 -0700 |
commit | ac62cbd5217ccda2364d5cf942db41f699637fe9 (patch) | |
tree | 57f347fa23b4b6a27226d35130c7878b17cfa2fb | |
parent | 7c36c990943039386e40d218264d7a1d3cef4243 (diff) | |
download | netd-ac62cbd5217ccda2364d5cf942db41f699637fe9.tar.gz |
Address comments for XfrmController::Init
-Use a cleaner string comparison
-Add a check to the unit test
Bug: 74560705
Test: atest netd_integration_test
Change-Id: Ia1fe2b7691a904696baefb186a7233a681412263
-rw-r--r-- | server/XfrmController.cpp | 2 | ||||
-rw-r--r-- | tests/binder_test.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp index adc02b78..d9c41d4f 100644 --- a/server/XfrmController.cpp +++ b/server/XfrmController.cpp @@ -390,7 +390,7 @@ netdutils::Status XfrmController::flushInterfaces() { for (const std::string& iface : ifaces.value()) { int status = 0; // Look for the reserved interface prefix, which must be in the name at position 0 - if (iface.find(TUNNEL_INTERFACE_PREFIX) == 0 && + if (!iface.compare(0, strlen(TUNNEL_INTERFACE_PREFIX), TUNNEL_INTERFACE_PREFIX) && (status = removeVirtualTunnelInterface(iface)) < 0) { ALOGE("Failed to delete ipsec tunnel %s.", iface.c_str()); return netdutils::statusFromErrno(status, "Failed to remove ipsec tunnel."); diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp index 0913aa5f..4cbfdf24 100644 --- a/tests/binder_test.cpp +++ b/tests/binder_test.cpp @@ -317,6 +317,7 @@ TEST_F(BinderTest, TestXfrmControllerInit) { ASSERT_TRUE(allocateIpSecResources(false, &spi)); status = XfrmController::Init(); + ASSERT_TRUE(status.ok()); ASSERT_TRUE(allocateIpSecResources(true, &spi)); // Clean up |