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

Implement shadow fail-safe data in FabricTable #19819

Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
54b18f9
Implement shadow fail-safe data in FabricTable
tcarmelveilleux Jun 21, 2022
9ae8c22
Restyled by clang-format
restyled-commits Jun 21, 2022
35c7eeb
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 21, 2022
d37dccd
Fixes after merging master
tcarmelveilleux Jun 21, 2022
beff07e
Rename callback of FabricTable::Delegate
tcarmelveilleux Jun 21, 2022
003a59a
Rekick restyle
tcarmelveilleux Jun 21, 2022
a56451d
restyle
tcarmelveilleux Jun 21, 2022
98a7f51
Align last known good time commit / revert to shadow fail-safe approach
msandstedt Jun 21, 2022
6e6122e
Fix CI
tcarmelveilleux Jun 21, 2022
50c67f7
Merge pull request #9 from msandstedt/update-fabrictable-new-opcert-s…
tcarmelveilleux Jun 21, 2022
59d5e58
Fix TV app
tcarmelveilleux Jun 22, 2022
5b4874e
Merge remote-tracking branch 'origin/update-fabrictable-new-opcert-st…
tcarmelveilleux Jun 22, 2022
fa5157c
Reduce flash usage on K32W0 by disabling detail (verbose) logs
tcarmelveilleux Jun 22, 2022
b3a6461
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 22, 2022
e94260b
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 22, 2022
db03f18
Disable progress logging in TI platform lock example to save flash
tcarmelveilleux Jun 22, 2022
4835323
Disable progress logging in TI platform shell example to save flash
tcarmelveilleux Jun 22, 2022
8ea7610
Reduce stack usage of TestEventLogging
tcarmelveilleux Jun 22, 2022
45550c6
Apply review comments from @msandstedt
tcarmelveilleux Jun 22, 2022
52699c4
Save stack for Nordic build
tcarmelveilleux Jun 22, 2022
e62391e
Save stack for Nordic build, some more
tcarmelveilleux Jun 22, 2022
56c610d
Added unit tests for all basic operations
tcarmelveilleux Jun 23, 2022
ef143c6
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 23, 2022
626e738
Fix merge conflict
tcarmelveilleux Jun 23, 2022
ed6db09
Restyle
tcarmelveilleux Jun 23, 2022
6962ec1
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 23, 2022
5d019c8
Change nrf connect stack limit up by 512 bytes for fake unit test com…
tcarmelveilleux Jun 23, 2022
3decd98
Revert "Save stack for Nordic build"
tcarmelveilleux Jun 23, 2022
33ef943
Revert "Save stack for Nordic build, some more"
tcarmelveilleux Jun 23, 2022
5dd808c
Fix UpdateLabel
tcarmelveilleux Jun 23, 2022
3eb3a16
Apply review comments, add ACL fabric removal
tcarmelveilleux Jun 23, 2022
84a871c
Apply review comments
tcarmelveilleux Jun 23, 2022
2dda34d
per bzbarsky, clear in-memory Last Known Good Time if revert fails
msandstedt Jun 23, 2022
c3ebba5
Merge pull request #10 from msandstedt/update-fabrictable-new-opcert-…
tcarmelveilleux Jun 23, 2022
efa0c5f
Apply fixes from @bzbarsky-apple
tcarmelveilleux Jun 23, 2022
f4d541b
Merge remote-tracking branch 'origin/update-fabrictable-new-opcert-st…
tcarmelveilleux Jun 23, 2022
684d8e8
Apply more review comments
tcarmelveilleux Jun 23, 2022
d619d56
Restyled
tcarmelveilleux Jun 23, 2022
225ab8f
Fix tests
tcarmelveilleux Jun 23, 2022
0e33917
Add unit test for iterator
tcarmelveilleux Jun 23, 2022
f09d11f
Iterator now works
tcarmelveilleux Jun 23, 2022
05cc156
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 23, 2022
eea33f0
Fix semantic merge conflict
tcarmelveilleux Jun 23, 2022
2b17b3e
Restyled
tcarmelveilleux Jun 23, 2022
4935173
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 23, 2022
cbbf425
Fix predicates for storage presence temporarily
tcarmelveilleux Jun 23, 2022
5691e4a
Fix Darwin build
bzbarsky-apple Jun 23, 2022
92d340e
Merge pull request #11 from bzbarsky-apple/testing
tcarmelveilleux Jun 23, 2022
29f01dd
Add missing docs, move methods to private that shouldn't be public
tcarmelveilleux Jun 24, 2022
c182cfe
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 24, 2022
3efe420
Change stack warning temporarily to pass on nRFConnect
tcarmelveilleux Jun 24, 2022
50818c4
Make MatterControllerFactory use const FabricInfo
tcarmelveilleux Jun 24, 2022
9f0b34e
Restyle
tcarmelveilleux Jun 24, 2022
54376dd
Merge remote-tracking branch 'upstream/master' into update-fabrictabl…
tcarmelveilleux Jun 24, 2022
d8864e3
Fix semantic conflict on SessionManager
tcarmelveilleux Jun 24, 2022
096a76a
Fix an init ordering issue in TestSessionManager.cpp
tcarmelveilleux Jun 24, 2022
21ab76b
Fix SessionManager shutdown
tcarmelveilleux Jun 24, 2022
444cbd5
Restyled
tcarmelveilleux Jun 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restyled
tcarmelveilleux committed Jun 23, 2022
commit d619d569e5d16909f707a192e0e777b7aaa31a47
22 changes: 11 additions & 11 deletions examples/chip-tool/commands/group/Commands.h
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ class ShowControllerGroups : public CHIPCommand
fprintf(stderr, " | Available Groups : |\n");
fprintf(stderr, " +-------------------------------------------------------------------------------------+\n");
fprintf(stderr, " | Group Id | KeySet Id | Group Name |\n");
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
auto it = groupDataProvider->IterateGroupInfo(fabricIndex);
chip::Credentials::GroupDataProvider::GroupInfo group;
@@ -97,7 +97,7 @@ class AddGroup : public CHIPCommand
return CHIP_ERROR_INVALID_ARGUMENT;
}

chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
chip::Credentials::GroupDataProvider::GroupInfo group;

@@ -131,7 +131,7 @@ class RemoveGroup : public CHIPCommand
return CHIP_ERROR_INVALID_ARGUMENT;
}

chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
ReturnErrorOnFailure(groupDataProvider->RemoveGroupInfo(fabricIndex, groupId));
SetCommandExitStatus(CHIP_NO_ERROR);
@@ -150,7 +150,7 @@ class ShowKeySets : public CHIPCommand

CHIP_ERROR RunCommand() override
{
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
chip::Credentials::GroupDataProvider::KeySet keySet;

@@ -189,8 +189,8 @@ class BindKeySet : public CHIPCommand

CHIP_ERROR RunCommand() override
{
size_t current_count = 0;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
size_t current_count = 0;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();

auto iter = groupDataProvider->IterateGroupKeys(fabricIndex);
@@ -221,8 +221,8 @@ class UnbindKeySet : public CHIPCommand

CHIP_ERROR RunCommand() override
{
size_t index = 0;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
size_t index = 0;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
auto iter = groupDataProvider->IterateGroupKeys(fabricIndex);
size_t maxCount = iter->Count();
@@ -266,7 +266,7 @@ class AddKeySet : public CHIPCommand

CHIP_ERROR RunCommand() override
{
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();
uint8_t compressed_fabric_id[sizeof(uint64_t)];
chip::MutableByteSpan compressed_fabric_id_span(compressed_fabric_id);
@@ -309,8 +309,8 @@ class RemoveKeySet : public CHIPCommand

CHIP_ERROR RunCommand() override
{
CHIP_ERROR err = CHIP_NO_ERROR;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
CHIP_ERROR err = CHIP_NO_ERROR;
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
chip::Credentials::GroupDataProvider * groupDataProvider = chip::Credentials::GetGroupDataProvider();

// Unbind all group
2 changes: 1 addition & 1 deletion src/access/AccessControl.h
Original file line number Diff line number Diff line change
@@ -597,7 +597,7 @@ class AccessControl
while (aclCount)
{
CHIP_ERROR err = DeleteEntry(nullptr, fabricIndex, --aclCount);
stickyError = (stickyError == CHIP_NO_ERROR) ? err : stickyError;
stickyError = (stickyError == CHIP_NO_ERROR) ? err : stickyError;
}
}

5 changes: 3 additions & 2 deletions src/access/tests/TestAccessControl.cpp
Original file line number Diff line number Diff line change
@@ -777,7 +777,8 @@ constexpr EntryData entryData1[] = {
};

constexpr size_t entryData1Count = ArraySize(entryData1);
static_assert(entryData1Count == (kNumFabric1EntriesInEntryData1 + kNumFabric2EntriesInEntryData1), "Must maintain both fabric counts for some tests");
static_assert(entryData1Count == (kNumFabric1EntriesInEntryData1 + kNumFabric2EntriesInEntryData1),
"Must maintain both fabric counts for some tests");

struct CheckData
{
@@ -1771,7 +1772,7 @@ void TestDeleteEntry(nlTestSuite * inSuite, void * inContext)
// After deleting Fabric index 1, we should have the number of entries of Fabric index 2
NL_TEST_ASSERT(inSuite, accessControl.DeleteAllEntriesForFabric(1) == CHIP_NO_ERROR);
size_t numEntriesForFabricIndex2 = 0;
size_t numTotalEntries = 0;
size_t numTotalEntries = 0;
NL_TEST_ASSERT(inSuite, accessControl.GetEntryCount(2, numEntriesForFabricIndex2) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, accessControl.GetEntryCount(numTotalEntries) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, numEntriesForFabricIndex2 == kNumFabric2EntriesInEntryData1);
Original file line number Diff line number Diff line change
@@ -371,7 +371,7 @@ constexpr size_t kMaxRspLen = 900;
// logic.
class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate
{
public:
public:
// Gets called when a fabric is deleted from KVS store
void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) override
{
@@ -402,10 +402,7 @@ class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate
NotifyFabricTableChanged();
}

void OnFabricUpdated(const FabricTable & fabricTable, FabricIndex fabricIndex) override
{
NotifyFabricTableChanged();
}
void OnFabricUpdated(const FabricTable & fabricTable, FabricIndex fabricIndex) override { NotifyFabricTableChanged(); }

// Gets called when a fabric in FabricTable is persisted to storage
void OnFabricCommitted(const FabricTable & fabricTable, FabricIndex fabricIndex) override
@@ -423,14 +420,13 @@ class OpCredsFabricTableDelegate : public chip::FabricTable::Delegate
NotifyFabricTableChanged();
}

private:
private:
void NotifyFabricTableChanged()
{
// Opcreds cluster is always on Endpoint 0
MatterReportingAttributeChangeCallback(0, OperationalCredentials::Id,
OperationalCredentials::Attributes::CommissionedFabrics::Id);
MatterReportingAttributeChangeCallback(0, OperationalCredentials::Id,
OperationalCredentials::Attributes::Fabrics::Id);
MatterReportingAttributeChangeCallback(0, OperationalCredentials::Id, OperationalCredentials::Attributes::Fabrics::Id);
}
};

@@ -798,12 +794,12 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co
// and error handling does not assist.
if (groupDataProvider != nullptr)
{
(void)groupDataProvider->RemoveFabric(newFabricIndex);
(void) groupDataProvider->RemoveFabric(newFabricIndex);
}

// TODO(#19898): All ACL work done within AddNOC does not trigger ACL cluster updates

(void)Access::GetAccessControl().DeleteAllEntriesForFabric(newFabricIndex);
(void) Access::GetAccessControl().DeleteAllEntriesForFabric(newFabricIndex);

MatterReportingAttributeChangeCallback(commandPath.mEndpointId, OperationalCredentials::Id,
OperationalCredentials::Attributes::CommissionedFabrics::Id);
@@ -860,7 +856,7 @@ bool emberAfOperationalCredentialsClusterUpdateNOCCallback(app::CommandHandler *
FabricInfo * fabricInfo = RetrieveCurrentFabric(commandObj);

bool csrWasForUpdateNoc = false; //< Output param of HasPendingOperationalKey
bool hasPendingKey = fabricTable.HasPendingOperationalKey(csrWasForUpdateNoc);
bool hasPendingKey = fabricTable.HasPendingOperationalKey(csrWasForUpdateNoc);

VerifyOrExit(NOCValue.size() <= Credentials::kMaxCHIPCertLength, nonDefaultStatus = Status::InvalidCommand);
VerifyOrExit(!ICACValue.HasValue() || ICACValue.Value().size() <= Credentials::kMaxCHIPCertLength,
3 changes: 1 addition & 2 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
@@ -450,8 +450,7 @@ class Server
CHIP_ERROR aclErr = Access::GetAccessControl().DeleteAllEntriesForFabric(fabricIndex);
if (aclErr != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
"Warning, failed to delete access control state for fabric index 0x%x: %" CHIP_ERROR_FORMAT,
ChipLogError(AppServer, "Warning, failed to delete access control state for fabric index 0x%x: %" CHIP_ERROR_FORMAT,
static_cast<unsigned>(fabricIndex), aclErr.Format());
}
}