mirror of
https://github.com/espressif/openthread.git
synced 2026-09-18 07:00:08 +00:00
[routing-manager] deprecate OMR/on-mesh prefixes when removed from netdata (#9599)
This commit adds `RioAdvertiser` component to `RoutingManager`, which manages the list of prefixes advertised as RIO in emitted RA messages by BR. The RIO prefixes are discovered from on-mesh prefixes in Thread Network Data, including OMR prefixes from `OmrPrefixManager` and other prefixes. Existing code for maintaining the list, appending RIOs, and determining/setting the RIO preference is moved to the `RioAdvertiser` class. The `RioAdvertiser` adds a new mechanism to deprecate prefixes removed from Network Data such that any removed prefix is still advertised as RIO in emitted RA messages up to a deprecation interval of 300 seconds (using a shorter route lifetime in RIO). This mechanism ensures that when an OMR prefix is withdrawn, traffic can still be routed during deprecation time from AIL to Thread devices using the old OMR address. This commit also updates `test_routing_manager` to validate the new behavior.
This commit is contained in:
@@ -58,6 +58,9 @@ static const char kInfraIfAddress[] = "fe80::1";
|
||||
static constexpr uint32_t kValidLitime = 2000;
|
||||
static constexpr uint32_t kPreferredLifetime = 1800;
|
||||
|
||||
static constexpr uint32_t kRioValidLifetime = 1800;
|
||||
static constexpr uint32_t kRioDeprecatingLifetime = 300;
|
||||
|
||||
static constexpr uint16_t kMaxRaSize = 800;
|
||||
static constexpr uint16_t kMaxDeprecatingPrefixes = 16;
|
||||
|
||||
@@ -1382,6 +1385,8 @@ void TestOmrSelection(void)
|
||||
VerifyOrQuit(sRsEmitted);
|
||||
VerifyOrQuit(sRaValidated);
|
||||
VerifyOrQuit(sExpectedRios.SawAll());
|
||||
VerifyOrQuit(sExpectedRios[0].mLifetime == kRioValidLifetime);
|
||||
|
||||
Log("Received RA was validated");
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -1409,17 +1414,20 @@ void TestOmrSelection(void)
|
||||
AdvanceTime(100);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Make sure BR emits RA with new OMR prefix now.
|
||||
// Make sure BR emits RA with the new OMR prefix now, and deprecates the old OMR prefix.
|
||||
|
||||
sRaValidated = false;
|
||||
sExpectedPio = kPioAdvertisingLocalOnLink;
|
||||
sExpectedRios.Clear();
|
||||
sExpectedRios.Add(omrPrefix);
|
||||
sExpectedRios.Add(localOmr);
|
||||
|
||||
AdvanceTime(20000);
|
||||
|
||||
VerifyOrQuit(sRaValidated);
|
||||
VerifyOrQuit(sExpectedRios.SawAll());
|
||||
VerifyOrQuit(sExpectedRios[0].mLifetime == kRioValidLifetime);
|
||||
VerifyOrQuit(sExpectedRios[1].mLifetime <= kRioDeprecatingLifetime);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Check Network Data. We should now see that the local OMR prefix
|
||||
@@ -1437,16 +1445,20 @@ void TestOmrSelection(void)
|
||||
AdvanceTime(100);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Make sure BR emits RA with local OMR prefix again.
|
||||
// Make sure BR emits RA with local OMR prefix again and start
|
||||
// deprecating the previously added OMR prefix.
|
||||
|
||||
sRaValidated = false;
|
||||
sExpectedRios.Clear();
|
||||
sExpectedRios.Add(omrPrefix);
|
||||
sExpectedRios.Add(localOmr);
|
||||
|
||||
AdvanceTime(20000);
|
||||
|
||||
VerifyOrQuit(sRaValidated);
|
||||
VerifyOrQuit(sExpectedRios.SawAll());
|
||||
VerifyOrQuit(sExpectedRios[0].mLifetime <= kRioDeprecatingLifetime);
|
||||
VerifyOrQuit(sExpectedRios[1].mLifetime == kRioValidLifetime);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Check Network Data. We should see that the local OMR prefix is
|
||||
@@ -1455,6 +1467,21 @@ void TestOmrSelection(void)
|
||||
VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false);
|
||||
VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Wait enough for old deprecating OMR prefix deprecating to expire.
|
||||
|
||||
sRaValidated = false;
|
||||
sExpectedRios.Clear();
|
||||
sExpectedRios.Add(omrPrefix);
|
||||
sExpectedRios.Add(localOmr);
|
||||
|
||||
AdvanceTime(310000);
|
||||
|
||||
VerifyOrQuit(sRaValidated);
|
||||
VerifyOrQuit(sExpectedRios.SawAll());
|
||||
VerifyOrQuit(sExpectedRios[0].mLifetime == 0);
|
||||
VerifyOrQuit(sExpectedRios[1].mLifetime == kRioValidLifetime);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
|
||||
@@ -2023,7 +2050,10 @@ void TestDomainPrefixAsOmr(void)
|
||||
|
||||
VerifyOrQuit(sExpectedRios[1].mPrefix == localOmr);
|
||||
VerifyOrQuit(sExpectedRios[1].mSawInRa);
|
||||
VerifyOrQuit(sExpectedRios[1].mLifetime == 0);
|
||||
VerifyOrQuit(sExpectedRios[1].mLifetime <= kRioDeprecatingLifetime);
|
||||
|
||||
// Wait long enough for deprecating RIO prefix to expire
|
||||
AdvanceTime(3200000);
|
||||
|
||||
sRaValidated = false;
|
||||
sExpectedPio = kPioAdvertisingLocalOnLink;
|
||||
|
||||
Reference in New Issue
Block a user