[routing-manager] advertise deprecating RIO prefixes with low preference (#10625)

This commit updates `RoutingManager::RioAdvertiser` to advertise
deprecating prefixes with `NetworkData::kkRoutePreferenceLow`.
`test_routing_manager` is updated to validate this new behavior.
This commit is contained in:
Abtin Keshavarzian
2024-08-21 19:30:56 -07:00
committed by GitHub
parent 697adfd112
commit e90792da0b
3 changed files with 36 additions and 16 deletions
+15 -8
View File
@@ -3086,7 +3086,9 @@ Error RoutingManager::RioAdvertiser::InvalidatPrevRios(RouterAdvert::TxMessage &
for (const RioPrefix &prefix : mPrefixes)
{
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0, aRaMessage));
RoutePreference preference = prefix.mIsDeprecating ? NetworkData::kRoutePreferenceLow : mPreference;
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0, preference, aRaMessage));
}
#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
@@ -3188,7 +3190,8 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
{
if (nextTime.GetNow() >= prefix.mExpirationTime)
{
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0, aRaMessage));
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0,
NetworkData::kRoutePreferenceLow, aRaMessage));
continue;
}
}
@@ -3201,7 +3204,8 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
if (mPrefixes.PushBack(prefix) != kErrorNone)
{
LogWarn("Too many deprecating on-mesh prefixes, removing %s", prefix.mPrefix.ToString().AsCString());
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0, aRaMessage));
SuccessOrExit(error = AppendRio(prefix.mPrefix, /* aRouteLifetime */ 0, NetworkData::kRoutePreferenceLow,
aRaMessage));
}
nextTime.UpdateIfEarlier(prefix.mExpirationTime);
@@ -3211,14 +3215,16 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
for (const RioPrefix &prefix : mPrefixes)
{
uint32_t lifetime = kDefaultOmrPrefixLifetime;
uint32_t lifetime = kDefaultOmrPrefixLifetime;
RoutePreference preference = mPreference;
if (prefix.mIsDeprecating)
{
lifetime = TimeMilli::MsecToSec(prefix.mExpirationTime - nextTime.GetNow());
lifetime = TimeMilli::MsecToSec(prefix.mExpirationTime - nextTime.GetNow());
preference = NetworkData::kRoutePreferenceLow;
}
SuccessOrExit(error = AppendRio(prefix.mPrefix, lifetime, aRaMessage));
SuccessOrExit(error = AppendRio(prefix.mPrefix, lifetime, preference, aRaMessage));
}
mTimer.FireAtIfEarlier(nextTime);
@@ -3229,12 +3235,13 @@ exit:
Error RoutingManager::RioAdvertiser::AppendRio(const Ip6::Prefix &aPrefix,
uint32_t aRouteLifetime,
RoutePreference aPreference,
RouterAdvert::TxMessage &aRaMessage)
{
Error error;
SuccessOrExit(error = aRaMessage.AppendRouteInfoOption(aPrefix, aRouteLifetime, mPreference));
LogRouteInfoOption(aPrefix, aRouteLifetime, mPreference);
SuccessOrExit(error = aRaMessage.AppendRouteInfoOption(aPrefix, aRouteLifetime, aPreference));
LogRouteInfoOption(aPrefix, aRouteLifetime, aPreference);
exit:
return error;
+4 -1
View File
@@ -1302,7 +1302,10 @@ private:
void SetPreferenceBasedOnRole(void);
void UpdatePreference(RoutePreference aPreference);
Error AppendRio(const Ip6::Prefix &aPrefix, uint32_t aRouteLifetime, RouterAdvert::TxMessage &aRaMessage);
Error AppendRio(const Ip6::Prefix &aPrefix,
uint32_t aRouteLifetime,
RoutePreference aPreference,
RouterAdvert::TxMessage &aRaMessage);
using RioTimer = TimerMilliIn<RoutingManager, &RoutingManager::HandleRioAdvertiserimer>;
+17 -7
View File
@@ -183,6 +183,8 @@ Array<DeprecatingPrefix, kMaxDeprecatingPrefixes> sDeprecatingPrefixes;
static constexpr uint16_t kMaxRioPrefixes = 10;
using NetworkData::RoutePreference;
struct RioPrefix
{
RioPrefix(void) = default;
@@ -191,12 +193,14 @@ struct RioPrefix
: mSawInRa(false)
, mPrefix(aPrefix)
, mLifetime(0)
, mPreference(NetworkData::kRoutePreferenceMedium)
{
}
bool mSawInRa; // Indicate whether or not this prefix was seen in the emitted RA (as RIO).
Ip6::Prefix mPrefix; // The RIO prefix.
uint32_t mLifetime; // The RIO prefix lifetime - only valid when `mSawInRa`
bool mSawInRa; // Indicate whether or not this prefix was seen in the emitted RA (as RIO).
Ip6::Prefix mPrefix; // The RIO prefix.
uint32_t mLifetime; // The RIO prefix lifetime - only valid when `mSawInRa`
RoutePreference mPreference; // The RIO preference - only valid when `mSawInRa`
};
class ExpectedRios : public Array<RioPrefix, kMaxRioPrefixes>
@@ -531,8 +535,9 @@ void ValidateRouterAdvert(const Icmp6Packet &aPacket)
{
if (prefix == rioPrefix.mPrefix)
{
rioPrefix.mSawInRa = true;
rioPrefix.mLifetime = rio.GetRouteLifetime();
rioPrefix.mSawInRa = true;
rioPrefix.mLifetime = rio.GetRouteLifetime();
rioPrefix.mPreference = rio.GetPreference();
}
}
@@ -741,8 +746,6 @@ void VerifyNoOmrPrefixInNetData(void)
VerifyOrQuit(otNetDataGetNextOnMeshPrefix(sInstance, &iterator, &prefixConfig) != kErrorNone);
}
using NetworkData::RoutePreference;
enum ExternalRouteMode : uint8_t
{
kNoRoute,
@@ -1419,6 +1422,7 @@ void TestOmrSelection(void)
VerifyOrQuit(sRaValidated);
VerifyOrQuit(sExpectedRios.SawAll());
VerifyOrQuit(sExpectedRios[0].mLifetime == kRioValidLifetime);
VerifyOrQuit(sExpectedRios[0].mPreference == NetworkData::kRoutePreferenceMedium);
Log("Received RA was validated");
@@ -1460,7 +1464,9 @@ void TestOmrSelection(void)
VerifyOrQuit(sRaValidated);
VerifyOrQuit(sExpectedRios.SawAll());
VerifyOrQuit(sExpectedRios[0].mLifetime == kRioValidLifetime);
VerifyOrQuit(sExpectedRios[0].mPreference == NetworkData::kRoutePreferenceMedium);
VerifyOrQuit(sExpectedRios[1].mLifetime <= kRioDeprecatingLifetime);
VerifyOrQuit(sExpectedRios[1].mPreference == NetworkData::kRoutePreferenceLow);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Check Network Data. We should now see that the local OMR prefix
@@ -1491,7 +1497,9 @@ void TestOmrSelection(void)
VerifyOrQuit(sRaValidated);
VerifyOrQuit(sExpectedRios.SawAll());
VerifyOrQuit(sExpectedRios[0].mLifetime <= kRioDeprecatingLifetime);
VerifyOrQuit(sExpectedRios[0].mPreference == NetworkData::kRoutePreferenceLow);
VerifyOrQuit(sExpectedRios[1].mLifetime == kRioValidLifetime);
VerifyOrQuit(sExpectedRios[1].mPreference == NetworkData::kRoutePreferenceMedium);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Check Network Data. We should see that the local OMR prefix is
@@ -1514,6 +1522,7 @@ void TestOmrSelection(void)
VerifyOrQuit(sExpectedRios.SawAll());
VerifyOrQuit(sExpectedRios[0].mLifetime == 0);
VerifyOrQuit(sExpectedRios[1].mLifetime == kRioValidLifetime);
VerifyOrQuit(sExpectedRios[0].mPreference == NetworkData::kRoutePreferenceLow);
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -2202,6 +2211,7 @@ void TestDomainPrefixAsOmr(void)
VerifyOrQuit(sExpectedRios[1].mPrefix == localOmr);
VerifyOrQuit(sExpectedRios[1].mSawInRa);
VerifyOrQuit(sExpectedRios[1].mLifetime <= kRioDeprecatingLifetime);
VerifyOrQuit(sExpectedRios[1].mPreference == NetworkData::kRoutePreferenceLow);
// Wait long enough for deprecating RIO prefix to expire
AdvanceTime(3200000);