From 926198bfda98eb7fd533faa6ce8aa039fec8a559 Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Thu, 9 Dec 2021 15:28:25 +0800 Subject: [PATCH] Remove time source template argument of sessions --- src/app/CASEClient.cpp | 3 +- src/controller/CHIPDeviceController.cpp | 3 +- src/messaging/tests/MessagingContext.cpp | 13 +++-- src/transport/SecureSession.h | 10 ++-- src/transport/SecureSessionTable.h | 18 +++---- src/transport/SessionManager.cpp | 16 +++--- src/transport/SessionManager.h | 4 +- src/transport/UnauthenticatedSessionTable.h | 29 +++++------ src/transport/tests/TestPeerConnections.cpp | 55 +++++++++++---------- 9 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/app/CASEClient.cpp b/src/app/CASEClient.cpp index e4bba8e6c9e0b1..82d31abc1fe39d 100644 --- a/src/app/CASEClient.cpp +++ b/src/app/CASEClient.cpp @@ -32,7 +32,8 @@ CHIP_ERROR CASEClient::EstablishSession(PeerId peer, const Transport::PeerAddres { // Create a UnauthenticatedSession for CASE pairing. // Don't use mSecureSession here, because mSecureSession is for encrypted communication. - Optional session = mInitParams.sessionManager->CreateUnauthenticatedSession(peerAddress, mrpConfig); + Optional session = mInitParams.sessionManager->CreateUnauthenticatedSession( + peerAddress, System::SystemClock().GetMonotonicTimestamp(), mrpConfig); VerifyOrReturnError(session.HasValue(), CHIP_ERROR_NO_MEMORY); Messaging::ExchangeContext * exchange = mInitParams.exchangeMgr->NewContext(session.Value(), &mCASESession); diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 1840ea11dd06c9..efec3018dddcf7 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -848,7 +848,8 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re } #endif // TODO: In some cases like PASE over IP, CRA and CRI values from commissionable node service should be used - session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), device->GetMRPConfig()); + session = mSystemState->SessionMgr()->CreateUnauthenticatedSession( + params.GetPeerAddress(), System::SystemClock().GetMonotonicTimestamp(), device->GetMRPConfig()); VerifyOrExit(session.HasValue(), err = CHIP_ERROR_NO_MEMORY); exchangeCtxt = mSystemState->ExchangeMgr()->NewContext(session.Value(), &device->GetPairing()); diff --git a/src/messaging/tests/MessagingContext.cpp b/src/messaging/tests/MessagingContext.cpp index 5e9743556bedd1..5008ca89b1ed71 100644 --- a/src/messaging/tests/MessagingContext.cpp +++ b/src/messaging/tests/MessagingContext.cpp @@ -72,14 +72,19 @@ SessionHandle MessagingContext::GetSessionBobToFriends() Messaging::ExchangeContext * MessagingContext::NewUnauthenticatedExchangeToAlice(Messaging::ExchangeDelegate * delegate) { - return mExchangeManager.NewContext(mSessionManager.CreateUnauthenticatedSession(mAliceAddress, gDefaultMRPConfig).Value(), - delegate); + return mExchangeManager.NewContext( + mSessionManager + .CreateUnauthenticatedSession(mAliceAddress, System::SystemClock().GetMonotonicTimestamp(), gDefaultMRPConfig) + .Value(), + delegate); } Messaging::ExchangeContext * MessagingContext::NewUnauthenticatedExchangeToBob(Messaging::ExchangeDelegate * delegate) { - return mExchangeManager.NewContext(mSessionManager.CreateUnauthenticatedSession(mBobAddress, gDefaultMRPConfig).Value(), - delegate); + return mExchangeManager.NewContext( + mSessionManager.CreateUnauthenticatedSession(mBobAddress, System::SystemClock().GetMonotonicTimestamp(), gDefaultMRPConfig) + .Value(), + delegate); } Messaging::ExchangeContext * MessagingContext::NewExchangeToAlice(Messaging::ExchangeDelegate * delegate) diff --git a/src/transport/SecureSession.h b/src/transport/SecureSession.h index 3627d4da7d81a5..9e456071670a62 100644 --- a/src/transport/SecureSession.h +++ b/src/transport/SecureSession.h @@ -65,14 +65,12 @@ class SecureSession }; SecureSession(Type secureSessionType, uint16_t localSessionId, NodeId peerNodeId, Credentials::CATValues peerCATs, - uint16_t peerSessionId, FabricIndex fabric, const ReliableMessageProtocolConfig & config, - System::Clock::Timestamp currentTime) : + uint16_t peerSessionId, FabricIndex fabric, System::Clock::Timestamp now, + const ReliableMessageProtocolConfig & config) : mSecureSessionType(secureSessionType), mPeerNodeId(peerNodeId), mPeerCATs(peerCATs), mLocalSessionId(localSessionId), mPeerSessionId(peerSessionId), - mFabric(fabric), mMRPConfig(config) - { - SetLastActivityTime(currentTime); - } + mFabric(fabric), mLastActivityTime(now), mMRPConfig(config) + {} SecureSession(SecureSession &&) = delete; SecureSession(const SecureSession &) = delete; diff --git a/src/transport/SecureSessionTable.h b/src/transport/SecureSessionTable.h index 9b6c9e99538ccf..68b63b95f88626 100644 --- a/src/transport/SecureSessionTable.h +++ b/src/transport/SecureSessionTable.h @@ -37,7 +37,7 @@ constexpr const uint16_t kAnyKeyId = 0xffff; * - handle session active time and expiration * - allocate and free space for sessions. */ -template +template class SecureSessionTable { public: @@ -60,10 +60,9 @@ class SecureSessionTable CHECK_RETURN_VALUE SecureSession * CreateNewSecureSession(SecureSession::Type secureSessionType, uint16_t localSessionId, NodeId peerNodeId, Credentials::CATValues peerCATs, uint16_t peerSessionId, FabricIndex fabric, - const ReliableMessageProtocolConfig & config) + System::Clock::Timestamp now, const ReliableMessageProtocolConfig & config) { - return mEntries.CreateObject(secureSessionType, localSessionId, peerNodeId, peerCATs, peerSessionId, fabric, config, - mTimeSource.GetMonotonicTimestamp()); + return mEntries.CreateObject(secureSessionType, localSessionId, peerNodeId, peerCATs, peerSessionId, fabric, now, config); } void ReleaseSession(SecureSession * session) { mEntries.ReleaseObject(session); } @@ -97,7 +96,7 @@ class SecureSessionTable } /// Convenience method to mark a session as active - void MarkSessionActive(SecureSession * state) { state->SetLastActivityTime(mTimeSource.GetMonotonicTimestamp()); } + void MarkSessionActive(System::Clock::Timestamp now, SecureSession * state) { state->SetLastActivityTime(now); } /** * Iterates through all active sessions and expires any sessions with an idle time @@ -106,11 +105,10 @@ class SecureSessionTable * Expiring a session involves callback execution and then clearing the internal state. */ template - void ExpireInactiveSessions(System::Clock::Timestamp maxIdleTime, Callback callback) + void ExpireInactiveSessions(System::Clock::Timestamp now, System::Clock::Timestamp maxIdleTime, Callback callback) { - const System::Clock::Timestamp currentTime = mTimeSource.GetMonotonicTimestamp(); mEntries.ForEachActiveObject([&](auto session) { - if (session->GetLastActivityTime() + maxIdleTime < currentTime) + if (session->GetLastActivityTime() + maxIdleTime < now) { callback(*session); ReleaseSession(session); @@ -119,11 +117,7 @@ class SecureSessionTable }); } - /// Allows access to the underlying time source used for keeping track of session active time - Time::TimeSource & GetTimeSource() { return mTimeSource; } - private: - Time::TimeSource mTimeSource; BitMapObjectPool mEntries; }; diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index acfe8f24a53a79..0045340b50d58c 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -222,7 +222,7 @@ CHIP_ERROR SessionManager::SendPreparedMessage(SessionHandle sessionHandle, cons } // This marks any connection where we send data to as 'active' - mSecureSessions.MarkSessionActive(session); + mSecureSessions.MarkSessionActive(System::SystemClock().GetMonotonicTimestamp(), session); destination = &session->GetPeerAddress(); @@ -237,7 +237,7 @@ CHIP_ERROR SessionManager::SendPreparedMessage(SessionHandle sessionHandle, cons else { auto unauthenticated = sessionHandle.GetUnauthenticatedSession(); - mUnauthenticatedSessions.MarkSessionActive(unauthenticated); + mUnauthenticatedSessions.MarkSessionActive(System::SystemClock().GetMonotonicTimestamp(), unauthenticated); destination = &unauthenticated->GetPeerAddress(); ChipLogProgress(Inet, @@ -314,7 +314,8 @@ CHIP_ERROR SessionManager::NewPairing(const Optional & p ChipLogDetail(Inet, "New secure session created for device 0x" ChipLogFormatX64 ", key %d!!", ChipLogValueX64(peerNodeId), peerSessionId); session = mSecureSessions.CreateNewSecureSession(pairing->GetSecureSessionType(), localSessionId, peerNodeId, - pairing->GetPeerCATs(), peerSessionId, fabric, pairing->GetMRPConfig()); + pairing->GetPeerCATs(), peerSessionId, fabric, + System::SystemClock().GetMonotonicTimestamp(), pairing->GetMRPConfig()); ReturnErrorCodeIf(session == nullptr, CHIP_ERROR_NO_MEMORY); if (peerAddr.HasValue() && peerAddr.Value().GetIPAddress() != Inet::IPAddress::Any) @@ -419,7 +420,7 @@ void SessionManager::MessageDispatch(const PacketHeader & packetHeader, const Tr System::PacketBufferHandle && msg) { Optional optionalSession = - mUnauthenticatedSessions.FindOrAllocateEntry(peerAddress, gDefaultMRPConfig); + mUnauthenticatedSessions.FindOrAllocateEntry(peerAddress, System::SystemClock().GetMonotonicTimestamp(), gDefaultMRPConfig); if (!optionalSession.HasValue()) { ChipLogError(Inet, "UnauthenticatedSession exhausted"); @@ -438,7 +439,7 @@ void SessionManager::MessageDispatch(const PacketHeader & packetHeader, const Tr } VerifyOrDie(err == CHIP_NO_ERROR); - mUnauthenticatedSessions.MarkSessionActive(session); + mUnauthenticatedSessions.MarkSessionActive(System::SystemClock().GetMonotonicTimestamp(), session); PayloadHeader payloadHeader; ReturnOnFailure(payloadHeader.DecodeAndConsume(msg)); @@ -501,7 +502,7 @@ void SessionManager::SecureUnicastMessageDispatch(const PacketHeader & packetHea return; } - mSecureSessions.MarkSessionActive(session); + mSecureSessions.MarkSessionActive(System::SystemClock().GetMonotonicTimestamp(), session); if (isDuplicate == SessionMessageDelegate::DuplicateMessage::Yes && !payloadHeader.NeedsAck()) { @@ -627,7 +628,8 @@ void SessionManager::ExpiryTimerCallback(System::Layer * layer, void * param) // TODO(#2279): session expiration is currently disabled until rekeying is supported // the #ifdef should be removed after that. mgr->mSecureSessions.ExpireInactiveSessions( - CHIP_PEER_CONNECTION_TIMEOUT_MS, [this](const Transport::SecureSession & state1) { HandleConnectionExpired(state1); }); + System::SystemClock().GetMonotonicTimestamp(), System::Clock::Milliseconds32(CHIP_PEER_CONNECTION_TIMEOUT_MS), + [this](const Transport::SecureSession & state1) { HandleConnectionExpired(state1); }); #endif mgr->ScheduleExpiryTimer(); // re-schedule the oneshot timer } diff --git a/src/transport/SessionManager.h b/src/transport/SessionManager.h index 88ff08e1d26dbb..19e563525dd0e6 100644 --- a/src/transport/SessionManager.h +++ b/src/transport/SessionManager.h @@ -253,11 +253,11 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate */ void OnMessageReceived(const Transport::PeerAddress & source, System::PacketBufferHandle && msgBuf) override; - Optional CreateUnauthenticatedSession(const Transport::PeerAddress & peerAddress, + Optional CreateUnauthenticatedSession(const Transport::PeerAddress & peerAddress, System::Clock::Timestamp now, const ReliableMessageProtocolConfig & config) { Optional session = - mUnauthenticatedSessions.FindOrAllocateEntry(peerAddress, config); + mUnauthenticatedSessions.FindOrAllocateEntry(peerAddress, now, config); return session.HasValue() ? MakeOptional(session.Value()) : NullOptional; } diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index 3d1d9a3dedd1ff..72d6759239a7c9 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -48,8 +48,10 @@ class UnauthenticatedSessionDeleter class UnauthenticatedSession : public ReferenceCounted { public: - UnauthenticatedSession(const PeerAddress & address, const ReliableMessageProtocolConfig & config) : - mPeerAddress(address), mMRPConfig(config) + UnauthenticatedSession(const PeerAddress & address, System::Clock::Timestamp now, + const ReliableMessageProtocolConfig & config) : + mPeerAddress(address), + mLastActivityTime(now), mMRPConfig(config) {} UnauthenticatedSession(const UnauthenticatedSession &) = delete; @@ -69,9 +71,8 @@ class UnauthenticatedSession : public ReferenceCounted +template class UnauthenticatedSessionTable { public: @@ -94,14 +95,14 @@ class UnauthenticatedSessionTable * @return the session found or allocated, nullptr if not found and allocation failed. */ CHECK_RETURN_VALUE - Optional FindOrAllocateEntry(const PeerAddress & address, + Optional FindOrAllocateEntry(const PeerAddress & address, System::Clock::Timestamp now, const ReliableMessageProtocolConfig & config) { UnauthenticatedSession * result = FindEntry(address); if (result != nullptr) return MakeOptional(*result); - CHIP_ERROR err = AllocEntry(address, config, result); + CHIP_ERROR err = AllocEntry(address, now, config, result); if (err == CHIP_NO_ERROR) { return MakeOptional(*result); @@ -113,14 +114,11 @@ class UnauthenticatedSessionTable } /// Mark a session as active - void MarkSessionActive(UnauthenticatedSessionHandle session) + void MarkSessionActive(System::Clock::Timestamp now, UnauthenticatedSessionHandle session) { - session->SetLastActivityTime(mTimeSource.GetMonotonicTimestamp()); + session->SetLastActivityTime(now); } - /// Allows access to the underlying time source used for keeping track of session active time - Time::TimeSource & GetTimeSource() { return mTimeSource; } - private: /** * Allocates a new session out of the internal resource pool. @@ -129,10 +127,10 @@ class UnauthenticatedSessionTable * CHIP_ERROR_NO_MEMORY). */ CHECK_RETURN_VALUE - CHIP_ERROR AllocEntry(const PeerAddress & address, const ReliableMessageProtocolConfig & config, + CHIP_ERROR AllocEntry(const PeerAddress & address, System::Clock::Timestamp now, const ReliableMessageProtocolConfig & config, UnauthenticatedSession *& entry) { - entry = mEntries.CreateObject(address, config); + entry = mEntries.CreateObject(address, now, config); if (entry != nullptr) return CHIP_NO_ERROR; @@ -142,7 +140,7 @@ class UnauthenticatedSessionTable return CHIP_ERROR_NO_MEMORY; } - mEntries.ResetObject(entry, address, config); + mEntries.ResetObject(entry, address, now, config); return CHIP_NO_ERROR; } @@ -222,7 +220,6 @@ class UnauthenticatedSessionTable return false; } - Time::TimeSource mTimeSource; BitMapObjectPool mEntries; }; diff --git a/src/transport/tests/TestPeerConnections.cpp b/src/transport/tests/TestPeerConnections.cpp index bee5e9cdfb7497..9b14817d1fa18b 100644 --- a/src/transport/tests/TestPeerConnections.cpp +++ b/src/transport/tests/TestPeerConnections.cpp @@ -63,13 +63,14 @@ const Credentials::CATValues kPeer3CATs = Credentials::kUndefinedCATs; void TestBasicFunctionality(nlTestSuite * inSuite, void * inContext) { SecureSession * statePtr; - SecureSessionTable<2, Time::Source::kTest> connections; - connections.GetTimeSource().SetMonotonicTimestamp(100_ms64); + SecureSessionTable<2> connections; + Time::TimeSource timeSource; + timeSource.SetMonotonicTimestamp(100_ms64); Credentials::CATValues peerCATs; // Node ID 1, peer key 1, local key 2 statePtr = connections.CreateNewSecureSession(kPeer1SessionType, 2, kPeer1NodeId, kPeer1CATs, 1, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); NL_TEST_ASSERT(inSuite, statePtr->GetSecureSessionType() == kPeer1SessionType); NL_TEST_ASSERT(inSuite, statePtr->GetPeerNodeId() == kPeer1NodeId); @@ -78,7 +79,7 @@ void TestBasicFunctionality(nlTestSuite * inSuite, void * inContext) // Node ID 2, peer key 3, local key 4 statePtr = connections.CreateNewSecureSession(kPeer2SessionType, 4, kPeer2NodeId, kPeer2CATs, 3, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); NL_TEST_ASSERT(inSuite, statePtr->GetSecureSessionType() == kPeer2SessionType); NL_TEST_ASSERT(inSuite, statePtr->GetPeerNodeId() == kPeer2NodeId); @@ -88,18 +89,19 @@ void TestBasicFunctionality(nlTestSuite * inSuite, void * inContext) // Insufficient space for new connections. Object is max size 2 statePtr = connections.CreateNewSecureSession(kPeer3SessionType, 6, kPeer3NodeId, kPeer3CATs, 5, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr == nullptr); } void TestFindByKeyId(nlTestSuite * inSuite, void * inContext) { SecureSession * statePtr; - SecureSessionTable<2, Time::Source::kTest> connections; + SecureSessionTable<2> connections; + Time::TimeSource timeSource; // Node ID 1, peer key 1, local key 2 statePtr = connections.CreateNewSecureSession(kPeer1SessionType, 2, kPeer1NodeId, kPeer1CATs, 1, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); NL_TEST_ASSERT(inSuite, !connections.FindSecureSessionByLocalKey(1)); @@ -107,7 +109,7 @@ void TestFindByKeyId(nlTestSuite * inSuite, void * inContext) // Node ID 2, peer key 3, local key 4 statePtr = connections.CreateNewSecureSession(kPeer2SessionType, 4, kPeer2NodeId, kPeer2CATs, 3, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); NL_TEST_ASSERT(inSuite, !connections.FindSecureSessionByLocalKey(3)); @@ -125,31 +127,32 @@ void TestExpireConnections(nlTestSuite * inSuite, void * inContext) { ExpiredCallInfo callInfo; SecureSession * statePtr; - SecureSessionTable<2, Time::Source::kTest> connections; + SecureSessionTable<2> connections; - connections.GetTimeSource().SetMonotonicTimestamp(100_ms64); + Time::TimeSource timeSource; + timeSource.SetMonotonicTimestamp(100_ms64); // Node ID 1, peer key 1, local key 2 statePtr = connections.CreateNewSecureSession(kPeer1SessionType, 2, kPeer1NodeId, kPeer1CATs, 1, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); statePtr->SetPeerAddress(kPeer1Addr); - connections.GetTimeSource().SetMonotonicTimestamp(200_ms64); + timeSource.SetMonotonicTimestamp(200_ms64); // Node ID 2, peer key 3, local key 4 statePtr = connections.CreateNewSecureSession(kPeer2SessionType, 4, kPeer2NodeId, kPeer2CATs, 3, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); statePtr->SetPeerAddress(kPeer2Addr); // cannot add before expiry - connections.GetTimeSource().SetMonotonicTimestamp(300_ms64); + timeSource.SetMonotonicTimestamp(300_ms64); statePtr = connections.CreateNewSecureSession(kPeer3SessionType, 6, kPeer3NodeId, kPeer3CATs, 5, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr == nullptr); // at time 300, this expires ip addr 1 - connections.ExpireInactiveSessions(150_ms64, [&callInfo](const SecureSession & state) { + connections.ExpireInactiveSessions(timeSource.GetMonotonicTimestamp(), 150_ms64, [&callInfo](const SecureSession & state) { callInfo.callCount++; callInfo.lastCallNodeId = state.GetPeerNodeId(); callInfo.lastCallPeerAddress = state.GetPeerAddress(); @@ -160,26 +163,26 @@ void TestExpireConnections(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, !connections.FindSecureSessionByLocalKey(2)); // now that the connections were expired, we can add peer3 - connections.GetTimeSource().SetMonotonicTimestamp(300_ms64); + timeSource.SetMonotonicTimestamp(300_ms64); // Node ID 3, peer key 5, local key 6 statePtr = connections.CreateNewSecureSession(kPeer3SessionType, 6, kPeer3NodeId, kPeer3CATs, 5, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); statePtr->SetPeerAddress(kPeer3Addr); - connections.GetTimeSource().SetMonotonicTimestamp(400_ms64); + timeSource.SetMonotonicTimestamp(400_ms64); NL_TEST_ASSERT(inSuite, statePtr = connections.FindSecureSessionByLocalKey(4)); - connections.MarkSessionActive(statePtr); - NL_TEST_ASSERT(inSuite, statePtr->GetLastActivityTime() == connections.GetTimeSource().GetMonotonicTimestamp()); + connections.MarkSessionActive(timeSource.GetMonotonicTimestamp(), statePtr); + NL_TEST_ASSERT(inSuite, statePtr->GetLastActivityTime() == timeSource.GetMonotonicTimestamp()); // At this time: // Peer 3 active at time 300 // Peer 2 active at time 400 - connections.GetTimeSource().SetMonotonicTimestamp(500_ms64); + timeSource.SetMonotonicTimestamp(500_ms64); callInfo.callCount = 0; - connections.ExpireInactiveSessions(150_ms64, [&callInfo](const SecureSession & state) { + connections.ExpireInactiveSessions(timeSource.GetMonotonicTimestamp(), 150_ms64, [&callInfo](const SecureSession & state) { callInfo.callCount++; callInfo.lastCallNodeId = state.GetPeerNodeId(); callInfo.lastCallPeerAddress = state.GetPeerAddress(); @@ -195,16 +198,16 @@ void TestExpireConnections(nlTestSuite * inSuite, void * inContext) // Node ID 1, peer key 1, local key 2 statePtr = connections.CreateNewSecureSession(kPeer1SessionType, 2, kPeer1NodeId, kPeer1CATs, 1, 0 /* fabricIndex */, - gDefaultMRPConfig); + timeSource.GetMonotonicTimestamp(), gDefaultMRPConfig); NL_TEST_ASSERT(inSuite, statePtr != nullptr); NL_TEST_ASSERT(inSuite, connections.FindSecureSessionByLocalKey(2)); NL_TEST_ASSERT(inSuite, connections.FindSecureSessionByLocalKey(4)); NL_TEST_ASSERT(inSuite, !connections.FindSecureSessionByLocalKey(6)); // peer 1 and 2 are active - connections.GetTimeSource().SetMonotonicTimestamp(1000_ms64); + timeSource.SetMonotonicTimestamp(1000_ms64); callInfo.callCount = 0; - connections.ExpireInactiveSessions(100_ms64, [&callInfo](const SecureSession & state) { + connections.ExpireInactiveSessions(timeSource.GetMonotonicTimestamp(), 100_ms64, [&callInfo](const SecureSession & state) { callInfo.callCount++; callInfo.lastCallNodeId = state.GetPeerNodeId(); callInfo.lastCallPeerAddress = state.GetPeerAddress();