Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate CASE resumption storage when UpdateNOC is called #19860

31 changes: 15 additions & 16 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,21 +396,7 @@ class Server
void OnFabricDeletedFromStorage(FabricTable & fabricTable, FabricIndex fabricIndex) override
{
(void) fabricTable;
auto & sessionManager = mServer->GetSecureSessionManager();
sessionManager.FabricRemoved(fabricIndex);

// Remove all CASE session resumption state
auto * sessionResumptionStorage = mServer->GetSessionResumptionStorage();
if (sessionResumptionStorage != nullptr)
{
CHIP_ERROR err = sessionResumptionStorage->DeleteAll(fabricIndex);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
"Warning, failed to delete session resumption state for fabric index 0x%x: %" CHIP_ERROR_FORMAT,
static_cast<unsigned>(fabricIndex), err.Format());
}
}
ClearCASEResumptionStateOnFabricChange(fabricIndex);

Credentials::GroupDataProvider * groupDataProvider = mServer->GetGroupDataProvider();
if (groupDataProvider != nullptr)
Expand Down Expand Up @@ -440,10 +426,23 @@ class Server
void OnFabricNOCUpdated(chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) override
{
(void) fabricTable;
(void) fabricIndex;
CommonOnFabricChange(fabricIndex);
tehampson marked this conversation as resolved.
Show resolved Hide resolved
}

private:
void ClearCASEResumptionStateOnFabricChange(chip::FabricIndex fabricIndex)
{
auto * sessionResumptionStorage = mServer->GetSessionResumptionStorage();
VerifyOrReturn(sessionResumptionStorage != nullptr);
CHIP_ERROR err = sessionResumptionStorage->DeleteAll(fabricIndex);
tehampson marked this conversation as resolved.
Show resolved Hide resolved
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
"Warning, failed to delete session resumption state for fabric index 0x%x: %" CHIP_ERROR_FORMAT,
static_cast<unsigned>(fabricIndex), err.Format());
}
}

Server * mServer = nullptr;
};

Expand Down
2 changes: 2 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CHIP_ERROR SessionManager::Init(System::Layer * systemLayer, TransportMgrBase *
VerifyOrReturnError(transportMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(storageDelegate != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(fabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorOnFailure(fabricTable->AddFabricDelegate(this));

mState = State::kInitialized;
mSystemLayer = systemLayer;
Expand All @@ -102,6 +103,7 @@ CHIP_ERROR SessionManager::Init(System::Layer * systemLayer, TransportMgrBase *

void SessionManager::Shutdown()
{
mFabricTable->RemoveFabricDelegate(this);
mMessageCounterManager = nullptr;

mState = State::kNotReady;
Expand Down
24 changes: 23 additions & 1 deletion src/transport/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class EncryptedPacketBufferHandle final : private System::PacketBufferHandle
EncryptedPacketBufferHandle(PacketBufferHandle && aBuffer) : PacketBufferHandle(std::move(aBuffer)) {}
};

class DLL_EXPORT SessionManager : public TransportMgrDelegate
class DLL_EXPORT SessionManager : public TransportMgrDelegate, public FabricTable::Delegate
{
public:
SessionManager();
Expand Down Expand Up @@ -251,6 +251,28 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate
using SessionHandleCallback = bool (*)(void * context, SessionHandle & sessionHandle);
CHIP_ERROR ForEachSessionHandle(void * context, SessionHandleCallback callback);

//// FabricTable::Delegate Implementation ////
void OnFabricDeletedFromStorage(FabricTable & fabricTable, FabricIndex fabricIndex) override
{
(void) fabricTable;
this->FabricRemoved(fabricIndex);
tehampson marked this conversation as resolved.
Show resolved Hide resolved
}
void OnFabricRetrievedFromStorage(FabricTable & fabricTable, FabricIndex fabricIndex) override
{
(void) fabricTable;
(void) fabricIndex;
}
void OnFabricPersistedToStorage(FabricTable & fabricTable, FabricIndex fabricIndex) override
{
(void) fabricTable;
(void) fabricIndex;
}
void OnFabricNOCUpdated(chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) override
{
(void) fabricTable;
(void) fabricIndex;
}

private:
/**
* The State of a secure transport object.
Expand Down