@@ -359,8 +359,8 @@ static bool remove_nh_tunnel(sai_object_id_t nh_id, IpAddress& ipAddr)
359
359
return true ;
360
360
}
361
361
362
- MuxCable::MuxCable (string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> skip_neighbors )
363
- :mux_name_(name), srv_ip4_(srv_ip4), srv_ip6_(srv_ip6), peer_ip4_(peer_ip), skip_neighbors_(skip_neighbors)
362
+ MuxCable::MuxCable (string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip)
363
+ :mux_name_(name), srv_ip4_(srv_ip4), srv_ip6_(srv_ip6), peer_ip4_(peer_ip)
364
364
{
365
365
mux_orch_ = gDirectory .get <MuxOrch*>();
366
366
mux_cb_orch_ = gDirectory .get <MuxCableOrch*>();
@@ -549,11 +549,6 @@ bool MuxCable::nbrHandler(bool enable, bool update_rt)
549
549
void MuxCable::updateNeighbor (NextHopKey nh, bool add)
550
550
{
551
551
sai_object_id_t tnh = mux_orch_->getNextHopTunnelId (MUX_TUNNEL, peer_ip4_);
552
- if (add && skip_neighbors_.find (nh.ip_address ) != skip_neighbors_.end ())
553
- {
554
- SWSS_LOG_INFO (" Skip update neighbor %s on %s" , nh.ip_address .to_string ().c_str (), nh.alias .c_str ());
555
- return ;
556
- }
557
552
nbr_handler_->update (nh, tnh, add, state_);
558
553
if (add)
559
554
{
@@ -570,7 +565,6 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
570
565
SWSS_LOG_INFO (" Neigh %s on %s, add %d, state %d" ,
571
566
nh.ip_address .to_string ().c_str (), nh.alias .c_str (), add, state);
572
567
573
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
574
568
IpPrefix pfx = nh.ip_address .to_string ();
575
569
576
570
if (add)
@@ -597,7 +591,7 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
597
591
case MuxState::MUX_STATE_STANDBY:
598
592
neighbors_[nh.ip_address ] = tunnelId;
599
593
gNeighOrch ->disableNeighbor (nh);
600
- mux_cb_orch-> addTunnelRoute (nh);
594
+ updateTunnelRoute (nh, true );
601
595
create_route (pfx, tunnelId);
602
596
break ;
603
597
default :
@@ -612,7 +606,7 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
612
606
if (state == MuxState::MUX_STATE_STANDBY)
613
607
{
614
608
remove_route (pfx);
615
- mux_cb_orch-> removeTunnelRoute (nh);
609
+ updateTunnelRoute (nh, false );
616
610
}
617
611
neighbors_.erase (nh.ip_address );
618
612
}
@@ -621,7 +615,6 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
621
615
bool MuxNbrHandler::enable (bool update_rt)
622
616
{
623
617
NeighborEntry neigh;
624
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
625
618
626
619
auto it = neighbors_.begin ();
627
620
while (it != neighbors_.end ())
@@ -677,7 +670,7 @@ bool MuxNbrHandler::enable(bool update_rt)
677
670
{
678
671
return false ;
679
672
}
680
- mux_cb_orch-> removeTunnelRoute (nh_key);
673
+ updateTunnelRoute (nh_key, false );
681
674
}
682
675
683
676
it++;
@@ -689,7 +682,6 @@ bool MuxNbrHandler::enable(bool update_rt)
689
682
bool MuxNbrHandler::disable (sai_object_id_t tnh)
690
683
{
691
684
NeighborEntry neigh;
692
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
693
685
694
686
auto it = neighbors_.begin ();
695
687
while (it != neighbors_.end ())
@@ -735,7 +727,7 @@ bool MuxNbrHandler::disable(sai_object_id_t tnh)
735
727
return false ;
736
728
}
737
729
738
- mux_cb_orch-> addTunnelRoute (nh_key);
730
+ updateTunnelRoute (nh_key, true );
739
731
740
732
IpPrefix pfx = it->first .to_string ();
741
733
if (create_route (pfx, it->second ) != SAI_STATUS_SUCCESS)
@@ -760,6 +752,27 @@ sai_object_id_t MuxNbrHandler::getNextHopId(const NextHopKey nhKey)
760
752
return SAI_NULL_OBJECT_ID;
761
753
}
762
754
755
+ void MuxNbrHandler::updateTunnelRoute (NextHopKey nh, bool add)
756
+ {
757
+ MuxOrch* mux_orch = gDirectory .get <MuxOrch*>();
758
+ MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
759
+
760
+ if (mux_orch->isSkipNeighbor (nh.ip_address ))
761
+ {
762
+ SWSS_LOG_INFO (" Skip updating neighbor %s, add %d" , nh.ip_address .to_string ().c_str (), add);
763
+ return ;
764
+ }
765
+
766
+ if (add)
767
+ {
768
+ mux_cb_orch->addTunnelRoute (nh);
769
+ }
770
+ else
771
+ {
772
+ mux_cb_orch->removeTunnelRoute (nh);
773
+ }
774
+ }
775
+
763
776
std::map<std::string, AclTable> MuxAclHandler::acl_table_;
764
777
765
778
MuxAclHandler::MuxAclHandler (sai_object_id_t port, string alias)
@@ -977,7 +990,7 @@ bool MuxOrch::isNeighborActive(const IpAddress& nbr, const MacAddress& mac, stri
977
990
978
991
if (ptr)
979
992
{
980
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
993
+ return ptr->isActive ();
981
994
}
982
995
983
996
string port;
@@ -991,15 +1004,15 @@ bool MuxOrch::isNeighborActive(const IpAddress& nbr, const MacAddress& mac, stri
991
1004
if (!port.empty () && isMuxExists (port))
992
1005
{
993
1006
MuxCable* ptr = getMuxCable (port);
994
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
1007
+ return ptr->isActive ();
995
1008
}
996
1009
997
1010
NextHopKey nh_key = NextHopKey (nbr, alias);
998
1011
string curr_port = getNexthopMuxName (nh_key);
999
1012
if (port.empty () && !curr_port.empty () && isMuxExists (curr_port))
1000
1013
{
1001
1014
MuxCable* ptr = getMuxCable (curr_port);
1002
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
1015
+ return ptr->isActive ();
1003
1016
}
1004
1017
1005
1018
return true ;
@@ -1295,7 +1308,8 @@ bool MuxOrch::handleMuxCfg(const Request& request)
1295
1308
}
1296
1309
1297
1310
mux_cable_tb_[port_name] = std::make_unique<MuxCable>
1298
- (MuxCable (port_name, srv_ip, srv_ip6, mux_peer_switch_, skip_neighbors));
1311
+ (MuxCable (port_name, srv_ip, srv_ip6, mux_peer_switch_));
1312
+ addSkipNeighbors (skip_neighbors);
1299
1313
1300
1314
SWSS_LOG_NOTICE (" Mux entry for port '%s' was added" , port_name.c_str ());
1301
1315
}
@@ -1307,6 +1321,7 @@ bool MuxOrch::handleMuxCfg(const Request& request)
1307
1321
return true ;
1308
1322
}
1309
1323
1324
+ removeSkipNeighbors (skip_neighbors);
1310
1325
mux_cable_tb_.erase (port_name);
1311
1326
1312
1327
SWSS_LOG_NOTICE (" Mux cable for port '%s' was removed" , port_name.c_str ());
0 commit comments