[bbr] handle role changes directly in BackboneRouter::Local (#13112)

This commit updates `BackboneRouter::Local` to receive role change
events directly from the `Notifier`. Previously, `Bbr::Local` was
indirectly relying on `BackboneRouter::Leader` to emit events even
when the PBBR configuration had not changed (e.g., during role
transitions).

The previous design was fragile and created an unnecessary dependency.
`Bbr::Local` now independently tracks role changes to ensure it
correctly evaluates its own status (e.g., deciding whether to
register as the Primary BBR).
This commit is contained in:
Abtin Keshavarzian
2026-05-18 22:02:40 -07:00
committed by Jonathan Hui
parent c5efa406c2
commit 9137b82dbe
3 changed files with 19 additions and 0 deletions
+12
View File
@@ -240,7 +240,19 @@ exit:
void Local::HandleBackboneRouterPrimaryUpdate(PrimaryEvent aEvent)
{
OT_UNUSED_VARIABLE(aEvent);
UpdateState();
}
void Local::HandleNotifierEvents(Events aEvents)
{
if (aEvents.Contains(kEventThreadRoleChanged))
{
UpdateState();
}
}
void Local::UpdateState(void)
{
VerifyOrExit(IsEnabled() && Get<Mle::Mle>().IsAttached());
// Wait some jitter before trying to Register.
+4
View File
@@ -59,6 +59,7 @@
#include "common/locator.hpp"
#include "common/log.hpp"
#include "common/non_copyable.hpp"
#include "common/notifier.hpp"
#include "common/time_ticker.hpp"
#include "net/netif.hpp"
#include "thread/network_data.hpp"
@@ -73,6 +74,7 @@ namespace BackboneRouter {
class Local : public InstanceLocator, private NonCopyable
{
friend class ot::TimeTicker;
friend class ot::Notifier;
public:
typedef otBackboneRouterDomainPrefixCallback DomainPrefixCallback; ///< Domain Prefix callback.
@@ -265,6 +267,8 @@ private:
};
void SetState(State aState);
void HandleNotifierEvents(Events aEvents);
void UpdateState(void);
void RemoveService(void);
void HandleTimeTick(void);
void AddDomainPrefixToNetworkData(void);
+3
View File
@@ -104,6 +104,9 @@ void Notifier::EmitEvents(void)
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
Get<BackboneRouter::Leader>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
Get<BackboneRouter::Local>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
Get<Dhcp6::Server>().HandleNotifierEvents(events);
#endif