@@ -517,6 +517,34 @@ static int thread_border_relay_to_leader_cb(int8_t service_id, uint8_t source_ad
517
517
}
518
518
519
519
#ifdef HAVE_THREAD_BORDER_ROUTER
520
+ static bool thread_bbr_default_route_exists (struct protocol_interface_info_entry * cur , uint8_t prefix_ptr [8 ])
521
+ {
522
+ uint16_t rloc16 = mac_helper_mac16_address_get (cur );
523
+ ns_list_foreach (thread_network_data_prefix_cache_entry_t , prefix , & cur -> thread_info -> networkDataStorage .localPrefixList ) {
524
+
525
+ if (prefix_ptr &&
526
+ (prefix -> servicesPrefixLen != 64 ||
527
+ memcmp (prefix_ptr , prefix -> servicesPrefix , 8 ) != 0 )) {
528
+ // Only matching prefixes are counted
529
+ continue ;
530
+ }
531
+
532
+ ns_list_foreach (thread_network_server_data_entry_t , br , & prefix -> borderRouterList ) {
533
+ if (br -> routerID == 0xfffe ) {
534
+ continue ;
535
+ }
536
+ if (!br -> P_default_route ) {
537
+ continue ;
538
+ }
539
+ if (rloc16 != br -> routerID ) {
540
+ // different default route exists
541
+ return true;
542
+ }
543
+ }
544
+ }
545
+ return false;
546
+ }
547
+
520
548
static bool thread_bbr_i_host_prefix (struct protocol_interface_info_entry * cur , uint8_t prefix_ptr [8 ], uint8_t * br_count , bool * i_am_lowest )
521
549
{
522
550
bool i_host_this_prefix = false;
@@ -600,14 +628,15 @@ static void thread_bbr_network_data_send(thread_bbr_t *this, uint8_t prefix[8],
600
628
this -> br_info_published = true;
601
629
}
602
630
603
- static void thread_bbr_routing_enable (thread_bbr_t * this )
631
+ static void thread_bbr_routing_enable (thread_bbr_t * this , bool multicast_routing_enabled )
604
632
{
605
633
if (this -> routing_enabled ) {
606
634
return ;
607
635
}
608
636
tr_info ("br: enable routing" );
609
637
// Start multicast proxying
610
- multicast_fwd_set_forwarding (this -> interface_id , true);
638
+ // We do not enable multicast forwarding as there is other default router present in network
639
+ multicast_fwd_set_forwarding (this -> interface_id , multicast_routing_enabled );
611
640
this -> routing_enabled = true;
612
641
}
613
642
@@ -663,7 +692,13 @@ static void thread_bbr_status_check(thread_bbr_t *this, uint32_t seconds)
663
692
664
693
// Check from network data are we currently BR or not and change routing state
665
694
if (this -> br_hosted ) {
666
- thread_bbr_routing_enable (this );
695
+
696
+ //If there is a default router present in any prefix other than us we do not forward multicast
697
+ //This prevents multicasts to different interfaces where Thread Mesh is forwarder
698
+ bool forward_multicast = !thread_bbr_default_route_exists (cur , NULL );
699
+ thread_extension_bbr_mcast_fwd_check (cur -> id , & forward_multicast );
700
+
701
+ thread_bbr_routing_enable (this , forward_multicast );
667
702
} else {
668
703
thread_bbr_routing_disable (this );
669
704
}
0 commit comments