Skip to content

Commit

Permalink
[telemetry] add more information about external routes
Browse files Browse the repository at this point in the history
This commit removed `NodeDivergenceInfo` and added `ExternalRoutes`
messaged, to make it standalone.

The `ExternalRoutes` has three bool fields:
 - `has_default_route_added`: if leader network data has route ::/0
 - `has_ula_route_added`: if leader network data has route fc00::/7
 - `has_others_route_added`: if leader network has others route
  • Loading branch information
zesonzhang committed May 23, 2024
1 parent 8359155 commit 4518d77
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 20 deletions.
8 changes: 8 additions & 0 deletions src/common/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ class Ip6Prefix
*/
bool IsDefaultRoutePrefix(void) const { return (*this == Ip6Prefix("::", 0)); }

/**
* This method checks if the object is the ULA prefix ("fc00::/7")
*
* @returns true if the object is the ULA prefix, false otherwise.
*
*/
bool IsUlaPrefix(void) const { return (*this == Ip6Prefix("fc00::", 7)); }

Ip6Address mPrefix; ///< The IPv6 prefix.
uint8_t mLength; ///< The IPv6 prefix length (in bits).
};
Expand Down
21 changes: 12 additions & 9 deletions src/proto/thread_telemetry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,17 @@ message TelemetryData {
optional uint32 global_unicast_address_count = 7;
}

// infomation on divergent BRs resulted from multi-AIL
// TODO: add more fields to this message to provide more information
message NodeDivergenceInfo {
// Indicate whether the BR's external route is published
optional bool route_ail = 1;
// Message to indicate the information of external routes in network data.
message ExternalRoutes {
// Indicates whether the a zero-length prefix (::/0) added from this BR
optional bool has_default_route_added = 1;

// Indicate whether the BR's external route is published as default route
optional bool route_default = 2;
// Indicates whether the a ULA prefix (fc00::/7) added from this BR
optional bool has_ula_route_added = 2;

// Indicates whether the other prefixes (other than "::/0" or "fc00::/7") added
// from this BR. (BR is a managed infrastructure router).
optional bool has_others_route_added = 3;
}

message WpanBorderRouter {
Expand Down Expand Up @@ -543,8 +546,8 @@ message TelemetryData {
// Information about the infra link
optional InfraLinkInfo infra_link_info = 12;

// Information about the node divergence (multi-AIL)
optional NodeDivergenceInfo node_divergence_info = 13;
// Information about the external routes in network data.
optional ExternalRoutes external_route_info = 13;
}

message RcpStabilityStatistics {
Expand Down
28 changes: 18 additions & 10 deletions src/utils/thread_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,11 @@ void ThreadHelper::DetachGracefullyCallback(void)

#if OTBR_ENABLE_TELEMETRY_DATA_API
#if OTBR_ENABLE_BORDER_ROUTING
void ThreadHelper::GetNodeDivergenceInfo(threadnetwork::TelemetryData_NodeDivergenceInfo *aNodeDivergenceInfo)
void ThreadHelper::GetExternalRouteInfo(threadnetwork::TelemetryData_ExternalRoutes *aExternalRouteInfo)
{
bool isExternalRouteAdded = false;
bool isDefaultRouteAdded = false;
bool isDefaultRouteAdded = false;
bool isUlaRouteAdded = false;
bool isOthersRouteAdded = false;
Ip6Prefix prefix;
uint16_t rloc16 = otThreadGetRloc16(mInstance);

Expand All @@ -938,18 +939,24 @@ void ThreadHelper::GetNodeDivergenceInfo(threadnetwork::TelemetryData_NodeDiverg
continue;
}

isExternalRouteAdded = true;

prefix.Set(config.mPrefix);
if (prefix.IsDefaultRoutePrefix())
{
isDefaultRouteAdded = true;
break;
}
else if (prefix.IsUlaPrefix())
{
isUlaRouteAdded = true;
}
else
{
isOthersRouteAdded = true;
}
}

aNodeDivergenceInfo->set_route_ail(isExternalRouteAdded);
aNodeDivergenceInfo->set_route_default(isDefaultRouteAdded);
aExternalRouteInfo->set_has_default_route_added(isDefaultRouteAdded);
aExternalRouteInfo->set_has_ula_route_added(isUlaRouteAdded);
aExternalRouteInfo->set_has_others_route_added(isOthersRouteAdded);
}
#endif // OTBR_ENABLE_BORDER_ROUTING

Expand Down Expand Up @@ -1315,8 +1322,9 @@ otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadn
}
// End of InfraLinkInfo section.

// NodeDivergenceInfo section
GetNodeDivergenceInfo(wpanBorderRouter->mutable_node_divergence_info());
// ExternalRoutes section
GetExternalRouteInfo(wpanBorderRouter->mutable_external_route_info());

#endif

#if OTBR_ENABLE_SRP_ADVERTISING_PROXY
Expand Down
2 changes: 1 addition & 1 deletion src/utils/thread_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class ThreadHelper
void ActiveDatasetChangedCallback(void);

#if OTBR_ENABLE_TELEMETRY_DATA_API && OTBR_ENABLE_BORDER_ROUTING
void GetNodeDivergenceInfo(threadnetwork::TelemetryData_NodeDivergenceInfo *aNodeDivergenceInfo);
void GetExternalRouteInfo(threadnetwork::TelemetryData_ExternalRoutes *aExternalRouteInfo);
#endif

otInstance *mInstance;
Expand Down

0 comments on commit 4518d77

Please sign in to comment.