[mle-router] check for repeating child entries when restoring children (#2170)

This commit adds additional check in `MleRouter::RestoreChildren()`
method for repeating/duplicate child entries (child entries with
same extended address) when restoring child table from non-volatile
memory. If there are more than one entry, the last one will be used.
This commit is contained in:
Abtin Keshavarzian
2017-09-06 09:51:30 -07:00
committed by Jonathan Hui
parent cbc883b932
commit 0e0ea33ef6
+7 -1
View File
@@ -3519,7 +3519,13 @@ otError MleRouter::RestoreChildren(void)
reinterpret_cast<uint8_t *>(&childInfo), &length));
VerifyOrExit(length >= sizeof(childInfo), error = OT_ERROR_PARSE);
VerifyOrExit((child = NewChild()) != NULL, error = OT_ERROR_NO_BUFS);
child = FindChild(*static_cast<Mac::ExtAddress *>(&childInfo.mExtAddress));
if (child == NULL)
{
VerifyOrExit((child = NewChild()) != NULL, error = OT_ERROR_NO_BUFS);
}
memset(child, 0, sizeof(*child));
child->SetExtAddress(*static_cast<Mac::ExtAddress *>(&childInfo.mExtAddress));