[border-routing] add configuration for Vicarious Router Solicitation (#7248)

This commit adds
`OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE` configuration
to allow disabling Vicarious Router Solicitation feature.
This commit is contained in:
Simon Lin
2021-12-23 12:26:04 -08:00
committed by GitHub
parent bd64f29bbd
commit b7c40afb66
3 changed files with 24 additions and 0 deletions
@@ -69,7 +69,9 @@ RoutingManager::RoutingManager(Instance &aInstance)
, mDiscoveredPrefixStaleTimer(aInstance, HandleDiscoveredPrefixStaleTimer)
, mRouterAdvertisementTimer(aInstance, HandleRouterAdvertisementTimer)
, mRouterAdvertisementCount(0)
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
, mVicariousRouterSolicitTimer(aInstance, HandleVicariousRouterSolicitTimer)
#endif
, mRouterSolicitTimer(aInstance, HandleRouterSolicitTimer)
, mRouterSolicitCount(0)
, mRoutingPolicyTimer(aInstance, HandleRoutingPolicyTimer)
@@ -246,7 +248,9 @@ void RoutingManager::Stop(void)
mRouterAdvertisementTimer.Stop();
mRouterAdvertisementCount = 0;
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
mVicariousRouterSolicitTimer.Stop();
#endif
mRouterSolicitTimer.Stop();
mRouterSolicitCount = 0;
@@ -640,7 +644,9 @@ void RoutingManager::StartRouterSolicitationDelay(void)
OT_ASSERT(mRouterSolicitCount == 0);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
mVicariousRouterSolicitTimer.Stop();
#endif
static_assert(kMaxRtrSolicitationDelay > 0, "invalid maximum Router Solicitation delay");
randomDelay = Random::NonCrypto::GetUint32InRange(0, Time::SecToMsec(kMaxRtrSolicitationDelay));
@@ -824,6 +830,7 @@ void RoutingManager::HandleRouterAdvertisementTimer(void)
EvaluateRoutingPolicy();
}
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
void RoutingManager::HandleVicariousRouterSolicitTimer(Timer &aTimer)
{
aTimer.Get<RoutingManager>().HandleVicariousRouterSolicitTimer();
@@ -842,6 +849,7 @@ void RoutingManager::HandleVicariousRouterSolicitTimer(void)
}
}
}
#endif
void RoutingManager::HandleRouterSolicitTimer(Timer &aTimer)
{
@@ -952,11 +960,13 @@ void RoutingManager::HandleRouterSolicit(const Ip6::Address &aSrcAddress,
otLogInfoBr("Received Router Solicitation from %s on interface %u", aSrcAddress.ToString().AsCString(),
mInfraIfIndex);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
if (!mVicariousRouterSolicitTimer.IsRunning())
{
mTimeVicariousRouterSolicitStart = TimerMilli::GetNow();
mVicariousRouterSolicitTimer.Start(Time::SecToMsec(kVicariousSolicitationTime));
}
#endif
// Schedule Router Advertisements with random delay.
randomDelay = Random::NonCrypto::GetUint32InRange(0, kMaxRaDelayTime);
@@ -292,8 +292,10 @@ private:
static void HandleRouterAdvertisementTimer(Timer &aTimer);
void HandleRouterAdvertisementTimer(void);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
static void HandleVicariousRouterSolicitTimer(Timer &aTimer);
void HandleVicariousRouterSolicitTimer(void);
#endif
static void HandleRouterSolicitTimer(Timer &aTimer);
void HandleRouterSolicitTimer(void);
static void HandleDiscoveredPrefixInvalidTimer(Timer &aTimer);
@@ -375,8 +377,10 @@ private:
TimerMilli mRouterAdvertisementTimer;
uint32_t mRouterAdvertisementCount;
#if OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
TimerMilli mVicariousRouterSolicitTimer;
TimeMilli mTimeVicariousRouterSolicitStart;
#endif
TimerMilli mRouterSolicitTimer;
TimeMilli mTimeRouterSolicitStart;
uint8_t mRouterSolicitCount;
+10
View File
@@ -65,6 +65,16 @@
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
*
* Define to 1 to enable Border Routing Vicarious Router Solicitation.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE
#define OPENTHREAD_CONFIG_BORDER_ROUTING_VICARIOUS_RS_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_AGENT_UDP_PORT
*