[routing-manager] new config to use heap for PrefixTable entries (#9455)

This commit introduces a new configuration option for the routing
manager to use heap-allocated entries in the `DiscoveredPrefixTable`,
which maintains a list of discovered routers and their advertised
on-link prefixes. This makes the implementation more flexible when
dealing with a large number of routers and/or discovered prefix
entries.

The config option `OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE`
enables this behavior. By default, it is enabled. When disabled, the
previous model, which uses pre-allocated arrays and pools, is used
instead.

This commit also updates the unit test `test_routing_manager` to track
heap allocations and validate that all heap allocations by the
routing manager are freed when it is stopped.
This commit is contained in:
Abtin Keshavarzian
2023-09-29 14:58:48 -07:00
committed by GitHub
parent bd63637696
commit eaa62613a5
4 changed files with 177 additions and 25 deletions
+28 -16
View File
@@ -1183,7 +1183,7 @@ void RoutingManager::DiscoveredPrefixTable::ProcessRouterAdvertMessage(const Ip6
if (router == nullptr)
{
router = mRouters.PushBack();
router = AllocateRouter();
if (router == nullptr)
{
@@ -1193,6 +1193,8 @@ void RoutingManager::DiscoveredPrefixTable::ProcessRouterAdvertMessage(const Ip6
router->Clear();
router->mAddress = aSrcAddress;
mRouters.Push(*router);
}
// RA message can indicate router provides default route in the RA
@@ -1471,13 +1473,12 @@ void RoutingManager::DiscoveredPrefixTable::RemoveAllEntries(void)
for (Router &router : mRouters)
{
Entry *entry;
while ((entry = router.mEntries.Pop()) != nullptr)
if (!router.mEntries.IsEmpty())
{
FreeEntry(*entry);
SignalTableChanged();
}
FreeEntries(router.mEntries);
}
RemoveRoutersWithNoEntries();
@@ -1579,13 +1580,27 @@ TimeMilli RoutingManager::DiscoveredPrefixTable::CalculateNextStaleTime(TimeMill
void RoutingManager::DiscoveredPrefixTable::RemoveRoutersWithNoEntries(void)
{
mRouters.RemoveAllMatching(Router::kContainsNoEntries);
LinkedList<Router> routersToFree;
mRouters.RemoveAllMatching(Router::kContainsNoEntries, routersToFree);
FreeRouters(routersToFree);
}
void RoutingManager::DiscoveredPrefixTable::FreeRouters(LinkedList<Router> &aRouters)
{
// Frees all routers in the given list `aRouters`
Router *router;
while ((router = aRouters.Pop()) != nullptr)
{
FreeRouter(*router);
}
}
void RoutingManager::DiscoveredPrefixTable::FreeEntries(LinkedList<Entry> &aEntries)
{
// Frees all entries in the given list `aEntries` (put them back
// in the entry pool).
// Frees all entries in the given list `aEntries`.
Entry *entry;
@@ -1768,8 +1783,8 @@ void RoutingManager::DiscoveredPrefixTable::InitIterator(PrefixTableIterator &aI
Iterator &iterator = static_cast<Iterator &>(aIterator);
iterator.SetInitTime();
iterator.SetRouter(mRouters.Front());
iterator.SetEntry(mRouters.IsEmpty() ? nullptr : mRouters[0].mEntries.GetHead());
iterator.SetRouter(mRouters.GetHead());
iterator.SetEntry(mRouters.IsEmpty() ? nullptr : mRouters.GetHead()->mEntries.GetHead());
}
Error RoutingManager::DiscoveredPrefixTable::GetNextEntry(PrefixTableIterator &aIterator,
@@ -1795,15 +1810,12 @@ Error RoutingManager::DiscoveredPrefixTable::GetNextEntry(PrefixTableIterator &a
if (iterator.GetEntry() == nullptr)
{
if (iterator.GetRouter() != mRouters.Back())
iterator.SetRouter(iterator.GetRouter()->GetNext());
if (iterator.GetRouter() != nullptr)
{
iterator.SetRouter(iterator.GetRouter() + 1);
iterator.SetEntry(iterator.GetRouter()->mEntries.GetHead());
}
else
{
iterator.SetRouter(nullptr);
}
}
exit:
+35 -9
View File
@@ -53,6 +53,7 @@
#include "border_router/infra_if.hpp"
#include "common/array.hpp"
#include "common/error.hpp"
#include "common/heap_allocatable.hpp"
#include "common/linked_list.hpp"
#include "common/locator.hpp"
#include "common/message.hpp"
@@ -624,10 +625,17 @@ private:
void HandleRouterTimer(void);
private:
#if !OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
static constexpr uint16_t kMaxRouters = OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_ROUTERS;
static constexpr uint16_t kMaxEntries = OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_PREFIXES;
#endif
class Entry : public LinkedListEntry<Entry>, public Unequatable<Entry>, private Clearable<Entry>
class Entry : public LinkedListEntry<Entry>,
public Unequatable<Entry>,
#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
public Heap::Allocatable<Entry>,
#endif
private Clearable<Entry>
{
friend class LinkedListEntry<Entry>;
friend class Clearable<Entry>;
@@ -725,7 +733,11 @@ private:
} mShared;
};
struct Router : public Clearable<Router>
struct Router : public LinkedListEntry<Router>,
#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
public Heap::Allocatable<Router>,
#endif
public Clearable<Router>
{
// The timeout (in msec) for router staying in active state
// before starting the Neighbor Solicitation (NS) probes.
@@ -746,6 +758,7 @@ private:
bool Matches(const Ip6::Address &aAddress) const { return aAddress == mAddress; }
bool Matches(EmptyChecker) const { return mEntries.IsEmpty(); }
Router *mNext;
Ip6::Address mAddress;
LinkedList<Entry> mEntries;
TimeMilli mTimeout;
@@ -774,8 +787,7 @@ private:
void RemovePrefix(const Entry::Matcher &aMatcher);
void RemoveOrDeprecateEntriesFromInactiveRouters(void);
void RemoveRoutersWithNoEntries(void);
Entry *AllocateEntry(void) { return mEntryPool.Allocate(); }
void FreeEntry(Entry &aEntry) { mEntryPool.Free(aEntry); }
void FreeRouters(LinkedList<Router> &aRouters);
void FreeEntries(LinkedList<Entry> &aEntries);
void UpdateNetworkDataOnChangeTo(Entry &aEntry);
const Entry *FindFavoredEntryToPublish(const Ip6::Prefix &aPrefix) const;
@@ -783,16 +795,30 @@ private:
void SignalTableChanged(void);
void UpdateRouterOnRx(Router &aRouter);
void SendNeighborSolicitToRouter(const Router &aRouter);
#if OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
Router *AllocateRouter(void) { return Router::Allocate(); }
Entry *AllocateEntry(void) { return Entry::Allocate(); }
void FreeRouter(Router &aRouter) { aRouter.Free(); }
void FreeEntry(Entry &aEntry) { aEntry.Free(); }
#else
Router *AllocateRouter(void) { return mRouterPool.Allocate(); }
Entry *AllocateEntry(void) { return mEntryPool.Allocate(); }
void FreeRouter(Router &aRouter) { mRouterPool.Free(aRouter); }
void FreeEntry(Entry &aEntry) { mEntryPool.Free(aEntry); }
#endif
using SignalTask = TaskletIn<RoutingManager, &RoutingManager::HandleDiscoveredPrefixTableChanged>;
using EntryTimer = TimerMilliIn<RoutingManager, &RoutingManager::HandleDiscoveredPrefixTableEntryTimer>;
using RouterTimer = TimerMilliIn<RoutingManager, &RoutingManager::HandleDiscoveredPrefixTableRouterTimer>;
Array<Router, kMaxRouters> mRouters;
Pool<Entry, kMaxEntries> mEntryPool;
EntryTimer mEntryTimer;
RouterTimer mRouterTimer;
SignalTask mSignalTask;
LinkedList<Router> mRouters;
EntryTimer mEntryTimer;
RouterTimer mRouterTimer;
SignalTask mSignalTask;
#if !OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
Pool<Entry, kMaxEntries> mEntryPool;
Pool<Router, kMaxRouters> mRouterPool;
#endif
};
class OmrPrefixManager;
+22
View File
@@ -45,11 +45,30 @@
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
*
* Define to 1 to allow using heap by Routing Manager.
*
* When enabled heap allocated entries will be used to track discovered prefix table contain information about
* discovered routers and the advertised on-link prefixes on infra link.
*
* When disabled pre-allocated pools are used instead where max number of entries are specified by
* `OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_ROUTERS` and `MAX_DISCOVERED_PREFIXES` configurations.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE
#define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_ROUTERS
*
* Specifies maximum number of routers (on infra link) to track by routing manager.
*
* Applicable only when heap allocation is not used, i.e., `OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE` is
* disabled.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_ROUTERS
#define OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_ROUTERS 16
@@ -60,6 +79,9 @@
*
* Specifies maximum number of discovered prefixes (on-link prefixes on the infra link) maintained by routing manager.
*
* Applicable only when heap allocation is not used, i.e., `OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE` is
* disabled.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_PREFIXES
#define OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_DISCOVERED_PREFIXES 64
+92
View File
@@ -476,6 +476,37 @@ exit:
return;
}
//----------------------------------------------------------------------------------------------------------------------
Array<void *, 500> sHeapAllocatedPtrs;
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
void *ptr = calloc(aNum, aSize);
SuccessOrQuit(sHeapAllocatedPtrs.PushBack(ptr));
return ptr;
}
void otPlatFree(void *aPtr)
{
if (aPtr != nullptr)
{
void **entry = sHeapAllocatedPtrs.Find(aPtr);
VerifyOrQuit(entry != nullptr, "A heap allocated item is freed twice");
sHeapAllocatedPtrs.Remove(*entry);
}
free(aPtr);
}
#endif
//----------------------------------------------------------------------------------------------------------------------
void LogRouterAdvert(const Icmp6Packet &aPacket)
{
Ip6::Nd::RouterAdvertMessage raMsg(aPacket);
@@ -1014,6 +1045,7 @@ void TestSamePrefixesFromMultipleRouters(void)
Ip6::Prefix routePrefix = PrefixFromString("2000:1234:5678::", 64);
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
Ip6::Address routerAddressB = AddressFromString("fd00::bbbb");
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestSamePrefixesFromMultipleRouters");
@@ -1028,6 +1060,7 @@ void TestSamePrefixesFromMultipleRouters(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1135,6 +1168,9 @@ void TestSamePrefixesFromMultipleRouters(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations == sHeapAllocatedPtrs.GetLength());
Log("End of TestSamePrefixesFromMultipleRouters");
FinalizeTest();
@@ -1146,6 +1182,7 @@ void TestOmrSelection(void)
Ip6::Prefix localOmr;
Ip6::Prefix omrPrefix = PrefixFromString("2000:0000:1111:4444::", 64);
NetworkData::OnMeshPrefixConfig prefixConfig;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestOmrSelection");
@@ -1160,6 +1197,7 @@ void TestOmrSelection(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1250,6 +1288,9 @@ void TestOmrSelection(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestOmrSelection");
FinalizeTest();
}
@@ -1262,6 +1303,7 @@ void TestDefaultRoute(void)
Ip6::Prefix defaultRoute = PrefixFromString("::", 0);
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
NetworkData::OnMeshPrefixConfig prefixConfig;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestDefaultRoute");
@@ -1276,6 +1318,7 @@ void TestDefaultRoute(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1410,6 +1453,9 @@ void TestDefaultRoute(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestDefaultRoute");
FinalizeTest();
@@ -1423,6 +1469,7 @@ void TestAdvNonUlaRoute(void)
Ip6::Prefix routePrefix = PrefixFromString("2000:1234:5678::", 64);
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
NetworkData::OnMeshPrefixConfig prefixConfig;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestAdvNonUlaRoute");
@@ -1437,6 +1484,7 @@ void TestAdvNonUlaRoute(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1571,6 +1619,9 @@ void TestAdvNonUlaRoute(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestAdvNonUlaRoute");
FinalizeTest();
@@ -1585,6 +1636,7 @@ void TestLocalOnLinkPrefixDeprecation(void)
Ip6::Prefix onLinkPrefix = PrefixFromString("fd00:abba:baba::", 64);
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
uint32_t localOnLinkLifetime;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestLocalOnLinkPrefixDeprecation");
@@ -1594,6 +1646,7 @@ void TestLocalOnLinkPrefixDeprecation(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Start Routing Manager. Check emitted RS and RA messages.
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1705,6 +1758,9 @@ void TestLocalOnLinkPrefixDeprecation(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestLocalOnLinkPrefixDeprecation");
FinalizeTest();
@@ -1717,6 +1773,7 @@ void TestDomainPrefixAsOmr(void)
Ip6::Prefix localOmr;
Ip6::Prefix domainPrefix = PrefixFromString("2000:0000:1111:4444::", 64);
NetworkData::OnMeshPrefixConfig prefixConfig;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestDomainPrefixAsOmr");
@@ -1731,6 +1788,7 @@ void TestDomainPrefixAsOmr(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -1852,6 +1910,9 @@ void TestDomainPrefixAsOmr(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestDomainPrefixAsOmr");
FinalizeTest();
}
@@ -1875,6 +1936,7 @@ void TestExtPanIdChange(void)
uint32_t oldPrefixLifetime;
Ip6::Prefix oldPrefixes[4];
otOperationalDataset dataset;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestExtPanIdChange");
@@ -1884,6 +1946,7 @@ void TestExtPanIdChange(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Start Routing Manager. Check emitted RS and RA messages.
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -2356,6 +2419,9 @@ void TestExtPanIdChange(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestExtPanIdChange");
FinalizeTest();
}
@@ -2368,6 +2434,7 @@ void TestRouterNsProbe(void)
Ip6::Prefix routePrefix = PrefixFromString("2000:1234:5678::", 64);
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
Ip6::Address routerAddressB = AddressFromString("fd00::bbbb");
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestRouterNsProbe");
@@ -2382,6 +2449,7 @@ void TestRouterNsProbe(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -2504,6 +2572,9 @@ void TestRouterNsProbe(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestRouterNsProbe");
FinalizeTest();
}
@@ -2519,6 +2590,7 @@ void TestConflictingPrefix(void)
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
Ip6::Address routerAddressB = AddressFromString("fd00::bbbb");
otOperationalDataset dataset;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestConflictingPrefix");
@@ -2533,6 +2605,7 @@ void TestConflictingPrefix(void)
sExpectedPio = kPioAdvertisingLocalOnLink;
sExpectedRios.Clear();
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOnLinkPrefix(localOnLink));
@@ -2718,6 +2791,9 @@ void TestConflictingPrefix(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(heapAllocations = sHeapAllocatedPtrs.GetLength());
Log("End of TestConflictingPrefix");
FinalizeTest();
@@ -2945,12 +3021,15 @@ void TestAutoEnableOfSrpServer(void)
Ip6::Prefix localOmr;
Ip6::Address routerAddressA = AddressFromString("fd00::aaaa");
Ip6::Prefix onLinkPrefix = PrefixFromString("2000:abba:baba::", 64);
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestAutoEnableOfSrpServer");
InitTest();
heapAllocations = sHeapAllocatedPtrs.GetLength();
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Check SRP Server state and enable auto-enable mode
@@ -3140,6 +3219,8 @@ void TestAutoEnableOfSrpServer(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VerifyOrQuit(sHeapAllocatedPtrs.GetLength() == heapAllocations);
Log("End of TestAutoEnableOfSrpServer");
FinalizeTest();
}
@@ -3153,6 +3234,7 @@ void TestNat64PrefixSelection(void)
Ip6::Prefix localOmr;
Ip6::Prefix omrPrefix = PrefixFromString("2000:0000:1111:4444::", 64);
NetworkData::OnMeshPrefixConfig prefixConfig;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestNat64PrefixSelection");
@@ -3162,6 +3244,7 @@ void TestNat64PrefixSelection(void)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Start Routing Manager. Check local NAT64 prefix generation.
heapAllocations = sHeapAllocatedPtrs.GetLength();
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(true));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetNat64Prefix(localNat64));
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().GetOmrPrefix(localOmr));
@@ -3222,6 +3305,9 @@ void TestNat64PrefixSelection(void)
VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ false);
VerifyNat64PrefixInNetData(localNat64);
SuccessOrQuit(sInstance->Get<BorderRouter::RoutingManager>().SetEnabled(false));
VerifyOrQuit(sHeapAllocatedPtrs.GetLength() == heapAllocations);
Log("End of TestNat64PrefixSelection");
FinalizeTest();
}
@@ -3246,11 +3332,13 @@ void VerifyNoPdOmrPrefix()
void TestBorderRoutingProcessPlatfromGeneratedNd(void)
{
Ip6::Prefix localOmr;
uint16_t heapAllocations;
Log("--------------------------------------------------------------------------------------------");
Log("TestBorderRoutingProcessPlatfromGeneratedNd");
InitTest(/* aEnableBorderRouting */ true);
heapAllocations = sHeapAllocatedPtrs.GetLength();
otBorderRoutingDhcp6PdSetEnabled(sInstance, true);
@@ -3433,6 +3521,10 @@ void TestBorderRoutingProcessPlatfromGeneratedNd(void)
VerifyNoPdOmrPrefix();
VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false);
}
SuccessOrQuit(otBorderRoutingSetEnabled(sInstance, false));
VerifyOrQuit(sHeapAllocatedPtrs.GetLength() == heapAllocations);
Log("End of TestBorderRoutingProcessPlatfromGeneratedNd");
}
#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE