From 0face33f4700f4ec7945ac6c1ff41cd3a9bfb43a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 21 Dec 2022 09:42:52 -0500 Subject: [PATCH] Go back to using the storage key 1.0 used for group fabric info. (#24163) https://github.com/project-chip/connectedhomeip/pull/23409 changed the key under which we store group fabric info, which breaks reception of group messages if a node updates from before that change to after that change. We should just keep using the same key name, especially because sharing a single storage key for all possible fabric lists (groups and whatever else will want to store lists of fabric indices) does not necessarily make sense. Fixes https://github.com/project-chip/connectedhomeip/issues/24161 --- src/credentials/GroupDataProviderImpl.cpp | 10 +++++++++- src/lib/support/CommonPersistentData.h | 7 ++----- src/lib/support/DefaultStorageKeyAllocator.h | 4 +--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 87eb9d04d6ee4b..95764967dab051 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -33,7 +33,15 @@ using GroupEndpoint = GroupDataProvider::GroupEndpoint; using EpochKey = GroupDataProvider::EpochKey; using KeySet = GroupDataProvider::KeySet; using GroupSession = GroupDataProvider::GroupSession; -using FabricList = CommonPersistentData::FabricList; + +struct FabricList : public CommonPersistentData::FabricList +{ + CHIP_ERROR UpdateKey(StorageKeyName & key) override + { + key = DefaultStorageKeyAllocator::GroupFabricList(); + return CHIP_NO_ERROR; + } +}; constexpr size_t kPersistentBufferMax = 128; diff --git a/src/lib/support/CommonPersistentData.h b/src/lib/support/CommonPersistentData.h index 24c3e9a0354ce4..f04ba591959c4e 100644 --- a/src/lib/support/CommonPersistentData.h +++ b/src/lib/support/CommonPersistentData.h @@ -76,11 +76,8 @@ struct StoredDataList : public PersistentData constexpr size_t kPersistentFabricBufferMax = 32; struct FabricList : StoredDataList { - CHIP_ERROR UpdateKey(StorageKeyName & key) override - { - key = DefaultStorageKeyAllocator::FabricList(); - return CHIP_NO_ERROR; - } + // Subclasses need to define UpdateKey to be whatever fabric list key they + // care about. void Clear() override { diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index dd7098ecf607f9..6a4b906c2426b8 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -102,9 +102,6 @@ class DefaultStorageKeyAllocator static StorageKeyName FabricMetadata(FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/m", fabric); } static StorageKeyName FabricOpKey(FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/o", fabric); } - // Fabric List - static StorageKeyName FabricList() { return StorageKeyName::FromConst("g/fl"); } - // Fail-safe handling static StorageKeyName FailSafeCommitMarkerKey() { return StorageKeyName::FromConst("g/fs/c"); } static StorageKeyName FailSafeNetworkConfig() { return StorageKeyName::FromConst("g/fs/n"); } @@ -147,6 +144,7 @@ class DefaultStorageKeyAllocator // Group Data Provider // List of fabric indices that have endpoint-to-group associations defined. + static StorageKeyName GroupFabricList() { return StorageKeyName::FromConst("g/gfl"); } static StorageKeyName FabricGroups(chip::FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/g", fabric); } static StorageKeyName FabricGroup(chip::FabricIndex fabric, chip::GroupId group) {