From d0523f99699456e65254a13565404709284dd811 Mon Sep 17 00:00:00 2001 From: Michael Sandstedt Date: Mon, 17 Oct 2022 22:41:13 -0500 Subject: [PATCH] Update DNS-SD advertisements on fail-safe timeout (#23199) When we remove a fabric during a pending add with fail-safe timeout, we aren't updating DNS-SD adevertisements. In addition to the obvious consequence of continuing to advertise a now-stale identity, this can also leave the advertisement slots full if the failed fabric addition was to the Nth slot in an N-fabric device. This then breaks advertisement when recommissioning to the Nth slot thereafter for builds that do not set this: CHIP_CONFIG_MINMDNS_DYNAMIC_OPERATIONAL_RESPONDER_LIST For those builds, this condition persists until reboot or some other action triggers DnssdServer::StartServer. This commit fixes the problem by moving the DnssdServer::StartServer call from the RemoveFabric invoke handler to the server's OnFabricRemoved callback. That will result in server restart both for RemoveFabric invocations and fail-safe expiry. Fixes https://github.com/project-chip/connectedhomeip/issues/23169 --- .../operational-credentials-server.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index ee7fa3d902c371..d25beb3c58af8f 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -272,11 +272,6 @@ const FabricInfo * RetrieveCurrentFabric(CommandHandler * aCommandHandler) CHIP_ERROR DeleteFabricFromTable(FabricIndex fabricIndex) { ReturnErrorOnFailure(Server::GetInstance().GetFabricTable().Delete(fabricIndex)); - - // We need to withdraw the advertisement for the now-removed fabric, so need - // to restart advertising altogether. - app::DnssdServer::Instance().StartServer(); - return CHIP_NO_ERROR; } @@ -362,6 +357,10 @@ class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate { ChipLogProgress(Zcl, "OpCreds: Fabric index 0x%x was removed", static_cast(fabricIndex)); + // We need to withdraw the advertisement for the now-removed fabric, so need + // to restart advertising altogether. + app::DnssdServer::Instance().StartServer(); + EventManagement::GetInstance().FabricRemoved(fabricIndex); NotifyFabricTableChanged();