From c98164f9339711cd34c663978ec56c2eb9adc6a0 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 7 Mar 2018 20:12:55 +0000 Subject: [PATCH] [mle] skip IPv6 address registration entries with no matching context (#2604) --- src/core/thread/mle_router.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 62c9b9b5e..6945b8fa2 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -2091,11 +2091,17 @@ otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffse VerifyOrExit(aMessage.Read(offset, len, &entry) == len, error = OT_ERROR_PARSE); offset += len; + registeredCount++; if (entry.IsCompressed()) { - // xxx check if context id exists - GetNetif().GetNetworkDataLeader().GetContext(entry.GetContextId(), context); + if (GetNetif().GetNetworkDataLeader().GetContext(entry.GetContextId(), context) != OT_ERROR_NONE) + { + otLogWarnMle(GetInstance(), "Failed to get context %d for compressed address from child 0x%04x", + entry.GetContextId(), aChild.GetRloc16()); + continue; + } + memcpy(&address, context.mPrefix, BitVectorBytes(context.mPrefixLength)); address.SetIid(entry.GetIid()); } @@ -2104,8 +2110,6 @@ otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffse address = *entry.GetIp6Address(); } - registeredCount++; - // We try to accept/add as many IPv6 addresses as possible. // "Child ID/Update Response" will indicate the accepted // addresses.