Skip to content

Commit

Permalink
Don't try to do something with message delivery failures on other fab…
Browse files Browse the repository at this point in the history
…rics.

If we have DeviceController instances for multiple fabrics around, all
will be notified via OnFirstMessageDeliveryFailed on message delivery
failure for any message.  Ignore the notifications unless they are for
a message over a CASE session for the fabric the controller is
associated with (in which case it might actually make sense for that
controller to act on the notification by redoing operational address
discovery and CASE).
  • Loading branch information
bzbarsky-apple committed Mar 12, 2022
1 parent 4638993 commit c235545
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
32 changes: 28 additions & 4 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,34 @@ CHIP_ERROR DeviceController::DisconnectDevice(NodeId nodeId)

void DeviceController::OnFirstMessageDeliveryFailed(const SessionHandle & session)
{
VerifyOrReturn(mState == State::Initialized,
ChipLogError(Controller, "OnFirstMessageDeliveryFailed was called in incorrect state"));
VerifyOrReturn(session->GetSessionType() == Transport::Session::SessionType::kSecure);
CHIP_ERROR err = UpdateDevice(session->AsSecureSession()->GetPeerNodeId());
if (session->GetSessionType() != Session::SessionType::kSecure)
{
// Definitely not a CASE session.
return;
}

auto * secureSession = session->AsSecureSession();
if (secureSession->GetSecureSessionType() != SecureSession::Type::kCASE)
{
// Still not CASE.
return;
}

FabricIndex ourIndex;
CHIP_ERROR err = GetFabricIndex(&ourIndex);
if (err != CHIP_NO_ERROR)
{
// We can't really do CASE, now can we?
return;
}

if (ourIndex != session->GetFabricIndex())
{
// Not one of our sessions.
return;
}

err = UpdateDevice(secureSession->GetPeerNodeId());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller,
Expand Down
3 changes: 2 additions & 1 deletion src/transport/SessionDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class DLL_EXPORT SessionRecoveryDelegate
* Called when the first message delivery in a session failed,
* so actions aiming to recover connection can be performed.
*
* @param session The handle to the secure session
* @param session The handle to the session. This may be any session type
* that supports MRP.
*/
virtual void OnFirstMessageDeliveryFailed(const SessionHandle & session) = 0;
};
Expand Down

0 comments on commit c235545

Please sign in to comment.