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
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index adc02b7..d9c41d4 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -390,7 +390,7 @@
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.");