From 1803a957e2dbb1c2a11586cd8c8a078f02f05544 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Tue, 15 Jul 2025 22:46:07 +0800 Subject: [PATCH] [srp-server] skip looking for conflicts on host of the same key (#11716) --- src/core/net/srp_server.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/net/srp_server.cpp b/src/core/net/srp_server.cpp index 38a055eb0..c06421d9a 100644 --- a/src/core/net/srp_server.cpp +++ b/src/core/net/srp_server.cpp @@ -507,15 +507,17 @@ bool Server::HasNameConflictsWith(Host &aHost) const ExitNow(hasConflicts = true); } - for (const Service &service : aHost.mServices) + for (const Host &host : mHosts) { - // Check on all hosts for a matching service with the same - // instance name and if found, verify that it has the same - // key. - - for (const Host &host : mHosts) + if (aHost.mKey == host.mKey) { - if (host.HasService(service.GetInstanceName()) && (aHost.mKey != host.mKey)) + continue; + } + + // Verify that no allocated services have the same instance name. + for (const Service &service : aHost.mServices) + { + if (host.HasService(service.GetInstanceName())) { LogWarn("Name conflict: service name %s has already been allocated", service.GetInstanceName()); ExitNow(hasConflicts = true);