[mle] limit number of child-router links a REED / FED maintains (#3358)

This commit is contained in:
Jonathan Hui
2018-12-13 10:44:30 -08:00
parent ce7b65e117
commit ff0b30db55
4 changed files with 42 additions and 1 deletions
+10
View File
@@ -1662,6 +1662,16 @@
#define OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN 10
#endif
/**
* @def OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS
*
* Specifies the desired number of router links that a REED / FED attempts to maintain.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS
#define OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS 3
#endif
/**
* @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
*
+2 -1
View File
@@ -1352,7 +1352,8 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
}
}
else if (IsFullThreadDevice() && (router->GetState() != Neighbor::kStateValid) &&
(router->GetState() != Neighbor::kStateLinkRequest))
(router->GetState() != Neighbor::kStateLinkRequest) &&
(mRouterTable.GetActiveLinkCount() < OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS))
{
router->SetExtAddress(macAddr);
router->GetLinkInfo().Clear();
+22
View File
@@ -335,6 +335,28 @@ void RouterTable::RemoveNeighbor(Router &aRouter)
}
}
uint8_t RouterTable::GetActiveLinkCount(void) const
{
uint8_t activeLinks = 0;
for (int i = 0; i < Mle::kMaxRouters; i++)
{
const Router &cur = mRouters[i];
if (cur.GetRloc16() == 0xffff)
{
break;
}
if (cur.GetState() == Neighbor::kStateValid)
{
activeLinks++;
}
}
return activeLinks;
}
Router *RouterTable::GetNeighbor(uint16_t aRloc16)
{
Router *router = NULL;
+8
View File
@@ -176,6 +176,14 @@ public:
*/
uint8_t GetActiveRouterCount(void) const { return mActiveRouterCount; }
/**
* This method returns the number of active links with neighboring routers.
*
* @returns The number of active links with neighboring routers.
*
*/
uint8_t GetActiveLinkCount(void) const;
/**
* This method returns the leader in the Thread network.
*