Skip to content

Commit

Permalink
[mpl] remove mpl entry from forwarding queue if the address query mat…
Browse files Browse the repository at this point in the history
…ches the host or one of its children
  • Loading branch information
sarveshkumarv3 committed Apr 5, 2024
1 parent 65bc830 commit 16d541a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/net/ip6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ class Ip6 : public InstanceLocator, private NonCopyable
*/
void ResetBorderRoutingCounters(void) { ClearAllBytes(mBorderRoutingCounters); }
#endif
/**
* Removes matching MPL entry.
*
*/
bool RemoveMplEntry(Message &aMessage) { return mMpl.RemoveMatchedMessage(aMessage); }

private:
static constexpr uint8_t kDefaultHopLimit = OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT;
Expand Down
21 changes: 21 additions & 0 deletions src/core/net/ip6_mpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,27 @@ uint8_t Mpl::DetermineMaxRetransmissions(void) const
return maxRetx;
}

bool Mpl::RemoveMatchedMessage(Message &aMessage)
{
bool match = false;
uint16_t len = aMessage.GetLength();
VerifyOrExit(len > 0);
for (Message &message : mBufferedMessageSet)
{
if (message.GetLength() - sizeof(Metadata) >= len)
{
if (aMessage.CompareBytes(0, message, message.GetLength() - sizeof(Metadata) - len, len))
{
mBufferedMessageSet.DequeueAndFree(message);
match = true;
break;
}
}
}
exit:
return match;
}

void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence)
{
Error error = kErrorNone;
Expand Down
7 changes: 7 additions & 0 deletions src/core/net/ip6_mpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ class Mpl : public InstanceLocator, private NonCopyable
*/
const MessageQueue &GetBufferedMessageSet(void) const { return mBufferedMessageSet; }
#endif
/**
* Compare with the MPL messages in the buffered set and remove the first matched entry
*
* @retval true Successfully found and removed
* @retval false Failed to find
*/
bool RemoveMatchedMessage(Message &aMessage);

private:
static constexpr uint16_t kNumSeedEntries = OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES;
Expand Down
2 changes: 2 additions & 0 deletions src/core/thread/address_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ void AddressResolver::HandleTmf<kUriAddressQuery>(Coap::Message &aMessage, const
{
SendAddressQueryResponse(target, Get<Mle::MleRouter>().GetMeshLocal64().GetIid(), nullptr,
aMessageInfo.GetPeerAddr());
Get<Ip6::Ip6>().RemoveMplEntry(aMessage);
ExitNow();
}

Expand All @@ -872,6 +873,7 @@ void AddressResolver::HandleTmf<kUriAddressQuery>(Coap::Message &aMessage, const
{
lastTransactionTime = Time::MsecToSec(TimerMilli::GetNow() - child.GetLastHeard());
SendAddressQueryResponse(target, child.GetMeshLocalIid(), &lastTransactionTime, aMessageInfo.GetPeerAddr());
Get<Ip6::Ip6>().RemoveMplEntry(aMessage);
ExitNow();
}
}
Expand Down

0 comments on commit 16d541a

Please sign in to comment.