From f7690fe7e9d638341921808cba6a3e695ec0131e Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 13 Jul 2023 10:19:52 -0700 Subject: [PATCH] [routing-manager] support Advertising PIO (AP) flag in published route (#9274) This commit adds support for the Advertising PIO (AP) flag in Network Data `ExternalRoute` entries. It also updates the `RoutingManager` class to set the AP flag on its published Network Data route when the local on-link prefix is included as PIO in emitted RA messages, which is equivalent to when the local on-link prefix is being published, advertised, or deprecated. This commit also updates the `test_routing_manager` unit test to validate the AP flag in the published route under different scenarios. --- include/openthread/instance.h | 2 +- include/openthread/netdata.h | 1 + src/cli/README.md | 3 +- src/cli/README_NETDATA.md | 3 + src/cli/cli.cpp | 4 + src/cli/cli_network_data.cpp | 5 + src/core/border_router/routing_manager.cpp | 21 +++- src/core/border_router/routing_manager.hpp | 3 + src/core/thread/network_data_tlvs.hpp | 10 ++ src/core/thread/network_data_types.cpp | 6 + tests/toranj/cli/test-021-br-route-prf.py | 18 +-- tests/unit/test_network_data.cpp | 2 + tests/unit/test_routing_manager.cpp | 131 +++++++++++---------- 13 files changed, 136 insertions(+), 73 deletions(-) diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 3205ad09a..afaa1dae9 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (344) +#define OPENTHREAD_API_VERSION (345) /** * @addtogroup api-instance diff --git a/include/openthread/netdata.h b/include/openthread/netdata.h index ea1791e90..aae61148a 100644 --- a/include/openthread/netdata.h +++ b/include/openthread/netdata.h @@ -94,6 +94,7 @@ typedef struct otExternalRouteConfig bool mNat64 : 1; ///< Whether this is a NAT64 prefix. bool mStable : 1; ///< Whether this configuration is considered Stable Network Data. bool mNextHopIsThisDevice : 1; ///< Whether the next hop is this device (value ignored on config add). + bool mAdvPio : 1; ///< Whether or not BR is advertising a ULA prefix in PIO (AP flag). } otExternalRouteConfig; /** diff --git a/src/cli/README.md b/src/cli/README.md index 1fbb49ff3..99876c8af 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -3020,12 +3020,13 @@ Get the external route list in the local Network Data. Done ``` -### route add \ [sn][prf] +### route add \ [sna][prf] Add a valid external route to the Network Data. - s: Stable flag - n: NAT64 flag +- a: Advertising PIO (AP) flag - prf: Default Router Preference, which may be: 'high', 'med', or 'low'. ```bash diff --git a/src/cli/README_NETDATA.md b/src/cli/README_NETDATA.md index f41f89983..ec828f32b 100644 --- a/src/cli/README_NETDATA.md +++ b/src/cli/README_NETDATA.md @@ -297,6 +297,7 @@ Publish an external route entry. - s: Stable flag - n: NAT64 flag +- a: Advertising PIO (AP) flag - prf: Preference, which may be: 'high', 'med', or 'low'. ```bash @@ -312,6 +313,7 @@ If there is no previously published external route matching old prefix, this com - s: Stable flag - n: NAT64 flag +- a: Advertising PIO (AP) flag - prf: Preference, which may be: 'high', 'med', or 'low'. ```bash @@ -358,6 +360,7 @@ External Routes are listed under `Routes` header: - Flags - s: Stable flag - n: NAT64 flag + - a: Advertising PIO (AP) flag - Preference `high`, `med`, or `low` - RLOC16 of device which added the route prefix diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 9b8a454bb..05da53569 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -6321,6 +6321,10 @@ otError Interpreter::ParseRoute(Arg aArgs[], otExternalRouteConfig &aConfig) aConfig.mNat64 = true; break; + case 'a': + aConfig.mAdvPio = true; + break; + case '-': break; diff --git a/src/cli/cli_network_data.cpp b/src/cli/cli_network_data.cpp index 8c492e38a..2406b634c 100644 --- a/src/cli/cli_network_data.cpp +++ b/src/cli/cli_network_data.cpp @@ -134,6 +134,11 @@ void NetworkData::RouteFlagsToString(const otExternalRouteConfig &aConfig, Flags *flagsPtr++ = 'n'; } + if (aConfig.mAdvPio) + { + *flagsPtr++ = 'a'; + } + *flagsPtr = '\0'; } diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 6a0c0df2c..11c520498 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -2174,6 +2174,12 @@ void RoutingManager::OnLinkPrefixManager::SetState(State aState) mLocalPrefix.ToString().AsCString()); mState = aState; + // Mark the Advertising PIO (AP) flag in the published route, when + // the local on-link prefix is being published, advertised, or + // deprecated. + + Get().mRoutePublisher.UpdateAdvPioFlags(aState != kIdle); + exit: return; } @@ -2745,6 +2751,7 @@ RoutingManager::RoutePublisher::RoutePublisher(Instance &aInstance) , mState(kDoNotPublish) , mPreference(NetworkData::kRoutePreferenceMedium) , mUserSetPreference(false) + , mAdvPioFlag(false) , mTimer(aInstance) { } @@ -2799,7 +2806,8 @@ void RoutingManager::RoutePublisher::UpdatePublishedRoute(State aNewState) { // Updates the published route entry in Network Data, transitioning // from current `mState` to new `aNewState`. This method can be used - // when there is no change to `mState` but a change to `mPreference`. + // when there is no change to `mState` but a change to `mPreference` + // or `mAdvPioFlag`. Ip6::Prefix oldPrefix; NetworkData::ExternalRouteConfig routeConfig; @@ -2815,6 +2823,7 @@ void RoutingManager::RoutePublisher::UpdatePublishedRoute(State aNewState) routeConfig.Clear(); routeConfig.mPreference = mPreference; + routeConfig.mAdvPio = mAdvPioFlag; routeConfig.mStable = true; DeterminePrefixFor(aNewState, routeConfig.GetPrefix()); @@ -2855,6 +2864,16 @@ void RoutingManager::RoutePublisher::Unpublish(void) return; } +void RoutingManager::RoutePublisher::UpdateAdvPioFlags(bool aAdvPioFlag) +{ + VerifyOrExit(mAdvPioFlag != aAdvPioFlag); + mAdvPioFlag = aAdvPioFlag; + UpdatePublishedRoute(mState); + +exit: + return; +} + void RoutingManager::RoutePublisher::SetPreference(RoutePreference aPreference) { LogInfo("User explicitly set published route preference to %s", RoutePreferenceToString(aPreference)); diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index 458e645db..b779461a4 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -988,6 +988,8 @@ class RoutingManager : public InstanceLocator void Stop(void) { Unpublish(); } void Evaluate(void); + void UpdateAdvPioFlags(bool aAdvPioFlag); + RoutePreference GetPreference(void) const { return mPreference; } void SetPreference(RoutePreference aPreference); void ClearPreference(void); @@ -1022,6 +1024,7 @@ class RoutingManager : public InstanceLocator State mState; RoutePreference mPreference; bool mUserSetPreference; + bool mAdvPioFlag; DelayTimer mTimer; }; diff --git a/src/core/thread/network_data_tlvs.hpp b/src/core/thread/network_data_tlvs.hpp index b93a97bac..3c128be87 100644 --- a/src/core/thread/network_data_tlvs.hpp +++ b/src/core/thread/network_data_tlvs.hpp @@ -467,6 +467,15 @@ class HasRouteEntry : public Equatable */ bool IsNat64(void) const { return (mFlags & kNat64Flag) != 0; } + /** + * Indicates whether or not the Advertising PIO (AP) flag is set. + * + * @retval TRUE If the AP flag is set. + * @retval FALSE If the AP flag is not set. + * + */ + bool IsAdvPio(void) const { return (mFlags & kAdvPioFlag) != 0; } + /** * Returns a pointer to the next HasRouteEntry. * @@ -508,6 +517,7 @@ class HasRouteEntry : public Equatable static constexpr uint8_t kPreferenceOffset = 6; static constexpr uint8_t kPreferenceMask = 3 << kPreferenceOffset; static constexpr uint8_t kNat64Flag = 1 << 5; + static constexpr uint8_t kAdvPioFlag = 1 << 4; uint16_t mRloc; uint8_t mFlags; diff --git a/src/core/thread/network_data_types.cpp b/src/core/thread/network_data_types.cpp index 24440cf53..1793f2b4c 100644 --- a/src/core/thread/network_data_types.cpp +++ b/src/core/thread/network_data_types.cpp @@ -184,6 +184,11 @@ uint8_t ExternalRouteConfig::ConvertToTlvFlags(void) const flags |= HasRouteEntry::kNat64Flag; } + if (mAdvPio) + { + flags |= HasRouteEntry::kAdvPioFlag; + } + flags |= (RoutePreferenceToValue(mPreference) << HasRouteEntry::kPreferenceOffset); return flags; @@ -208,6 +213,7 @@ void ExternalRouteConfig::SetFrom(Instance &aInstance, void ExternalRouteConfig::SetFromTlvFlags(uint8_t aFlags) { mNat64 = ((aFlags & HasRouteEntry::kNat64Flag) != 0); + mAdvPio = ((aFlags & HasRouteEntry::kAdvPioFlag) != 0); mPreference = RoutePreferenceFromValue(aFlags >> HasRouteEntry::kPreferenceOffset); } diff --git a/tests/toranj/cli/test-021-br-route-prf.py b/tests/toranj/cli/test-021-br-route-prf.py index a58158b85..4d327d8e7 100755 --- a/tests/toranj/cli/test-021-br-route-prf.py +++ b/tests/toranj/cli/test-021-br-route-prf.py @@ -97,7 +97,7 @@ def check_published_route_1(): verify(br.br_get_state() == 'running') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s med')) + verify(routes[0].startswith('fc00::/7 sa med')) verify(br.br_get_routeprf() == 'med') @@ -118,7 +118,7 @@ def check_published_route_2(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s low')) + verify(routes[0].startswith('fc00::/7 sa low')) verify(br.br_get_routeprf() == 'low') @@ -135,7 +135,7 @@ def check_published_route_3(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s high')) + verify(routes[0].startswith('fc00::/7 sa high')) verify(br.br_get_routeprf() == 'high') @@ -148,7 +148,7 @@ def check_published_route_4(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s med')) + verify(routes[0].startswith('fc00::/7 sa med')) verify(br.br_get_routeprf() == 'med') @@ -166,7 +166,7 @@ def check_published_route_5(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s low')) + verify(routes[0].startswith('fc00::/7 sa low')) verify(br.br_get_routeprf() == 'low') @@ -183,7 +183,7 @@ def check_published_route_6(): verify(br.get_state() == 'router') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s med')) + verify(routes[0].startswith('fc00::/7 sa med')) verify(br.br_get_routeprf() == 'med') @@ -204,7 +204,7 @@ def check_published_route_7(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s med')) + verify(routes[0].startswith('fc00::/7 sa med')) verify(br.br_get_routeprf() == 'med') @@ -224,7 +224,7 @@ def check_published_route_8(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s low')) + verify(routes[0].startswith('fc00::/7 sa low')) verify(br.br_get_routeprf() == 'low') @@ -247,7 +247,7 @@ def check_published_route_9(): verify(br.get_state() == 'child') routes = br.get_netdata_routes() verify(len(routes) == 1) - verify(routes[0].startswith('fc00::/7 s med')) + verify(routes[0].startswith('fc00::/7 sa med')) verify(br.br_get_routeprf() == 'med') diff --git a/tests/unit/test_network_data.cpp b/tests/unit/test_network_data.cpp index 51c0b67c4..6fcdfd3ec 100644 --- a/tests/unit/test_network_data.cpp +++ b/tests/unit/test_network_data.cpp @@ -134,6 +134,7 @@ void TestNetworkDataIterator(void) false, // mNat64 false, // mStable false, // mNextHopIsThisDevice + false, // mAdvPio }, { { @@ -146,6 +147,7 @@ void TestNetworkDataIterator(void) false, // mNat64 true, // mStable false, // mNextHopIsThisDevice + false, // mAdvPio }, }; diff --git a/tests/unit/test_routing_manager.cpp b/tests/unit/test_routing_manager.cpp index a4b5cad91..43089b4e0 100644 --- a/tests/unit/test_routing_manager.cpp +++ b/tests/unit/test_routing_manager.cpp @@ -631,7 +631,14 @@ enum ExternalRouteMode : uint8_t kUlaRoute, }; -void VerifyExternalRouteInNetData(ExternalRouteMode aMode) +enum AdvPioMode : uint8_t +{ + kSkipAdvPioCheck, + kWithAdvPioFlagSet, + kWithAdvPioCleared, +}; + +void VerifyExternalRouteInNetData(ExternalRouteMode aExternalRouteMode, AdvPioMode aAdvPioMode = kSkipAdvPioCheck) { Error error; otNetworkDataIterator iterator = OT_NETWORK_DATA_ITERATOR_INIT; @@ -639,7 +646,7 @@ void VerifyExternalRouteInNetData(ExternalRouteMode aMode) error = otNetDataGetNextRoute(sInstance, &iterator, &routeConfig); - switch (aMode) + switch (aExternalRouteMode) { case kNoRoute: Log("VerifyExternalRouteInNetData(kNoRoute)"); @@ -650,6 +657,7 @@ void VerifyExternalRouteInNetData(ExternalRouteMode aMode) Log("VerifyExternalRouteInNetData(kDefaultRoute)"); VerifyOrQuit(error == kErrorNone); VerifyOrQuit(routeConfig.mPrefix.mLength == 0); + VerifyOrQuit((aAdvPioMode == kSkipAdvPioCheck) || (routeConfig.mAdvPio == (aAdvPioMode == kWithAdvPioFlagSet))); VerifyOrQuit(otNetDataGetNextRoute(sInstance, &iterator, &routeConfig) != kErrorNone); break; @@ -658,6 +666,7 @@ void VerifyExternalRouteInNetData(ExternalRouteMode aMode) VerifyOrQuit(error == kErrorNone); VerifyOrQuit(routeConfig.mPrefix.mLength == 7); VerifyOrQuit(routeConfig.mPrefix.mPrefix.mFields.m8[0] == 0xfc); + VerifyOrQuit((aAdvPioMode == kSkipAdvPioCheck) || (routeConfig.mAdvPio == (aAdvPioMode == kWithAdvPioFlagSet))); VerifyOrQuit(otNetDataGetNextRoute(sInstance, &iterator, &routeConfig) != kErrorNone); break; } @@ -1040,7 +1049,7 @@ void TestSamePrefixesFromMultipleRouters(void) // Check Network Data to include the local OMR and on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A with a new on-link (PIO) and route prefix (RIO). @@ -1068,7 +1077,7 @@ void TestSamePrefixesFromMultipleRouters(void) // Check Network Data to include new prefixes from router A. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send the same RA again from router A with the on-link (PIO) and route prefix (RIO). @@ -1103,7 +1112,7 @@ void TestSamePrefixesFromMultipleRouters(void) // Check Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router B removing the route prefix. @@ -1122,7 +1131,7 @@ void TestSamePrefixesFromMultipleRouters(void) //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check Network Data. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1172,7 +1181,7 @@ void TestOmrSelection(void) // Check Network Data to include the local OMR and on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Add a new OMR prefix directly into net data. The new prefix should @@ -1210,7 +1219,7 @@ void TestOmrSelection(void) // is removed. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Remove the OMR prefix previously added in net data. @@ -1237,7 +1246,7 @@ void TestOmrSelection(void) // added again. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1288,7 +1297,7 @@ void TestDefaultRoute(void) // Check Network Data to include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A advertising a default route. @@ -1309,7 +1318,7 @@ void TestDefaultRoute(void) // OMR prefix (with preference medium or higher). VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Add an OMR prefix directly into Network Data with @@ -1334,7 +1343,7 @@ void TestDefaultRoute(void) // OMR prefix, the default route should be published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Remove the OMR prefix from Network Data. @@ -1350,7 +1359,7 @@ void TestDefaultRoute(void) // the discovered prefix table. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); VerifyPrefixTable({RoutePrefix(defaultRoute, kValidLitime, NetworkData::kRoutePreferenceLow, routerAddressA)}); @@ -1366,7 +1375,7 @@ void TestDefaultRoute(void) // Check Network Data. Again the default route should be published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A removing the default route. @@ -1382,7 +1391,7 @@ void TestDefaultRoute(void) // a default-route, we should go back to publishing ULA route. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A again advertising a default route. @@ -1397,7 +1406,7 @@ void TestDefaultRoute(void) // Check Network Data. We should see default route published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1449,7 +1458,7 @@ void TestAdvNonUlaRoute(void) // Check Network Data to include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A advertising a non-ULA. @@ -1470,7 +1479,7 @@ void TestAdvNonUlaRoute(void) // OMR prefix (with preference medium or higher). VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Add an OMR prefix directly into Network Data with @@ -1495,7 +1504,7 @@ void TestAdvNonUlaRoute(void) // OMR prefix, the default route should be published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Remove the OMR prefix from Network Data. @@ -1511,7 +1520,7 @@ void TestAdvNonUlaRoute(void) // the discovered prefix table. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); VerifyPrefixTable({RoutePrefix(routePrefix, kValidLitime, NetworkData::kRoutePreferenceMedium, routerAddressA)}); @@ -1527,7 +1536,7 @@ void TestAdvNonUlaRoute(void) // Check Network Data. Again the default route should be published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A removing the route. @@ -1543,7 +1552,7 @@ void TestAdvNonUlaRoute(void) // the route, we should go back to publishing the ULA route. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A again advertising the route again. @@ -1558,7 +1567,7 @@ void TestAdvNonUlaRoute(void) // Check Network Data. We should see default route published. VerifyOmrPrefixInNetData(omrPrefix, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1611,7 +1620,7 @@ void TestLocalOnLinkPrefixDeprecation(void) // Check Network Data to include the local OMR and on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A with a new on-link (PIO) which is preferred over @@ -1639,7 +1648,7 @@ void TestLocalOnLinkPrefixDeprecation(void) // along with the deprecating local on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Wait for local on-link prefix to expire @@ -1654,7 +1663,7 @@ void TestLocalOnLinkPrefixDeprecation(void) // see the deprecating local on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kSkipAdvPioCheck); // Keep checking the emitted RAs and make sure on-link prefix // is included with smaller lifetime every time. @@ -1692,7 +1701,7 @@ void TestLocalOnLinkPrefixDeprecation(void) // Check Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioCleared); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1743,7 +1752,7 @@ void TestDomainPrefixAsOmr(void) // Check Network Data to include the local OMR and on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Add a domain prefix directly into net data. The new prefix should @@ -1812,7 +1821,7 @@ void TestDomainPrefixAsOmr(void) // is removed. VerifyOmrPrefixInNetData(domainPrefix, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Remove the domain prefix from net data. @@ -1839,7 +1848,7 @@ void TestDomainPrefixAsOmr(void) // added again. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1938,7 +1947,7 @@ void TestExtPanIdChange(void) // Validate Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Stop BR and validate that a final RA is emitted deprecating @@ -1985,7 +1994,7 @@ void TestExtPanIdChange(void) { // Ensure Network Data entries remain as before. - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); // Keep checking the emitted RAs and make sure the prefix // is included with smaller lifetime every time. @@ -2017,7 +2026,7 @@ void TestExtPanIdChange(void) // Validate the Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // Check behavior when ext PAN ID changes while the local on-link is being @@ -2070,7 +2079,7 @@ void TestExtPanIdChange(void) // Validate that Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Wait for old local on-link prefix to expire. @@ -2083,7 +2092,7 @@ void TestExtPanIdChange(void) // Ensure Network Data entries remain as before. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); // Keep checking the emitted RAs and make sure the prefix // is included with smaller lifetime every time. @@ -2121,7 +2130,7 @@ void TestExtPanIdChange(void) // Validate the Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // Check behavior when ext PAN ID changes while the local on-link is not @@ -2150,7 +2159,7 @@ void TestExtPanIdChange(void) // Validate the Network Data. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Remove the on-link prefix PIO being advertised by router A @@ -2171,7 +2180,7 @@ void TestExtPanIdChange(void) AdvanceTime(2000 * 1000); VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // Multiple PAN ID changes and multiple deprecating old prefixes. @@ -2190,7 +2199,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(sDeprecatingPrefixes.GetLength() == 1); VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[0])); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Change the prefix again. We should see two deprecating prefixes. @@ -2210,7 +2219,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[0])); VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[1])); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Wait for 15 minutes and then change ext PAN ID again. @@ -2234,7 +2243,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[1])); VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[2])); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Change ext PAN ID back to previous value of `kExtPanId1`. @@ -2258,7 +2267,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(oldPrefixes[2] == localOnLink); VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[3])); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Stop BR and validate the final emitted RA to contain @@ -2308,7 +2317,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(sDeprecatingPrefixes.GetLength() == 1); VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[3])); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // Validate the oldest prefix is removed when we have too many @@ -2343,7 +2352,7 @@ void TestExtPanIdChange(void) VerifyOrQuit(sDeprecatingPrefixes.ContainsMatching(oldPrefixes[2])); VerifyOrQuit(!sDeprecatingPrefixes.ContainsMatching(oldLocalOnLink)); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2545,7 +2554,7 @@ void TestConflictingPrefix(void) // Check Network Data to include the local OMR and on-link prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A with our local on-link prefix as RIO. @@ -2564,7 +2573,7 @@ void TestConflictingPrefix(void) // Check Network Data to still include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A removing local on-link prefix as RIO. @@ -2576,7 +2585,7 @@ void TestConflictingPrefix(void) // the change by router A did not cause it to be unpublished. AdvanceTime(10000); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check that the local on-link prefix is still being advertised. @@ -2585,7 +2594,7 @@ void TestConflictingPrefix(void) AdvanceTime(610000); VerifyOrQuit(sRaValidated); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router B advertising an on-link prefix. This @@ -2609,7 +2618,7 @@ void TestConflictingPrefix(void) // the new on-link prefix from router B. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ true); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A again adding local on-link prefix as RIO. @@ -2627,7 +2636,7 @@ void TestConflictingPrefix(void) //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check Network Data remains unchanged. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A removing the previous RIO. @@ -2638,7 +2647,7 @@ void TestConflictingPrefix(void) // Check Network Data remains unchanged. AdvanceTime(60000); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router B removing its on-link prefix. @@ -2657,7 +2666,7 @@ void TestConflictingPrefix(void) //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check Network Data to remain unchanged. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Change the extended PAN ID. @@ -2682,7 +2691,7 @@ void TestConflictingPrefix(void) // Check Network Data contains default route due to the // deprecating on-link prefix from router B. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A again adding the old local on-link prefix @@ -2694,7 +2703,7 @@ void TestConflictingPrefix(void) // Check Network Data remains unchanged. AdvanceTime(10000); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send an RA from router A removing the previous RIO. @@ -2705,7 +2714,7 @@ void TestConflictingPrefix(void) // Check Network Data remains unchanged. AdvanceTime(10000); - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2757,7 +2766,7 @@ void TestSavedOnLinkPrefixes(void) // Check Network Data to include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Disable the instance and re-enable it. @@ -2782,7 +2791,7 @@ void TestSavedOnLinkPrefixes(void) // Check Network Data to include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Send RA from router A advertising an on-link prefix. @@ -2818,7 +2827,7 @@ void TestSavedOnLinkPrefixes(void) // Check Network Data to include the local OMR and ULA prefix. VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); - VerifyExternalRouteInNetData(kUlaRoute); + VerifyExternalRouteInNetData(kUlaRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2879,7 +2888,7 @@ void TestSavedOnLinkPrefixes(void) // Check Network Data to now use default route due to the // on-link prefix from router A. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioFlagSet); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Wait for more than 1800 seconds to let the deprecating @@ -2891,7 +2900,7 @@ void TestSavedOnLinkPrefixes(void) AdvanceTime(10 * 1000); } - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Disable the instance and re-enable it and restart Routing Manager. @@ -2920,7 +2929,7 @@ void TestSavedOnLinkPrefixes(void) //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check Network Data still contains the default route. - VerifyExternalRouteInNetData(kDefaultRoute); + VerifyExternalRouteInNetData(kDefaultRoute, kWithAdvPioCleared); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -