[child] update MLR masks when removing registered IPv6 addresses (#10425)

This commit modifies `Child::RemoveIp6Address()` to update the
`mMlrToRegisterMask` and `mMlrToUnregisterMask` when a registered
child IPv6 address entry is removed from the list. These bit-vector
masks track the MLR state associated with the entry using its index
in the array. Since `Array::Remove()` replaces the deleted entry with
the last one in the array, the MLR masks are also updated to reflect
this change.
This commit is contained in:
Abtin Keshavarzian
2024-06-25 16:08:16 -04:00
committed by GitHub
parent ec69ad31f9
commit 7b779a3db1
+17
View File
@@ -203,6 +203,23 @@ Error Child::RemoveIp6Address(const Ip6::Address &aAddress)
entry = mIp6Addresses.Find(aAddress);
VerifyOrExit(entry != nullptr);
#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
{
// `Array::Remove()` will replace the removed entry with the
// last one in the array. We also update the MLR bit vectors
// to reflect this change.
uint16_t entryIndex = mIp6Addresses.IndexOf(*entry);
uint16_t lastIndex = mIp6Addresses.GetLength() - 1;
mMlrToRegisterMask.Set(entryIndex, mMlrToRegisterMask.Get(lastIndex));
mMlrToRegisterMask.Set(lastIndex, false);
mMlrRegisteredMask.Set(entryIndex, mMlrRegisteredMask.Get(lastIndex));
mMlrRegisteredMask.Set(lastIndex, false);
}
#endif
mIp6Addresses.Remove(*entry);
error = kErrorNone;