Skip to content

Commit

Permalink
Error reporting cleanup (#6979)
Browse files Browse the repository at this point in the history
* Code cleanup: better error report for on receive errors, destination node id logging is a progress not an error

* Include fabric ID in progress message for secure transport. We may want to eventually maye this "Detail" in case logging is too verbose

* Take into account that node ids in packet headers are optional

* Restyle fixes and swap back error to progress

* Review comments and merge fix

* revert unwanted changes

* Updated the chip error logging conditional
  • Loading branch information
andy31415 authored and pull[bot] committed Jul 9, 2021
1 parent b4c2793 commit 2422113
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ CHIP_ERROR ExchangeManager::UnregisterUnsolicitedMessageHandlerForType(Protocols

void ExchangeManager::OnReceiveError(CHIP_ERROR error, const Transport::PeerAddress & source, SecureSessionMgr * msgLayer)
{
ChipLogError(ExchangeManager, "Accept FAILED, err = %s", ErrorStr(error));
#if CHIP_ERROR_LOGGING
char srcAddressStr[Transport::PeerAddress::kMaxToStringSize];
source.ToString(srcAddressStr);

ChipLogError(ExchangeManager, "Error receiving message from %s: %s", srcAddressStr, ErrorStr(error));
#endif // CHIP_ERROR_LOGGING
}

CHIP_ERROR ExchangeManager::RegisterUMH(Protocols::Id protocolId, int16_t msgType, ExchangeDelegate * delegate)
Expand Down
8 changes: 5 additions & 3 deletions src/transport/SecureSessionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,14 @@ void SecureSessionMgr::SecureMessageDispatch(const PacketHeader & packetHeader,

if (packetHeader.GetDestinationNodeId().HasValue())
{
ChipLogError(Inet, "Secure transport received message destined to node ID (0x" ChipLogFormatX64 ")",
ChipLogValueX64(packetHeader.GetDestinationNodeId().Value()));
ChipLogProgress(Inet, "Secure transport received message destined to fabric %d, node 0x" ChipLogFormatX64 ". Key ID %d",
static_cast<int>(state->GetAdminId()), ChipLogValueX64(packetHeader.GetDestinationNodeId().Value()),
packetHeader.GetEncryptionKeyID());
}
else
{
ChipLogError(Inet, "Secure transport received message without node ID with key ID (%d)", packetHeader.GetEncryptionKeyID());
ChipLogProgress(Inet, "Secure transport received message for fabric %d without node ID. Key ID %d",
static_cast<int>(state->GetAdminId()), packetHeader.GetEncryptionKeyID());
}

mPeerConnections.MarkConnectionActive(state);
Expand Down

0 comments on commit 2422113

Please sign in to comment.