@@ -537,6 +537,72 @@ def create_and_test_route(self, appdb, asicdb, dvs, dvs_route):
537537
538538 ps ._del (rtprefix )
539539
540+ def create_and_test_NH_routes (self , appdb , asicdb , dvs , dvs_route , mac ):
541+ '''
542+ Tests case where neighbor is removed in standby and added in active with route
543+ '''
544+ nh_route = "2.2.2.0/24"
545+ nh_route_ipv6 = "2023::/64"
546+ neigh_ip = self .SERV1_IPV4
547+ neigh_ipv6 = self .SERV1_IPV6
548+ apdb = dvs .get_app_db ()
549+
550+ # Setup
551+ self .set_mux_state (appdb , "Ethernet0" , "active" )
552+ self .add_neighbor (dvs , neigh_ip , mac )
553+ self .add_neighbor (dvs , neigh_ipv6 , mac )
554+ dvs .runcmd (
555+ "vtysh -c \" configure terminal\" -c \" ip route " + nh_route +
556+ " " + neigh_ip + "\" "
557+ )
558+ dvs .runcmd (
559+ "vtysh -c \" configure terminal\" -c \" ipv6 route " + nh_route_ipv6 +
560+ " " + neigh_ipv6 + "\" "
561+ )
562+ apdb .wait_for_entry ("ROUTE_TABLE" , nh_route )
563+ rtkeys = dvs_route .check_asicdb_route_entries ([nh_route ])
564+ rtkeys_ipv6 = dvs_route .check_asicdb_route_entries ([nh_route_ipv6 ])
565+ self .check_nexthop_in_asic_db (asicdb , rtkeys [0 ])
566+ self .check_nexthop_in_asic_db (asicdb , rtkeys_ipv6 [0 ])
567+
568+ # Set state to standby and delete neighbor
569+ self .set_mux_state (appdb , "Ethernet0" , "standby" )
570+ self .check_nexthop_in_asic_db (asicdb , rtkeys [0 ], True )
571+ self .check_nexthop_in_asic_db (asicdb , rtkeys_ipv6 [0 ], True )
572+
573+ self .del_neighbor (dvs , neigh_ip )
574+ self .del_neighbor (dvs , neigh_ipv6 )
575+ self .check_nexthop_in_asic_db (asicdb , rtkeys [0 ], True )
576+ self .check_nexthop_in_asic_db (asicdb , rtkeys_ipv6 [0 ], True )
577+
578+ # Set state to active, learn neighbor again
579+ self .set_mux_state (appdb , "Ethernet0" , "active" )
580+ self .check_nexthop_in_asic_db (asicdb , rtkeys [0 ], True )
581+ self .check_nexthop_in_asic_db (asicdb , rtkeys_ipv6 [0 ], True )
582+
583+ self .add_neighbor (dvs , neigh_ip , mac )
584+ self .add_neighbor (dvs , neigh_ipv6 , mac )
585+ self .check_nexthop_in_asic_db (asicdb , rtkeys [0 ])
586+ self .check_nexthop_in_asic_db (asicdb , rtkeys_ipv6 [0 ])
587+ dvs .runcmd (
588+ "ip neigh flush " + neigh_ip
589+ )
590+ dvs .runcmd (
591+ "ip neigh flush " + neigh_ipv6
592+ )
593+
594+ # Cleanup
595+ dvs .runcmd (
596+ "vtysh -c \" configure terminal\" -c \" no ip route " + nh_route +
597+ " " + neigh_ip + "\" "
598+ )
599+ dvs .runcmd (
600+ "vtysh -c \" configure terminal\" -c \" no ipv6 route " + nh_route_ipv6 +
601+ " " + neigh_ipv6 + "\" "
602+ )
603+ self .del_neighbor (dvs , neigh_ip )
604+ self .del_neighbor (dvs , neigh_ipv6 )
605+
540606 def get_expected_sai_qualifiers (self , portlist , dvs_acl ):
541607 expected_sai_qualifiers = {
542608 "SAI_ACL_ENTRY_ATTR_PRIORITY" : self .ACL_PRIORITY ,
@@ -1099,6 +1165,14 @@ def test_Route(self, dvs, dvs_route, testlog):
10991165
11001166 self .create_and_test_route (appdb , asicdb , dvs , dvs_route )
11011167
1168+ def test_NH (self , dvs , dvs_route , intf_fdb_map , setup_peer_switch , setup_tunnel , testlog ):
1169+ """ test NH routes and mux state change """
1170+ appdb = swsscommon .DBConnector (swsscommon .APPL_DB , dvs .redis_sock , 0 )
1171+ asicdb = dvs .get_asic_db ()
1172+ mac = intf_fdb_map ["Ethernet0" ]
1173+
1174+ self .create_and_test_NH_routes (appdb , asicdb , dvs , dvs_route , mac )
1175+
11021176 def test_acl (self , dvs , dvs_acl , testlog ):
11031177 """ test acl and mux state change """
11041178
0 commit comments