[nexus] remove active node tracking (#12754)

This commit removes the active node tracking logic from the Nexus
simulation framework.

Previously, `Core` maintained a pointer to the `mActiveNode` and updated
it dynamically during processing and network events. This was necessary
so that log messages could be attributed to the correct node/instance.

With the recent introduction of "instance-aware logging" in the OpenThread
core, the logging mechanism natively knows which `otInstance` generated a
log. Therefore, manually tracking and context-switching the active node
in the Nexus framework is no longer required.

This change simplifies `nexus::Core`, removes context-switching overhead
from heavily utilized inline methods like `Node::Get<Type>()`, and allows
us to simplify the signature of `InfraIf::Receive()`.
This commit is contained in:
Abtin Keshavarzian
2026-03-25 10:36:11 -05:00
committed by GitHub
parent 37f09fe97e
commit a5593e7980
6 changed files with 7 additions and 28 deletions
+1 -6
View File
@@ -44,7 +44,6 @@ Core::Core(void)
: mCurNodeId(0)
, mPendingAction(false)
, mNow(0)
, mActiveNode(nullptr)
{
const char *pcapFile;
@@ -379,8 +378,6 @@ void Core::AdvanceTime(uint32_t aDuration)
void Core::Process(Node &aNode)
{
SetActiveNode(&aNode);
otTaskletsProcess(&aNode.GetInstance());
ProcessRadio(aNode);
@@ -400,8 +397,6 @@ void Core::Process(Node &aNode)
aNode.mAlarmMicro.mScheduled = false;
otPlatAlarmMicroFired(&aNode.GetInstance());
}
SetActiveNode(nullptr);
}
void Core::ProcessRadio(Node &aNode)
@@ -620,7 +615,7 @@ void Core::ProcessInfraIf(Node &aNode)
continue;
}
rxNode.mInfraIf.Receive(aNode, *message);
rxNode.mInfraIf.Receive(*message);
}
message->Free();
-4
View File
@@ -76,9 +76,6 @@ public:
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Used by platform implementation
void SetActiveNode(Node *aNode) { mActiveNode = aNode; }
Node *GetActiveNode(void) { return mActiveNode; }
void UpdateNextAlarmMilli(const Alarm &aAlarm);
void UpdateNextAlarmMicro(const Alarm &aAlarm);
void MarkPendingAction(void) { mPendingAction = true; }
@@ -134,7 +131,6 @@ private:
bool mPendingAction;
uint64_t mNow;
uint64_t mNextAlarmTime;
Node *mActiveNode;
};
void Log(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
+3 -5
View File
@@ -410,20 +410,18 @@ void InfraIf::SendUdp(const Ip6::Address &aSrcAddress,
Message *loopbackMessage = aPayload.Clone<kNoReservedHeader>();
VerifyOrQuit(loopbackMessage != nullptr);
Receive(GetNode(), *loopbackMessage);
Receive(*loopbackMessage);
loopbackMessage->Free();
}
mPendingTxQueue.Enqueue(aPayload);
}
void InfraIf::Receive(Node &aSrcNode, Message &aMessage)
void InfraIf::Receive(Message &aMessage)
{
Node &node = GetNode();
Ip6::Headers headers;
Core::Get().SetActiveNode(&node);
aMessage.SetOffset(0);
SuccessOrExit(headers.ParseFrom(aMessage));
@@ -515,7 +513,7 @@ void InfraIf::Receive(Node &aSrcNode, Message &aMessage)
}
exit:
Core::Get().SetActiveNode(&aSrcNode);
return;
}
void InfraIf::HandleEchoRequest(const Ip6::Header &aHeader, Message &aMessage)
+1 -1
View File
@@ -84,7 +84,7 @@ public:
uint16_t aDestPort,
Message &aPayload);
void Receive(Node &aSrcNode, Message &aMessage);
void Receive(Message &aMessage);
void GetLinkLayerAddress(LinkLayerAddress &aLinkLayerAddress) const;
typedef void (*EchoReplyHandler)(void *aContext, const Ip6::Address &aSource, uint16_t aId, uint16_t aSequence);
-2
View File
@@ -166,8 +166,6 @@ void Node::HandleReceive(otMessage *aMessage)
VerifyOrExit(header->GetDestination().GetScope() > Ip6::Address::kRealmLocalScope);
Core::Get().SetActiveNode(this);
if (header->GetDestination().IsMulticast())
{
VerifyOrExit(Get<BackboneRouter::Local>().IsPrimary());
+2 -10
View File
@@ -121,17 +121,9 @@ public:
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template <typename Type> Type &Get(void)
{
Core::Get().SetActiveNode(this);
return Instance::Get<Type>();
}
template <typename Type> Type &Get(void) { return Instance::Get<Type>(); }
Instance &GetInstance(void)
{
Core::Get().SetActiveNode(this);
return *this;
}
Instance &GetInstance(void) { return *this; }
uint32_t GetId(void) { return GetInstance().GetId(); }