From c5f2e89fe6bc822bb2f64adf1280547242860f1a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 22 Jun 2022 21:25:12 -0400 Subject: [PATCH] Use AbortAllOtherCommunicationOnFabric in RemoveFabric. This prevents establishment of new sessions for the fabric, and shuts down other communication on the sessions that do exist, which our old setup did not use to do. Fixes https://github.com/project-chip/connectedhomeip/issues/9642 --- .../operational-credentials-server.cpp | 32 +------------------ 1 file changed, 1 insertion(+), 31 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 41058931c2801e..203c375c4f8dc7 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -476,28 +476,6 @@ void MatterOperationalCredentialsPluginServerInitCallback(void) DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler); } -namespace { -class FabricCleanupExchangeDelegate : public chip::Messaging::ExchangeDelegate -{ -public: - CHIP_ERROR OnMessageReceived(chip::Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader, - System::PacketBufferHandle && payload) override - { - return CHIP_NO_ERROR; - } - void OnResponseTimeout(chip::Messaging::ExchangeContext * ec) override {} - void OnExchangeClosing(chip::Messaging::ExchangeContext * ec) override - { - SessionManager * sessionManager = ec->GetExchangeMgr()->GetSessionManager(); - FabricIndex currentFabricIndex = ec->GetSessionHandle()->GetFabricIndex(); - CleanupSessionsForFabric(*sessionManager, currentFabricIndex); - } -}; - -FabricCleanupExchangeDelegate gFabricCleanupExchangeDelegate; - -} // namespace - bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::RemoveFabric::DecodableType & commandData) @@ -543,15 +521,7 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle FabricIndex currentFabricIndex = commandObj->GetAccessingFabricIndex(); if (currentFabricIndex == fabricBeingRemoved) { - // If the current fabric is being removed, don't expire the secure sessions immediately as they are - // still needed to send a pending message generated by emberAfSendImmediateDefaultResponse(). - // Hijack the exchange delegate here (as no more messages should be received on this exchange), - // and wait for it to close, before expiring the secure sessions for the fabric. Also, suppress MRP - // usage since the MRP engine still holds an exchange even after it's closed, and the engine references - // the associated session object. - // TODO: https://github.com/project-chip/connectedhomeip/issues/9642 - ec->SetAutoRequestAck(false); - ec->SetDelegate(&gFabricCleanupExchangeDelegate); + ec->AbortAllOtherCommunicationOnFabric(); } else {