@@ -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*>();
@@ -543,11 +543,6 @@ bool MuxCable::nbrHandler(bool enable, bool update_rt)
543
543
void MuxCable::updateNeighbor (NextHopKey nh, bool add)
544
544
{
545
545
sai_object_id_t tnh = mux_orch_->getNextHopTunnelId (MUX_TUNNEL, peer_ip4_);
546
- if (add && skip_neighbors_.find (nh.ip_address ) != skip_neighbors_.end ())
547
- {
548
- SWSS_LOG_INFO (" Skip update neighbor %s on %s" , nh.ip_address .to_string ().c_str (), nh.alias .c_str ());
549
- return ;
550
- }
551
546
nbr_handler_->update (nh, tnh, add, state_);
552
547
if (add)
553
548
{
@@ -564,7 +559,6 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
564
559
SWSS_LOG_INFO (" Neigh %s on %s, add %d, state %d" ,
565
560
nh.ip_address .to_string ().c_str (), nh.alias .c_str (), add, state);
566
561
567
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
568
562
IpPrefix pfx = nh.ip_address .to_string ();
569
563
570
564
if (add)
@@ -591,7 +585,7 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
591
585
case MuxState::MUX_STATE_STANDBY:
592
586
neighbors_[nh.ip_address ] = tunnelId;
593
587
gNeighOrch ->disableNeighbor (nh);
594
- mux_cb_orch-> addTunnelRoute (nh);
588
+ updateTunnelRoute (nh, true );
595
589
create_route (pfx, tunnelId);
596
590
break ;
597
591
default :
@@ -606,7 +600,7 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
606
600
if (state == MuxState::MUX_STATE_STANDBY)
607
601
{
608
602
remove_route (pfx);
609
- mux_cb_orch-> removeTunnelRoute (nh);
603
+ updateTunnelRoute (nh, false );
610
604
}
611
605
neighbors_.erase (nh.ip_address );
612
606
}
@@ -615,7 +609,6 @@ void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, Mu
615
609
bool MuxNbrHandler::enable (bool update_rt)
616
610
{
617
611
NeighborEntry neigh;
618
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
619
612
620
613
auto it = neighbors_.begin ();
621
614
while (it != neighbors_.end ())
@@ -671,7 +664,7 @@ bool MuxNbrHandler::enable(bool update_rt)
671
664
{
672
665
return false ;
673
666
}
674
- mux_cb_orch-> removeTunnelRoute (nh_key);
667
+ updateTunnelRoute (nh_key, false );
675
668
}
676
669
677
670
it++;
@@ -683,7 +676,6 @@ bool MuxNbrHandler::enable(bool update_rt)
683
676
bool MuxNbrHandler::disable (sai_object_id_t tnh)
684
677
{
685
678
NeighborEntry neigh;
686
- MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
687
679
688
680
auto it = neighbors_.begin ();
689
681
while (it != neighbors_.end ())
@@ -729,7 +721,7 @@ bool MuxNbrHandler::disable(sai_object_id_t tnh)
729
721
return false ;
730
722
}
731
723
732
- mux_cb_orch-> addTunnelRoute (nh_key);
724
+ updateTunnelRoute (nh_key, true );
733
725
734
726
IpPrefix pfx = it->first .to_string ();
735
727
if (create_route (pfx, it->second ) != SAI_STATUS_SUCCESS)
@@ -754,6 +746,27 @@ sai_object_id_t MuxNbrHandler::getNextHopId(const NextHopKey nhKey)
754
746
return SAI_NULL_OBJECT_ID;
755
747
}
756
748
749
+ void MuxNbrHandler::updateTunnelRoute (NextHopKey nh, bool add)
750
+ {
751
+ MuxOrch* mux_orch = gDirectory .get <MuxOrch*>();
752
+ MuxCableOrch* mux_cb_orch = gDirectory .get <MuxCableOrch*>();
753
+
754
+ if (mux_orch->isSkipNeighbor (nh.ip_address ))
755
+ {
756
+ SWSS_LOG_INFO (" Skip updating neighbor %s, add %d" , nh.ip_address .to_string ().c_str (), add);
757
+ return ;
758
+ }
759
+
760
+ if (add)
761
+ {
762
+ mux_cb_orch->addTunnelRoute (nh);
763
+ }
764
+ else
765
+ {
766
+ mux_cb_orch->removeTunnelRoute (nh);
767
+ }
768
+ }
769
+
757
770
std::map<std::string, AclTable> MuxAclHandler::acl_table_;
758
771
759
772
MuxAclHandler::MuxAclHandler (sai_object_id_t port, string alias)
@@ -971,7 +984,7 @@ bool MuxOrch::isNeighborActive(const IpAddress& nbr, const MacAddress& mac, stri
971
984
972
985
if (ptr)
973
986
{
974
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
987
+ return ptr->isActive ();
975
988
}
976
989
977
990
string port;
@@ -985,15 +998,15 @@ bool MuxOrch::isNeighborActive(const IpAddress& nbr, const MacAddress& mac, stri
985
998
if (!port.empty () && isMuxExists (port))
986
999
{
987
1000
MuxCable* ptr = getMuxCable (port);
988
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
1001
+ return ptr->isActive ();
989
1002
}
990
1003
991
1004
NextHopKey nh_key = NextHopKey (nbr, alias);
992
1005
string curr_port = getNexthopMuxName (nh_key);
993
1006
if (port.empty () && !curr_port.empty () && isMuxExists (curr_port))
994
1007
{
995
1008
MuxCable* ptr = getMuxCable (curr_port);
996
- return ( ptr->isActive () || ptr-> isSkipNeighbor (nbr) );
1009
+ return ptr->isActive ();
997
1010
}
998
1011
999
1012
return true ;
@@ -1289,7 +1302,8 @@ bool MuxOrch::handleMuxCfg(const Request& request)
1289
1302
}
1290
1303
1291
1304
mux_cable_tb_[port_name] = std::make_unique<MuxCable>
1292
- (MuxCable (port_name, srv_ip, srv_ip6, mux_peer_switch_, skip_neighbors));
1305
+ (MuxCable (port_name, srv_ip, srv_ip6, mux_peer_switch_));
1306
+ addSkipNeighbors (skip_neighbors);
1293
1307
1294
1308
SWSS_LOG_NOTICE (" Mux entry for port '%s' was added" , port_name.c_str ());
1295
1309
}
@@ -1301,6 +1315,7 @@ bool MuxOrch::handleMuxCfg(const Request& request)
1301
1315
return true ;
1302
1316
}
1303
1317
1318
+ removeSkipNeighbors (skip_neighbors);
1304
1319
mux_cable_tb_.erase (port_name);
1305
1320
1306
1321
SWSS_LOG_NOTICE (" Mux cable for port '%s' was removed" , port_name.c_str ());
0 commit comments