Exemple #1
0
def config_bgp_redistribute(config='yes'):
    bgpapi.config_bgp(dut=vars.D2,
                      local_as=eh_data.remote_asn,
                      addr_family=eh_data.af_ipv4,
                      config=config,
                      config_type_list=["redist"],
                      redistribute='connected')
    bgpapi.config_bgp(dut=vars.D2,
                      local_as=eh_data.remote_asn,
                      addr_family=eh_data.af_ipv6,
                      config=config,
                      config_type_list=["redist"],
                      redistribute='connected')
    st.wait(1)
Exemple #2
0
def test_ft_bgp_ebgp_multihop_4byteASN():
    """

    Verify the functioning of ebgp multihop command with 4 byte ASN
    """
    #On DUT1 and DUT3, create BGP with 4byte ASN
    dut1_as = 6500001
    dut1 = topo['dut_list'][0]
    dut3_as = 6500002
    dut3 = topo['dut_list'][2]

    #Configure bgp on DUT1 and add DUT3 as neighbor with ebgp-multihop ttl set to 5
    bgpapi.config_bgp(dut1,
                      local_as=dut1_as,
                      neighbor=topo['D3D2P1_ipv4'],
                      remote_as=dut3_as,
                      config_type_list=["neighbor", "ebgp_mhop"],
                      ebgp_mhop='5')
    #Add static route to DUT3 neighbor
    ipapi.create_static_route(dut1, topo['D1D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D3D2P1_ipv4']))
    #Configure bgp on DUT3 and add DUT1 as neighbor with ebgp-multihop ttl set to 5
    bgpapi.config_bgp(dut3,
                      local_as=dut3_as,
                      neighbor=topo['D1D2P1_ipv4'],
                      remote_as=dut1_as,
                      config_type_list=["neighbor", "ebgp_mhop"],
                      ebgp_mhop='5')
    #Add static route to DUT1 neighbor
    ipapi.create_static_route(dut3, topo['D3D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D1D2P1_ipv4']))

    result = bgpapi.verify_bgp_summary(dut1,
                                       family='ipv4',
                                       neighbor=topo['D3D2P1_ipv4'],
                                       state='Established')

    #Clear applied configs
    bgpapi.cleanup_router_bgp(dut1)
    bgpapi.cleanup_router_bgp(dut3)
    ipapi.delete_static_route(dut1, topo['D1D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D3D2P1_ipv4']))
    ipapi.delete_static_route(dut3, topo['D3D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D1D2P1_ipv4']))

    if result:
        st.report_pass("test_case_passed")
    else:
        st.report_fail("test_case_failed")
Exemple #3
0
def create_bgp_neighbor_route_map_config(dut, local_asn, neighbor_ip,
                                         routemap):
    rmap = rmap_obj.RouteMap(routemap)
    rmap.add_permit_sequence('10')
    rmap.add_sequence_set_ipv6_next_hop_prefer_global('10')
    rmap.execute_command(dut)
    bgpfeature.config_bgp(dut,
                          addr_family='ipv6',
                          local_as=local_asn,
                          neighbor=neighbor_ip,
                          routeMap=routemap,
                          diRection='in',
                          config='yes',
                          config_type_list=["routeMap"])
    bgpfeature.config_bgp(dut,
                          addr_family='ipv6',
                          local_as=local_asn,
                          neighbor=neighbor_ip,
                          routeMap=routemap,
                          diRection='out',
                          config='yes',
                          config_type_list=["routeMap"])
    return
Exemple #4
0
def dut_vrf_bgp(**kwargs):
    vars = st.get_testbed_vars()

    dut1 = st.get_dut_names()[0]
    dut2 = st.get_dut_names()[1]

    if 'config' in kwargs:
        config = kwargs['config']
    else:
        config = ''

    if config == '':
        st.log('######------Configure BGP in vrf for virtual interface ------######')
        for i in range(0,3):
            dict1 = {'vrf_name':data.vrf_name[i],'router_id':data.dut1_router_id,'local_as':data.dut1_as[i],'neighbor':data.dut2_dut1_vrf_ip[i],'remote_as':data.dut2_as[i],'config_type_list':['neighbor']}
            dict2 = {'vrf_name':data.vrf_name[i],'router_id':data.dut2_router_id,'local_as':data.dut2_as[i],'neighbor':data.dut1_dut2_vrf_ip[i],'remote_as':data.dut1_as[i],'config_type_list':['neighbor']}
            parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2])

            dict1 = {'vrf_name':data.vrf_name[i],'router_id':data.dut1_router_id,'local_as':data.dut1_as[i],'neighbor':data.dut2_dut1_vrf_ip[i],'remote_as':data.dut2_as[i],'config_type_list':['activate','nexthop_self']}
            dict2 = {'vrf_name':data.vrf_name[i],'router_id':data.dut2_router_id,'local_as':data.dut2_as[i],'neighbor':data.dut1_dut2_vrf_ip[i],'remote_as':data.dut1_as[i],'config_type_list':['activate','nexthop_self']}
            parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2])

            st.log('######------Configure BGPv4+ in vrf for virtual interface ------######')
            dict1 = {'vrf_name':data.vrf_name[i],'router_id':data.dut1_router_id,'local_as':data.dut1_as[i],'addr_family':'ipv6','neighbor':data.dut2_dut1_vrf_ipv6[i],'remote_as':data.dut2_as[i],'config_type_list':['neighbor']}
            dict2 = {'vrf_name':data.vrf_name[i],'router_id':data.dut2_router_id,'local_as':data.dut2_as[i],'addr_family':'ipv6','neighbor':data.dut1_dut2_vrf_ipv6[i],'remote_as':data.dut1_as[i],'config_type_list':['neighbor']}
            parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2])

            dict1 = {'vrf_name':data.vrf_name[i],'router_id':data.dut1_router_id,'local_as':data.dut1_as[i],'addr_family':'ipv6','neighbor':data.dut2_dut1_vrf_ipv6[i],'remote_as':data.dut2_as[i],'config_type_list':['activate','nexthop_self']}
            dict2 = {'vrf_name':data.vrf_name[i],'router_id':data.dut2_router_id,'local_as':data.dut2_as[i],'addr_family':'ipv6','neighbor':data.dut1_dut2_vrf_ipv6[i],'remote_as':data.dut1_as[i],'config_type_list':['activate','nexthop_self']}
            parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2])

            bgp_obj.config_bgp(dut = dut2, vrf_name = data.vrf_name[i], local_as = data.dut2_as[i], addr_family ='ipv6', config_type_list=["routeMap"], routeMap='UseGlobal', diRection='in', neighbor=data.dut1_dut2_vrf_ipv6[i])
            bgp_obj.config_bgp(dut = dut1, vrf_name = data.vrf_name[i], local_as = data.dut1_as[i], addr_family ='ipv6', config_type_list=["routeMap"], routeMap='UseGlobal', diRection='in', neighbor=data.dut2_dut1_vrf_ipv6[i])
    elif config == 'no':
        for i in range(0,3):
            bgp_obj.config_bgp(dut = dut1, local_as = data.dut1_as[i], vrf_name = data.vrf_name[i] ,config = 'no', removeBGP = 'yes', config_type_list = ["removeBGP"])
            bgp_obj.config_bgp(dut = dut2, local_as = data.dut2_as[i], vrf_name = data.vrf_name[i] ,config = 'no', removeBGP = 'yes', config_type_list = ["removeBGP"])
Exemple #5
0
def test_ft_bgp_unnumbered_rmap():
    """
    # ################ Author Details ################
    # Name: Sesha Reddy Koilkonda
    # Email: [email protected]
    # ################################################
    :return:
    """
    utils_obj.banner_log('FtOtSoRtBgpUnFn010,FtOtSoRtBgpUnFn016')
    result = 0
    network_ipv6 = '6002:1::0/64'

    bgp_obj.config_bgp(config='yes',
                       dut=vars.D2,
                       local_as=data.d2_local_as,
                       addr_family='ipv6',
                       neighbor=vars.D2D1P1,
                       weight='35000',
                       config_type_list=["weight"])
    bgp_obj.config_bgp_network_advertise(vars.D1,
                                         data.d1_local_as,
                                         network_ipv6,
                                         addr_family='ipv6',
                                         config='yes',
                                         network_import_check=True)
    st.wait(60)
    n1 = ip_obj.verify_ip_route(vars.D2,
                                family='ipv6',
                                shell='sonic',
                                ip_address='6002:1::/64')
    if (n1 is False):
        st.error("Failed to advertise the ipv6 network to the peer")
        result += 1
    bgp_obj.get_ip_bgp_route(vars.D2, family="ipv6", network="6002:1/64")
    # Add route-map to advertised network
    ip_obj.config_access_list(vars.D1,
                              'Ubgp-access-list1',
                              network_ipv6,
                              'deny',
                              family='ipv6',
                              seq_num="1")
    ip_obj.config_route_map_match_ip_address(vars.D1,
                                             'Ubgp-rmap',
                                             'deny',
                                             '10',
                                             'Ubgp-access-list1',
                                             family='ipv6')
    bgp_obj.advertise_bgp_network(vars.D1,
                                  data.d1_local_as,
                                  network_ipv6,
                                  'Ubgp-rmap',
                                  family='ipv6')
    # verify route-map to advertised network
    n1 = ip_obj.verify_ip_route(vars.D2,
                                family='ipv6',
                                shell='sonic',
                                ip_address='6002:1::/64')
    if (n1 is True):
        st.error(
            "Advertised network is not filtered by the configured route map")
        result += 1
    else:
        st.log("As expected, advertised network is filtered by the route map.")
    # Veirfy the BGP unnumbered neighbourship post r-map config
    if not utils.poll_wait(bgp_obj.verify_bgp_summary,
                           data.wait_timer,
                           vars.D1,
                           family='ipv6',
                           shell=bgp_cli_type,
                           neighbor=vars.D1D2P1,
                           state='Established'):
        st.error(
            "Failed to form BGP unnumbered peering using IPv6 link local, with the route map configuration."
        )
        result += 1
    # Unconfig the r-map and verify the BGP neighbourship
    ip_obj.config_route_map_mode(vars.D1,
                                 'Ubgp-rmap',
                                 'deny',
                                 '10',
                                 config='no')
    ip_obj.config_access_list(vars.D1,
                              'Ubgp-access-list1',
                              network_ipv6,
                              'deny',
                              config='no',
                              family='ipv6',
                              seq_num="1")
    bgp_obj.config_bgp(config='no',
                       dut=vars.D2,
                       local_as=data.d2_local_as,
                       addr_family='ipv6',
                       neighbor=vars.D2D1P1,
                       weight='35000',
                       config_type_list=["weight"])
    bgp_obj.config_bgp_network_advertise(vars.D1,
                                         data.d1_local_as,
                                         network_ipv6,
                                         addr_family='ipv6',
                                         config='no')
    if not utils.poll_wait(bgp_obj.verify_bgp_summary,
                           data.wait_timer,
                           vars.D1,
                           family='ipv6',
                           shell=bgp_cli_type,
                           neighbor=vars.D1D2P1,
                           state='Established'):
        st.error(
            "Failed to form BGP unnumbered peering using IPv6 link local, after route map un-configuration."
        )
        result += 1
    if result == 0:
        st.report_pass("test_case_passed")
    else:
        st.error(
            "BGP unnumbered neighborship failed with the route map configuration."
        )
        st.report_fail("test_case_failed")
def tg_vrf_bgp2(**kwargs):
    dut1 = st.get_dut_names()[0]
    dut2 = st.get_dut_names()[1]
    if 'config' in kwargs:
        config = kwargs['config']
    else:
        config = ''

    if config == '':
        st.log(
            '######------Configure BGP in vrf -101 for TG interface------######'
        )
        for i in range(0, 3):
            st.log(
                '######------Configure BGPv4+ in vrf-102 for TG interface ------######'
            )
            bgp_obj.config_bgp(dut=dut1,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut1_router_id,
                               addr_family='ipv6',
                               local_as=data.dut1_as[i],
                               neighbor=data.tg1_dut1_vrf_ipv6_2[i],
                               remote_as=data.dut1_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            bgp_obj.config_bgp(dut=dut1,
                               vrf_name=data.vrf_name[i],
                               local_as=data.dut1_as[i],
                               addr_family='ipv6',
                               config_type_list=["routeMap"],
                               routeMap='UseGlobal',
                               diRection='in',
                               neighbor=data.tg1_dut1_vrf_ipv6_2[i])
            bgp_obj.config_bgp(dut=dut2,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut2_router_id,
                               addr_family='ipv6',
                               local_as=data.dut2_as[i],
                               neighbor=data.tg1_dut2_vrf_ipv6_2[i],
                               remote_as=data.dut2_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            bgp_obj.config_bgp(dut=dut2,
                               vrf_name=data.vrf_name[i],
                               local_as=data.dut2_as[i],
                               addr_family='ipv6',
                               config_type_list=["routeMap"],
                               routeMap='UseGlobal',
                               diRection='in',
                               neighbor=data.tg1_dut2_vrf_ipv6_2[i])
        time.sleep(2)
    elif config == 'no':
        for i in range(0, 3):
            bgp_obj.config_bgp(dut=dut1,
                               local_as=data.dut1_as[i],
                               vrf_name=data.vrf_name[i],
                               config='no',
                               removeBGP='yes',
                               config_type_list=["removeBGP"])
            bgp_obj.config_bgp(dut=dut2,
                               local_as=data.dut2_as[i],
                               vrf_name=data.vrf_name[i],
                               config='no',
                               removeBGP='yes',
                               config_type_list=["removeBGP"])
def tg_vrf_bgp(**kwargs):
    dut1 = st.get_dut_names()[0]
    dut2 = st.get_dut_names()[1]
    if 'config' in kwargs:
        config = kwargs['config']
    else:
        config = ''

    if config == '':
        st.log(
            '######------Configure BGP in vrf -101 for TG interface------######'
        )
        for i in range(0, 3):
            bgp_obj.config_bgp(dut=dut1,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut1_router_id,
                               local_as=data.dut1_as[i],
                               neighbor=data.tg1_dut1_vrf_ip[i],
                               remote_as=data.dut1_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            st.log(
                '######------Configure BGPv4+ in vrf-102 for TG interface ------######'
            )
            bgp_obj.config_bgp(dut=dut1,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut1_router_id,
                               addr_family='ipv6',
                               local_as=data.dut1_as[i],
                               neighbor=data.tg1_dut1_vrf_ipv6[i],
                               remote_as=data.dut1_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            bgp_obj.config_bgp(dut=dut1,
                               vrf_name=data.vrf_name[i],
                               local_as=data.dut1_as[i],
                               addr_family='ipv6',
                               config_type_list=["routeMap"],
                               routeMap='UseGlobal',
                               diRection='in',
                               neighbor=data.tg1_dut1_vrf_ipv6[i])
            bgp_obj.config_bgp(dut=dut2,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut2_router_id,
                               local_as=data.dut2_as[i],
                               neighbor=data.tg1_dut2_vrf_ip[i],
                               remote_as=data.dut2_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            bgp_obj.config_bgp(dut=dut2,
                               vrf_name=data.vrf_name[i],
                               router_id=data.dut2_router_id,
                               addr_family='ipv6',
                               local_as=data.dut2_as[i],
                               neighbor=data.tg1_dut2_vrf_ipv6[i],
                               remote_as=data.dut2_tg_as[i],
                               config='yes',
                               config_type_list=['neighbor', 'activate'])
            bgp_obj.config_bgp(dut=dut2,
                               vrf_name=data.vrf_name[i],
                               local_as=data.dut2_as[i],
                               addr_family='ipv6',
                               config_type_list=["routeMap"],
                               routeMap='UseGlobal',
                               diRection='in',
                               neighbor=data.tg1_dut2_vrf_ipv6[i])
        time.sleep(2)
        '''
        for i in range(0,3):
            if not retry_api(bgp_obj.verify_bgp_summary,dut1,family='ipv4',shell="sonic",neighbor=data.tg1_dut1_vrf_ip[i], state='Established', vrf = data.vrf_name[i],delay=5,retry_count=5):
                st.log("FAIL: BGP not up")
            if not retry_api(bgp_obj.verify_bgp_summary,dut2,family='ipv6',shell="sonic",neighbor=data.tg1_dut2_vrf_ipv6[i], state='Established', vrf = data.vrf_name[i],delay=5,retry_count=5):
                st.log("FAIL: BGPv6 not up")
        '''
    elif config == 'no':
        for i in range(0, 3):
            bgp_obj.config_bgp(dut=dut1,
                               local_as=data.dut1_as[i],
                               vrf_name=data.vrf_name[i],
                               config='no',
                               removeBGP='yes',
                               config_type_list=["removeBGP"])
            bgp_obj.config_bgp(dut=dut2,
                               local_as=data.dut2_as[i],
                               vrf_name=data.vrf_name[i],
                               config='no',
                               removeBGP='yes',
                               config_type_list=["removeBGP"])
Exemple #8
0
def l3tc_vrfipv4v6_confed_bgp_config(config='yes',
                                     vrf_type='all',
                                     config_type='all'):
    """

    :param config:
    :param vrf_type:
    :param config_type:
    :return:
    """
    st.banner("{}Configuring BGP with 4-node confederation topology.".format(
        'Un' if config != 'yes' else ''))
    #Confedration topo:
    #DUT1 in sub-AS1 (AS1 = 24)
    #DUT2, DUT3, DUT 4 in sub-AS2 (AS2 = 35)
    #IBGP AS = 100
    config = 'add' if config == 'yes' else 'remove'

    leftconfed_as = 24
    rightconfed_as = 35
    iBGP_as = 100

    topo['D1_as'] = 24
    topo['D2_as'] = 35
    topo['D3_as'] = 35
    topo['D4_as'] = 35

    result = True

    if config == 'add':
        if config_type == 'ipv4' or config_type == 'all':
            #Confederation config for DUT1
            dut = topo['dut_list'][0]
            neighbor = topo['D1D2P1_neigh_ipv4']
            bgpapi.config_bgp(dut,
                              local_as=leftconfed_as,
                              config='yes',
                              conf_peers=rightconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor"],
                              neighbor=neighbor)

            #Confederation config for DUT2
            dut = topo['dut_list'][1]
            neighbor = topo['D2D3P1_neigh_ipv4']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor"],
                              neighbor=neighbor)
            bgpapi.create_bgp_neighbor(dut, rightconfed_as,
                                       topo['D2D1P1_neigh_ipv4'],
                                       leftconfed_as)

            #Confederation config for DUT3
            dut = topo['dut_list'][2]
            neighbor = topo['D3D4P1_neigh_ipv4']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor"],
                              neighbor=neighbor)
            bgpapi.create_bgp_neighbor(dut, rightconfed_as,
                                       topo['D3D2P1_neigh_ipv4'],
                                       rightconfed_as)

            #Confederation config for DUT4
            dut = topo['dut_list'][3]
            neighbor = topo['D4D3P1_neigh_ipv4']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor"],
                              neighbor=neighbor)

        if config_type == 'ipv6' or config_type == 'all':
            #Confederation config for DUT1
            dut = topo['dut_list'][0]
            neighbor = topo['D1D2P1_neigh_ipv6']
            bgpapi.config_bgp(dut,
                              local_as=leftconfed_as,
                              config='yes',
                              addr_family='ipv6',
                              conf_peers=rightconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor", "activate"],
                              neighbor=neighbor)

            #Confederation config for DUT2
            dut = topo['dut_list'][1]
            neighbor = topo['D2D3P1_neigh_ipv6']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              addr_family='ipv6',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor", "activate"],
                              neighbor=neighbor)
            bgpapi.create_bgp_neighbor(dut,
                                       rightconfed_as,
                                       topo['D2D1P1_neigh_ipv6'],
                                       leftconfed_as,
                                       family="ipv6")

            #Confederation config for DUT3
            dut = topo['dut_list'][2]
            neighbor = topo['D3D4P1_neigh_ipv6']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              addr_family='ipv6',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor", "activate"],
                              neighbor=neighbor)
            bgpapi.create_bgp_neighbor(dut,
                                       rightconfed_as,
                                       topo['D3D2P1_neigh_ipv6'],
                                       rightconfed_as,
                                       family="ipv6")

            #Confederation config for DUT4
            dut = topo['dut_list'][3]
            neighbor = topo['D4D3P1_neigh_ipv6']
            bgpapi.config_bgp(dut,
                              local_as=rightconfed_as,
                              config='yes',
                              addr_family='ipv6',
                              conf_peers=leftconfed_as,
                              conf_identf=iBGP_as,
                              remote_as=rightconfed_as,
                              config_type_list=["neighbor", "activate"],
                              neighbor=neighbor)

    else:
        bgpapi.cleanup_router_bgp(topo['dut_list'])

    return result
Exemple #9
0
def test_ft_bgp_ebgp_multihop_4byteASN():
    """

    Verify the functioning of ebgp multihop command with 4 byte ASN
    """
    # On DUT1 and DUT3, create BGP with 4byte ASN
    dut1_as = 6500001
    dut1 = topo['dut_list'][0]
    dut3_as = 6500002
    dut3 = topo['dut_list'][2]
    result = 0
    wait_timer = 150

    st.banner("Verify the ebgp multihop functionality with 4 byte AS Number")

    # Configure bgp on DUT1 and configure DUT3 as neighbor with ebgp-multihop ttl set to 5
    st.log(
        "Configure eBGP on DUT1 with Neighbor as DUT3 with multihop set to maximum hops of 5"
    )
    bgpapi.config_bgp(dut1,
                      local_as=dut1_as,
                      neighbor=topo['D3D2P1_ipv4'],
                      remote_as=dut3_as,
                      config_type_list=["neighbor", "ebgp_mhop"],
                      ebgp_mhop='5')

    # Add static route towards neighbor DUT3
    st.log("Add static route towards DUT3")
    ipapi.create_static_route(dut1, topo['D1D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D3D2P1_ipv4']))

    # Configure bgp on DUT3 and configure DUT1 as neighbor with ebgp-multihop ttl set to 5
    st.log(
        "Configure eBGP on DUT3 with DUT1 as Neighbor with multihop set to maximum hops of 5"
    )
    bgpapi.config_bgp(dut3,
                      local_as=dut3_as,
                      neighbor=topo['D1D2P1_ipv4'],
                      remote_as=dut1_as,
                      config_type_list=["neighbor", "ebgp_mhop"],
                      ebgp_mhop='5')

    # Add static route towards neighbor DUT1
    st.log("Add static route towards DUT1")
    ipapi.create_static_route(dut3, topo['D3D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D1D2P1_ipv4']))

    st.log("Verify BGP neighborship on DUT1")
    #result = bgpapi.verify_bgp_summary(dut1, family='ipv4', neighbor=topo['D3D2P1_ipv4'], state='Established')
    if not utils.poll_wait(bgpapi.verify_bgp_summary,
                           wait_timer,
                           dut1,
                           family='ipv4',
                           neighbor=topo['D3D2P1_ipv4'],
                           state='Established'):
        st.log("Failed to form BGP eBGP multihop peering with 4byte ASN")
        result += 1
    if result == 0:
        st.log("Pass: BGP neighborship established between DUT1 and DUT3")
    else:
        st.error(
            "Fail: BGP neighborship not established between DUT1 and DUT3")
        st.banner("Collecting techsupport")
        exec_all(True, [[
            st.generate_tech_support, topo['dut_list'][0],
            "test_ft_bgp_ebgp_multihop_4byteASN"
        ],
                        [
                            st.generate_tech_support, topo['dut_list'][1],
                            "test_ft_bgp_ebgp_multihop_4byteASN"
                        ],
                        [
                            st.generate_tech_support, topo['dut_list'][2],
                            "test_ft_bgp_ebgp_multihop_4byteASN"
                        ]])

    #Clear applied configs
    st.banner("Cleanup for TestFunction")
    bgpapi.cleanup_router_bgp(dut1)
    bgpapi.cleanup_router_bgp(dut3)
    ipapi.delete_static_route(dut1, topo['D1D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D3D2P1_ipv4']))
    ipapi.delete_static_route(dut3, topo['D3D2P1_neigh_ipv4'],
                              "{}/24".format(topo['D1D2P1_ipv4']))

    if result == 0:
        st.report_pass("test_case_passed")
    else:
        st.report_fail("test_case_failed")
def test_ft_l3_performance_enhancements_v4_bgp_session_failover_convergence_time(
        fixture_v4):
    ################# Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email:  [email protected]
    #################################################
    #
    # Objective - FtOpSoRtPerfFn032 : Performance measurement for BGP Session Failover case
    #  Measure time taken for the traffic ( corresponding to BGP routes ) to resume fully
    #  (i.e RX rate = TX rate) after the BGP session flaps ( i.e BGP session goes down and then comes up
    #  This is triggered using "clear ip bgp * " CLI command ).
    #
    ############### Test bed details ################
    #  TG --- DUT --- TG
    #################################################
    # Configuring traffic stream on the TG interface
    tr1 = tg.tg_traffic_config(
        port_handle=tg_handler["tg_ph_2"],
        emulation_src_handle=h2['handle'],
        emulation_dst_handle=bgp_rtr1['route'][0]['handle'],
        circuit_endpoint_type='ipv4',
        mode='create',
        transmit_mode='continuous',
        length_mode='fixed',
        rate_pps=data.traffic_rate_pps,
        enable_stream_only_gen='0')

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv4", def_v4_route_count,
                                    data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv4',
                                   neighbor=data.neigh_ip_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != int(data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Starting the TG traffic after clearing the DUT counters
    papi.clear_interface_counters(dut)
    tg.tg_traffic_control(action="run", handle=tr1['stream_id'])

    st.wait(25)

    # Verifying the BGP route count on the DUT
    if not check_intf_traffic_counters(dut, 20, "install"):
        st.report_fail("ingress_traffic_rate_not_matching_with_egress_rate")

    # Clearing the BGP session.
    st.log("Clearing the BGP session.")
    bgpfeature.clear_ip_bgp(dut)

    st.banner(
        "# Measuring Convergence time ( control plane + data plane ) taken for BGP session failover scenario on HWSKU {}"
        .format(hwsku_under_test))
    # Taking the start time timestamp
    start_time = datetime.datetime.now()
    bgpfeature.config_bgp(dut=vars.D1,
                          local_as=data.as_num,
                          config='yes',
                          neighbor=data.neigh_ip_addr,
                          config_type_list=["connect"],
                          connect='1')

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv4", def_v4_route_count,
                                    data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv4',
                                   neighbor=data.neigh_ip_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != int(data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Taking the end time timestamp
    end_time = datetime.datetime.now()

    # Time taken for route installation
    st.log("Start Time: {}".format(start_time))
    st.log("End Time: {}".format(end_time))
    time_in_secs = end_time - start_time

    st.banner(
        "Convergence time ( control plane + data plane ) taken for BGP session failover scenario (After session up, time taken for BGP to re establish, learn and install the routes to hardware) on HWSKU {} = "
        .format(hwsku_under_test) + str(time_in_secs.seconds))

    # Stopping the TG traffic
    tg.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    st.report_pass("test_case_passed")