예제 #1
0
def setup_module(mod):
    "Sets up the pytest environment"

    logger.info('\n\n---- Starting OSPF Segment Routing tests ----\n')

    tgen = Topogen(OspfSrTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_OSPF,
            os.path.join(CWD, '{}/ospfd.conf'.format(rname))
        )

    # Initialize all routers.
    tgen.start_router()

    # Verify that version, MPLS and Segment Routing are OK
    for router in router_list.values():
        # Check for Version
        if router.has_version('<', '4'):
            tgen.set_error('Unsupported FRR version')
            break
        # Check that Segment Routing is available
        output = tgen.gears[router.name].vtysh_cmd(
            "show ip ospf database segment-routing json")
        if output.find("Unknown") != -1:
            tgen.set_error('Segment Routing is not available')
예제 #2
0
def setup_module(module):
    tgen = Topogen(BGPECMPTopo1, module.__name__)
    tgen.start_topology()

    # Starting Routers
    router_list = tgen.routers()
    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP,
            os.path.join(CWD, '{}/bgpd.conf'.format(rname))
        )
        router.start()

    # Starting Hosts and init ExaBGP on each of them
    topotest.sleep(10, 'starting BGP on all {} peers'.format(total_ebgp_peers))
    peer_list = tgen.exabgp_peers()
    for pname, peer in peer_list.iteritems():
        peer_dir = os.path.join(CWD, pname)
        env_file = os.path.join(CWD, 'exabgp.env')
        peer.start(peer_dir, env_file)
        logger.info(pname)
예제 #3
0
def setup_module(module):
    tgen = Topogen(BGPVRFNETNSTopo1, module.__name__)
    tgen.start_topology()

    # Get r1 reference
    router = tgen.gears['r1']

    # check for zebra capability
    if CustomizeVrfWithNetns == True:
        if router.check_capability(
                TopoRouter.RD_ZEBRA,
                '--vrfwnetns'
                ) == False:
            return  pytest.skip('Skipping BGP VRF NETNS Test. VRF NETNS backend not available on FRR')
        if os.system('ip netns list') != 0:
            return  pytest.skip('Skipping BGP VRF NETNS Test. NETNS not available on System')
    # retrieve VRF backend kind
    if CustomizeVrfWithNetns == True:
        logger.info('Testing with VRF Namespace support')

    # create VRF r1-cust1
    # move r1-eth0 to VRF r1-cust1
    cmds = ['if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi',
            'ip netns add {0}-cust1',
            'ip link set dev {0}-eth0 netns {0}-cust1',
            'ip netns exec {0}-cust1 ifconfig {0}-eth0 up']
    for cmd in cmds:
        cmd = cmd.format('r1')
        logger.info('cmd: '+cmd);
        output = router.run(cmd.format('r1'))
        if output != None and len(output) > 0:
            logger.info('Aborting due to unexpected output: cmd="{}" output=\n{}'.format(cmd, output))
            return pytest.skip('Skipping BGP VRF NETNS Test. Unexpected output to command: '+cmd)
    #run daemons
    router.load_config(
        TopoRouter.RD_ZEBRA,
        os.path.join(CWD, '{}/zebra.conf'.format('r1')),
        '--vrfwnetns'
    )
    router.load_config(
        TopoRouter.RD_BGP,
        os.path.join(CWD, '{}/bgpd.conf'.format('r1'))
    )

    logger.info('Launching BGP and ZEBRA')
    # BGP and ZEBRA start without underlying VRF
    router.start()
    # Starting Hosts and init ExaBGP on each of them
    logger.info('starting exaBGP on peer1')
    peer_list = tgen.exabgp_peers()
    for pname, peer in peer_list.iteritems():
        peer_dir = os.path.join(CWD, pname)
        env_file = os.path.join(CWD, 'exabgp.env')
        logger.info('Running ExaBGP peer')
        peer.start(peer_dir, env_file)
        logger.info(pname)
예제 #4
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(ISISTopo1, mod.__name__)
    tgen.start_topology()

    # For all registered routers, load the zebra configuration file
    for rname, router in tgen.routers().iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_ISIS,
            os.path.join(CWD, '{}/isisd.conf'.format(rname))
        )

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()

    has_version_20 = False
    for router in tgen.routers().values():
        if router.has_version('<', '3'):
            has_version_20 = True

    if has_version_20:
        logger.info('Skipping ISIS tests for FRR 2.0')
        tgen.set_error('ISIS has convergence problems with IPv6')
예제 #5
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(TemplateTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # For all registered routers, load the zebra configuration file
    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        # Don't start ospfd and ldpd in the CE nodes
        if router.name[0] == 'r':
            router.load_config(
                TopoRouter.RD_OSPF,
                os.path.join(CWD, '{}/ospfd.conf'.format(rname))
            )
            router.load_config(
                TopoRouter.RD_LDP,
                os.path.join(CWD, '{}/ldpd.conf'.format(rname))
            )

    tgen.start_router()
    for router in router_list.values():
        if router.has_version('<', '3'):
            tgen.set_error('unsupported version')
예제 #6
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(BFDTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname)),
        )
        router.load_config(
            TopoRouter.RD_BFD,
            os.path.join(CWD, '{}/bfdd.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP,
            os.path.join(CWD, '{}/bgpd.conf'.format(rname))
        )

    # Initialize all routers.
    tgen.start_router()

    # Verify that we are using the proper version and that the BFD
    # daemon exists.
    for router in router_list.values():
        # Check for Version
        if router.has_version('<', '5.1'):
            tgen.set_error('Unsupported FRR version')
            break
예제 #7
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(OSPFTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # check for zebra capability
    for rname, router in router_list.iteritems():
        if router.check_capability(
                TopoRouter.RD_ZEBRA,
                '--vrfwnetns'
        ) == False:
            return  pytest.skip('Skipping OSPF VRF NETNS feature. VRF NETNS backend not available on FRR')

    if os.system('ip netns list') != 0:
        return  pytest.skip('Skipping OSPF VRF NETNS Test. NETNS not available on System')

    logger.info('Testing with VRF Namespace support')

    cmds = ['if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi',
            'ip netns add {0}-cust1',
            'ip link set dev {0}-eth0 netns {0}-cust1',
            'ip netns exec {0}-cust1 ifconfig {0}-eth0 up',
            'ip link set dev {0}-eth1 netns {0}-cust1',
            'ip netns exec {0}-cust1 ifconfig {0}-eth1 up']

    for rname, router in router_list.iteritems():

        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
        for cmd in cmds:
            output = tgen.net[rname].cmd(cmd.format(rname))

        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname)),
            '--vrfwnetns'
        )
        router.load_config(
            TopoRouter.RD_OSPF,
            os.path.join(CWD, '{}/ospfd.conf'.format(rname))
        )

    # Initialize all routers.
    tgen.start_router()
    for router in router_list.values():
        if router.has_version('<', '4.0'):
            tgen.set_error('unsupported version')
예제 #8
0
def setup_module(mod):
    tgen = Topogen(TemplateTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    for i, (rname, router) in enumerate(router_list.iteritems(), 1):
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP,
            os.path.join(CWD, '{}/bgpd.conf'.format(rname))
        )

    tgen.start_router()
예제 #9
0
파일: test_pim.py 프로젝트: ton31337/frr
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(PIMTopo, mod.__name__)
    tgen.start_topology()

    # For all registered routers, load the zebra configuration file
    for rname, router in tgen.routers().iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_PIM,
            os.path.join(CWD, '{}/pimd.conf'.format(rname))
        )

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(build_topo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # For all registered routers, load the zebra configuration file
    for rname, router in router_list.items():
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        # Don't start ospfd and ldpd in the CE nodes
        if router.name[0] == "r":
            router.load_config(
                TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
            )
            router.load_config(
                TopoRouter.RD_LDP, os.path.join(CWD, "{}/ldpd.conf".format(rname))
            )

    tgen.start_router()
예제 #11
0
def setup_module(mod):
    "Sets up the pytest environment"

    tgen = Topogen(build_topo, mod.__name__)
    tgen.start_topology()

    logger.info("** %s: Setup Topology" % mod.__name__)
    logger.info("******************************************")

    # For debugging after starting net, but before starting FRR,
    # uncomment the next line
    # tgen.mininet_cli()

    router_list = tgen.routers()
    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_OSPF6,
                           os.path.join(CWD, "{}/ospf6d.conf".format(rname)))

    # Initialize all routers.
    tgen.start_router()
예제 #12
0
def setup_module(mod):
    "Sets up the pytest environment"

    # skip tests is SNMP not installed
    if not os.path.isfile("/usr/sbin/snmpd"):
        error_msg = "SNMP not installed - skipping"
        pytest.skip(error_msg)

    # This function initiates the topology build with Topogen...
    tgen = Topogen(TemplateTopo, mod.__name__)
    # ... and here it calls Mininet initialization functions.
    tgen.start_topology()

    router_list = tgen.routers()

    # For all registered routers, load the zebra configuration file
    for rname, router in router_list.iteritems():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        # Don't start the following in the CE nodes
        if router.name[0] == "r":
            router.load_config(
                TopoRouter.RD_ISIS,
                os.path.join(CWD, "{}/isisd.conf".format(rname)),
                "-M snmp",
            )
            router.load_config(
                TopoRouter.RD_LDP,
                os.path.join(CWD, "{}/ldpd.conf".format(rname)),
            )
            router.load_config(
                TopoRouter.RD_SNMP,
                os.path.join(CWD, "{}/snmpd.conf".format(rname)),
                "-Le -Ivacm_conf,usmConf,iquery -V -DAgentX,trap",
            )

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()
예제 #13
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(build_topo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()
    for rname, router in router_list.items():
        daemon_file = "{}/{}/zebra.conf".format(CWD, rname)
        if os.path.isfile(daemon_file):
            router.load_config(TopoRouter.RD_ZEBRA, daemon_file)

        daemon_file = "{}/{}/bgpd.conf".format(CWD, rname)
        if os.path.isfile(daemon_file):
            router.load_config(TopoRouter.RD_BGP, daemon_file)

        daemon_file = "{}/{}/pimd.conf".format(CWD, rname)
        if os.path.isfile(daemon_file):
            router.load_config(TopoRouter.RD_PIM, daemon_file)

    # Initialize all routers.
    tgen.start_router()

    app_helper.init(tgen)
예제 #14
0
def setup_module(module):
    logger.info("PIM RP ACL Topology: \n {}".format(TOPOLOGY))

    tgen = Topogen(PIMACLTopo, module.__name__)
    tgen.start_topology()

    # Starting Routers
    router_list = tgen.routers()

    for rname, router in router_list.items():
        logger.info("Loading router %s" % rname)
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        if rname[0] != 'h':
            # Only load ospf on routers, not on end hosts
            router.load_config(
                TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
            )
            router.load_config(
                TopoRouter.RD_PIM, os.path.join(CWD, "{}/pimd.conf".format(rname))
            )
    tgen.start_router()
예제 #15
0
def setup_module(mod):
    testsuite_run_time = time.asctime(time.localtime(time.time()))
    logger.info("Testsuite start time: {}".format(testsuite_run_time))
    logger.info("=" * 40)

    logger.info("Running setup_module to create topology")

    tgen = Topogen(build_topo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    for i, (rname, router) in enumerate(router_list.items(), 1):
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
        )

    tgen.start_router()

    logger.info("Running setup_module() done")
예제 #16
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(OSPFTopo, mod.__name__)
    tgen.start_topology()

    ospf6_config = "ospf6d.conf"
    if tgen.gears["r1"].has_version("<", "4.0"):
        ospf6_config = "ospf6d.conf-pre-v4"

    router_list = tgen.routers()
    for rname, router in router_list.items():
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_OSPF6, os.path.join(CWD, "{}/{}".format(rname, ospf6_config))
        )

    # Initialize all routers.
    tgen.start_router()
예제 #17
0
def setup_module(module):
    logger.info("PIM IGMP VRF Topology: \n {}".format(TOPOLOGY))

    tgen = Topogen(build_topo, module.__name__)
    tgen.start_topology()

    vrf_setup_cmds = [
        "ip link add name blue type vrf table 11",
        "ip link add name red type vrf table 12",
        "ip link set dev blue up",
        "ip link set dev red up",
        "ip link set dev r1-eth0 vrf blue up",
        "ip link set dev r1-eth1 vrf blue up",
        "ip link set dev r1-eth2 vrf red up",
        "ip link set dev r1-eth3 vrf red up",
    ]

    # Starting Routers
    router_list = tgen.routers()

    # Create VRF on r2 first and add it's interfaces
    for cmd in vrf_setup_cmds:
        tgen.net["r1"].cmd(cmd)

    for rname, router in router_list.items():
        logger.info("Loading router %s" % rname)
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        if rname[0] != "h":
            # Only load ospf on routers, not on end hosts
            router.load_config(
                TopoRouter.RD_OSPF,
                os.path.join(CWD, "{}/ospfd.conf".format(rname)))
            router.load_config(TopoRouter.RD_PIM,
                               os.path.join(CWD, "{}/pimd.conf".format(rname)))

    tgen.start_router()
예제 #18
0
def setup_module(mod):
    "Sets up the pytest environment"
    # This function initiates the topology build with Topogen...
    tgen = Topogen(TemplateTopo, mod.__name__)
    # ... and here it calls Mininet initialization functions.
    tgen.start_topology()

    # This is a sample of configuration loading.
    router_list = tgen.routers()

    # For all registred routers, load the zebra configuration file
    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            # Uncomment next line to load configuration from ./router/zebra.conf
            #os.path.join(CWD, '{}/zebra.conf'.format(rname))
        )

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(build_topo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    logger.info("Testing with Linux VRF support and udp_l3mdev=0")
    if os.system("echo 0 > /proc/sys/net/ipv4/udp_l3mdev_accept") != 0:
        return pytest.skip(
            "Skipping BFD vrflite Topo1 Test. Linux VRF not available on System"
        )

    for rname, router in router_list.items():
        router.net.add_l3vrf("vrf1", 10)
        router.net.add_l3vrf("vrf2", 20)
        router.net.add_l3vrf("vrf3", 30)
        router.net.add_vlan(rname + "-eth0.100", rname + "-eth0", 100)
        router.net.add_vlan(rname + "-eth0.200", rname + "-eth0", 200)
        router.net.add_vlan(rname + "-eth0.300", rname + "-eth0", 300)
        router.net.attach_iface_to_l3vrf(rname + "-eth0.100", "vrf1")
        router.net.attach_iface_to_l3vrf(rname + "-eth0.200", "vrf2")
        router.net.add_loop(rname + "-loop1")
        router.net.add_loop(rname + "-loop2")
        router.net.attach_iface_to_l3vrf(rname + "-loop1", "vrf1")
        router.net.attach_iface_to_l3vrf(rname + "-loop2", "vrf2")
        router.net.attach_iface_to_l3vrf(rname + "-eth0", "vrf3")

    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_BFD,
                           os.path.join(CWD, "{}/bfdd.conf".format(rname)))

    # Initialize all routers.
    tgen.start_router()
def setup_module(mod):
    "Sets up the pytest environment"
    topodef = {
        "s1": ("rt1:eth-rt2", "rt2:eth-rt1"),
        "s2": ("rt1:eth-rt3", "rt3:eth-rt1"),
        "s3": ("rt2:eth-rt5", "rt5:eth-rt2"),
        "s4": ("rt3:eth-rt4", "rt4:eth-rt3"),
        "s5": ("rt4:eth-rt5", "rt5:eth-rt4"),
    }
    tgen = Topogen(topodef, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # For all registered routers, load the zebra configuration file
    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_BFD,
                           os.path.join(CWD, "{}/bfdd.conf".format(rname)))
        router.load_config(TopoRouter.RD_ISIS,
                           os.path.join(CWD, "{}/isisd.conf".format(rname)))

    tgen.start_router()
예제 #21
0
def setup_module(mod):
    "Sets up the pytest environment"

    # Required linux kernel version for this suite to run.
    result = required_linux_kernel_version("5.0")
    if result is not True:
        pytest.skip("Kernel requirements are not met")

    tgen = Topogen(BGPIPV6RTADVVRFTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    logger.info("Testing with VRF Lite support")

    cmds = [
        "ip link add {0}-cust1 type vrf table 1001",
        "ip link add loop1 type dummy",
        "ip link set loop1 master {0}-cust1",
        "ip link set {0}-eth0 master {0}-cust1",
    ]

    for rname, router in router_list.items():
        for cmd in cmds:
            output = tgen.net[rname].cmd(cmd.format(rname))

    for rname, router in router_list.items():
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
        )

    # Initialize all routers.
    tgen.start_router()
def setup_module(module):
    "Setup topology"
    tgen = Topogen(build_topo, module.__name__)
    tgen.start_topology()

    leaf1 = tgen.gears["leaf1"]
    leaf2 = tgen.gears["leaf2"]

    leaf1.run("brctl addbr brleaf1")
    leaf2.run("brctl addbr brleaf2")
    leaf1.run("ip link set dev brleaf1 up")
    leaf2.run("ip link set dev brleaf2 up")
    leaf1.run(
        "ip link add vxlan0 type vxlan id 42 group 239.1.1.1 dev leaf1-eth1 dstport 4789"
    )
    leaf2.run(
        "ip link add vxlan0 type vxlan id 42 group 239.1.1.1 dev leaf2-eth1 dstport 4789"
    )
    leaf1.run("brctl addif brleaf1 vxlan0")
    leaf2.run("brctl addif brleaf2 vxlan0")
    leaf1.run("ip link set up dev vxlan0")
    leaf2.run("ip link set up dev vxlan0")
    # tgen.mininet_cli()
    # This is a sample of configuration loading.
    router_list = tgen.routers()
    for rname, router in router_list.items():
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_PIM, os.path.join(CWD, "{}/pimd.conf".format(rname))
        )
    tgen.start_router()
예제 #23
0
def setup_module(module):
    tgen = Topogen(BGPECMPTopo1, module.__name__)
    tgen.start_topology()

    # Starting Routers
    router_list = tgen.routers()
    for rname, router in router_list.iteritems():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, "{}/bgpd.conf".format(rname)))
        router.start()

    # Starting Hosts and init ExaBGP on each of them
    topotest.sleep(10, "starting BGP on all {} peers".format(total_ebgp_peers))
    peer_list = tgen.exabgp_peers()
    for pname, peer in peer_list.iteritems():
        peer_dir = os.path.join(CWD, pname)
        env_file = os.path.join(CWD, "exabgp.env")
        peer.start(peer_dir, env_file)
        logger.info(pname)
예제 #24
0
def setup_module(mod):
    """
    Sets up the pytest environment.

    * `mod`: module name
    """
    global NEXT_HOPS, INTF_LIST_R3, INTF_LIST_R2, TEST_STATIC
    global ADDR_TYPES

    # Required linux kernel version for this suite to run.
    result = required_linux_kernel_version("4.15")
    if result is not True:
        pytest.skip("Kernel requirements are not met")

    testsuite_run_time = time.asctime(time.localtime(time.time()))
    logger.info("Testsuite start time: {}".format(testsuite_run_time))
    logger.info("=" * 40)

    logger.info("Running setup_module to create topology")

    # This function initiates the topology build with Topogen...
    tgen = Topogen(CreateTopo, mod.__name__)

    # Starting topology, create tmp files which are loaded to routers
    #  to start deamons and then start routers
    start_topology(tgen)

    # Creating configuration from JSON
    build_config_from_json(tgen, topo)

    # Don't run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    # tgen.mininet_cli()
    # Api call verify whether BGP is converged
    ADDR_TYPES = check_address_types()

    for addr_type in ADDR_TYPES:
        BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
        assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error:" " {}".format(
            BGP_CONVERGENCE)

    link_data = [
        val for links, val in topo["routers"]["r2"]["links"].items()
        if "r3" in links
    ]
    for adt in ADDR_TYPES:
        NEXT_HOPS[adt] = [val[adt].split("/")[0] for val in link_data]
        if adt == "ipv4":
            NEXT_HOPS[adt] = sorted(NEXT_HOPS[adt],
                                    key=lambda x: int(x.split(".")[2]))
        elif adt == "ipv6":
            NEXT_HOPS[adt] = sorted(NEXT_HOPS[adt],
                                    key=lambda x: int(x.split(":")[-3], 16))

    INTF_LIST_R2 = [val["interface"].split("/")[0] for val in link_data]
    INTF_LIST_R2 = sorted(INTF_LIST_R2, key=lambda x: int(x.split("eth")[1]))

    link_data = [
        val for links, val in topo["routers"]["r3"]["links"].items()
        if "r2" in links
    ]
    INTF_LIST_R3 = [val["interface"].split("/")[0] for val in link_data]
    INTF_LIST_R3 = sorted(INTF_LIST_R3, key=lambda x: int(x.split("eth")[1]))

    # STATIC_ROUTE = True
    logger.info("Running setup_module() done")
예제 #25
0
def setup_module(mod):
    "Sets up the pytest environment"
    global l3mdev_accept
    global krel

    tgen = Topogen(BGPEVPNTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    krel = platform.release()
    if topotest.version_cmp(krel, '4.18') < 0:
        logger.info(
            'BGP EVPN RT5 NETNS tests will not run (have kernel "{}", but it requires 4.18)'
            .format(krel))
        return pytest.skip(
            'Skipping BGP EVPN RT5 NETNS Test. Kernel not supported')

    l3mdev_accept = 1
    logger.info('setting net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept))

    # create VRF vrf-101 on R1 and R2
    # create loop101
    cmds_vrflite = [
        'sysctl -w net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept),
        'ip link add {}-vrf-101 type vrf table 101',
        'ip ru add oif {}-vrf-101 table 101',
        'ip ru add iif {}-vrf-101 table 101', 'ip link set dev {}-vrf-101 up',
        'sysctl -w net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept),
        'ip link add loop101 type dummy',
        'ip link set dev loop101 master {}-vrf-101',
        'ip link set dev loop101 up'
    ]
    cmds_netns = [
        'ip netns add {}-vrf-101', 'ip link add loop101 type dummy',
        'ip link set dev loop101 netns {}-vrf-101',
        'ip netns exec {}-vrf-101 ip link set dev loop101 up'
    ]

    cmds_r2 = [  # config routing 101
        'ip link add name bridge-101 up type bridge stp_state 0',
        'ip link set bridge-101 master {}-vrf-101',
        'ip link set dev bridge-101 up',
        'ip link add name vxlan-101 type vxlan id 101 dstport 4789 dev r2-eth0 local 192.168.100.41',
        'ip link set dev vxlan-101 master bridge-101',
        'ip link set vxlan-101 up type bridge_slave learning off flood off mcast_flood off'
    ]

    cmds_r1_netns_method3 = [
        'ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21',
        'ip link set dev vxlan-{1} netns {0}-vrf-{1}',
        'ip netns exec {0}-vrf-{1} ip li set dev lo up',
        'ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0',
        'ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}',
        'ip netns exec {0}-vrf-{1} ip link set bridge-{1} up',
        'ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up'
    ]

    router = tgen.gears['r1']
    for cmd in cmds_netns:
        logger.info('cmd to r1: ' + cmd)
        output = router.run(cmd.format('r1'))
        logger.info('result: ' + output)

    router = tgen.gears['r2']
    for cmd in cmds_vrflite:
        logger.info('cmd to r2: ' + cmd.format('r2'))
        output = router.run(cmd.format('r2'))
        logger.info('result: ' + output)

    for cmd in cmds_r2:
        logger.info('cmd to r2: ' + cmd.format('r2'))
        output = router.run(cmd.format('r2'))
        logger.info('result: ' + output)

    router = tgen.gears['r1']
    bridge_id = '101'
    for cmd in cmds_r1_netns_method3:
        logger.info('cmd to r1: ' + cmd.format('r1', bridge_id))
        output = router.run(cmd.format('r1', bridge_id))
        logger.info('result: ' + output)
    router = tgen.gears['r1']

    for rname, router in router_list.iteritems():
        if rname == 'r1':
            router.load_config(
                TopoRouter.RD_ZEBRA,
                os.path.join(CWD, '{}/zebra.conf'.format(rname)),
                '--vrfwnetns -o vrf0')
        else:
            router.load_config(
                TopoRouter.RD_ZEBRA,
                os.path.join(CWD, '{}/zebra.conf'.format(rname)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, '{}/bgpd.conf'.format(rname)))

    # Initialize all routers.
    tgen.start_router()
예제 #26
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(BFDTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # check for zebra capability
    for rname, router in router_list.iteritems():
        if router.check_capability(
                TopoRouter.RD_ZEBRA,
                '--vrfwnetns'
        ) == False:
            return  pytest.skip('Skipping BFD Topo1 VRF NETNS feature. VRF NETNS backend not available on FRR')

    if os.system('ip netns list') != 0:
        return  pytest.skip('Skipping BFD Topo1 VRF NETNS Test. NETNS not available on System')

    logger.info('Testing with VRF Namespace support')

    cmds = ['if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi',
            'ip netns add {0}-cust1',
            'ip link set dev {0}-eth0 netns {0}-cust1',
            'ip netns exec {0}-cust1 ifconfig {0}-eth0 up']
    cmds2 = ['ip link set dev {0}-eth1 netns {0}-cust1',
             'ip netns exec {0}-cust1 ifconfig {0}-eth1 up',
             'ip link set dev {0}-eth2 netns {0}-cust1',
             'ip netns exec {0}-cust1 ifconfig {0}-eth2 up']

    for rname, router in router_list.iteritems():
        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
        for cmd in cmds:
            output = tgen.net[rname].cmd(cmd.format(rname))
        if rname == 'r2':
            for cmd in cmds2:
                output = tgen.net[rname].cmd(cmd.format(rname))

    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname)),
            '--vrfwnetns'
        )
        router.load_config(
            TopoRouter.RD_BFD,
            os.path.join(CWD, '{}/bfdd.conf'.format(rname))
        )
        router.load_config(
            TopoRouter.RD_BGP,
            os.path.join(CWD, '{}/bgpd.conf'.format(rname))
        )

    # Initialize all routers.
    tgen.start_router()

    # Verify that we are using the proper version and that the BFD
    # daemon exists.
    for router in router_list.values():
        # Check for Version
        if router.has_version('<', '5.1'):
            tgen.set_error('Unsupported FRR version')
            break
예제 #27
0
def setup_module(mod):
    "Sets up the pytest environment"

    testsuite_run_time = time.asctime(time.localtime(time.time()))
    logger.info("Testsuite start time: {}".format(testsuite_run_time))
    logger.info("=" * 40)

    logger.info("Running setup_module to create topology")

    # This function initiates the topology build with Topogen...
    tgen = Topogen(TemplateTopo, mod.__name__)
    # ... and here it calls Mininet initialization functions.

    kernelv = platform.release()
    if topotest.version_cmp(kernelv, "4.15") < 0:
        logger.info(
            "For EVPN, kernel version should be minimum 4.15. Kernel present {}"
            .format(kernelv))
        return

    if topotest.version_cmp(kernelv, '4.15') == 0:
        l3mdev_accept = 1
        logger.info(
            'setting net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept))
    else:
        l3mdev_accept = 0

    # Starting topology, create tmp files which are loaded to routers
    #  to start deamons and then start routers
    tgen.start_topology()

    # Configure MAC address for hosts as these MACs are advertised with EVPN type-2 routes
    for (name, host) in tgen.gears.items():
        if name not in HOSTS:
            continue

        host_mac = "1a:2b:3c:4d:5e:6{}".format(HOST_SUFFIX[name])
        host.run("ip link set dev {}-eth0 down").format(name)
        host.run("ip link set dev {0}-eth0 address {1}".format(name, host_mac))
        host.run("ip link set dev {}-eth0 up").format(name)

    # Configure PE VxLAN and Bridge interfaces
    for (name, pe) in tgen.gears.items():
        if name not in PES:
            continue
        vtep_ip = "10.100.0.{}".format(PE_SUFFIX[name])
        bridge_ip = "50.0.1.{}/24".format(PE_SUFFIX[name])
        bridge_ipv6 = "50:0:1::{}/48".format(PE_SUFFIX[name])

        pe.run("ip link add vrf-blue type vrf table 10")
        pe.run("ip link set dev vrf-blue up")
        pe.run("ip link add vxlan100 type vxlan id 100 dstport 4789 local {}".
               format(vtep_ip))
        pe.run("ip link add name br100 type bridge stp_state 0")
        pe.run("ip link set dev vxlan100 master br100")
        pe.run("ip link set dev {}-eth1 master br100".format(name))
        pe.run("ip addr add {} dev br100".format(bridge_ip))
        pe.run("ip link set up dev br100")
        pe.run("ip link set up dev vxlan100")
        pe.run("ip link set up dev {}-eth1".format(name))
        pe.run("ip link set dev br100 master vrf-blue")
        pe.run("ip -6 addr add {} dev br100".format(bridge_ipv6))

        pe.run(
            "ip link add vxlan1000 type vxlan id 1000 dstport 4789 local {}".
            format(vtep_ip))
        pe.run("ip link add name br1000 type bridge stp_state 0")
        pe.run("ip link set dev vxlan1000 master br100")
        pe.run("ip link set up dev br1000")
        pe.run("ip link set up dev vxlan1000")
        pe.run("ip link set dev br1000 master vrf-blue")

        pe.run("sysctl -w net.ipv4.ip_forward=1")
        pe.run("sysctl -w net.ipv6.conf.all.forwarding=1")
        pe.run("sysctl -w net.ipv4.udp_l3mdev_accept={}".format(l3mdev_accept))
        pe.run("sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept))

    # For all registred routers, load the zebra configuration file
    for (name, router) in tgen.routers().items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(name)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, "{}/bgpd.conf".format(name)))

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()

    logger.info("Running setup_module() done")
    topotest.sleep(200)
def setup_module(module):
    tgen = Topogen(BGPVRFNETNSTopo1, module.__name__)
    tgen.start_topology()

    # Get r1 reference
    router = tgen.gears["r1"]

    # check for zebra capability
    if CustomizeVrfWithNetns == True:
        if router.check_capability(TopoRouter.RD_ZEBRA,
                                   "--vrfwnetns") == False:
            return pytest.skip(
                "Skipping BGP VRF NETNS Test. VRF NETNS backend not available on FRR"
            )
        if os.system("ip netns list") != 0:
            return pytest.skip(
                "Skipping BGP VRF NETNS Test. NETNS not available on System")
    # retrieve VRF backend kind
    if CustomizeVrfWithNetns == True:
        logger.info("Testing with VRF Namespace support")

    # create VRF r1-cust1
    # move r1-eth0 to VRF r1-cust1
    cmds = [
        "if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi",
        "ip netns add {0}-cust1",
        "ip link set dev {0}-eth0 netns {0}-cust1",
        "ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
    ]
    for cmd in cmds:
        cmd = cmd.format("r1")
        logger.info("cmd: " + cmd)
        output = router.run(cmd.format("r1"))
        if output != None and len(output) > 0:
            logger.info(
                'Aborting due to unexpected output: cmd="{}" output=\n{}'.
                format(cmd, output))
            return pytest.skip(
                "Skipping BGP VRF NETNS Test. Unexpected output to command: " +
                cmd)
    # run daemons
    router.load_config(
        TopoRouter.RD_ZEBRA,
        os.path.join(CWD, "{}/zebra.conf".format("r1")),
        "--vrfwnetns",
    )
    router.load_config(TopoRouter.RD_BGP,
                       os.path.join(CWD, "{}/bgpd.conf".format("r1")))

    logger.info("Launching BGP and ZEBRA")
    # BGP and ZEBRA start without underlying VRF
    router.start()
    # Starting Hosts and init ExaBGP on each of them
    logger.info("starting exaBGP on peer1")
    peer_list = tgen.exabgp_peers()
    for pname, peer in peer_list.iteritems():
        peer_dir = os.path.join(CWD, pname)
        env_file = os.path.join(CWD, "exabgp.env")
        logger.info("Running ExaBGP peer")
        peer.start(peer_dir, env_file)
        logger.info(pname)
예제 #29
0
def setup_module(mod):
    "Sets up the pytest environment"
    # This function initiates the topology build with Topogen...
    tgen = Topogen(build_topo, mod.__name__)
    # ... and here it calls Mininet initialization functions.
    tgen.start_topology()

    r1 = tgen.gears["R1"]
    r2 = tgen.gears["R2"]
    r3 = tgen.gears["R3"]

    # blue vrf
    r1.cmd_raises("ip link add blue type vrf table 1001")
    r1.cmd_raises("ip link set up dev blue")
    r2.cmd_raises("ip link add blue type vrf table 1001")
    r2.cmd_raises("ip link set up dev blue")
    r3.cmd_raises("ip link add blue type vrf table 1001")
    r3.cmd_raises("ip link set up dev blue")

    r1.cmd_raises("ip link add lo1 type dummy")
    r1.cmd_raises("ip link set lo1 master blue")
    r1.cmd_raises("ip link set up dev lo1")
    r2.cmd_raises("ip link add lo1 type dummy")
    r2.cmd_raises("ip link set up dev lo1")
    r2.cmd_raises("ip link set lo1 master blue")
    r3.cmd_raises("ip link add lo1 type dummy")
    r3.cmd_raises("ip link set up dev lo1")
    r3.cmd_raises("ip link set lo1 master blue")

    r1.cmd_raises("ip link set R1-eth2 master blue")
    r1.cmd_raises("ip link set R1-eth3 master blue")
    r2.cmd_raises("ip link set R2-eth2 master blue")
    r2.cmd_raises("ip link set R2-eth3 master blue")
    r3.cmd_raises("ip link set R3-eth2 master blue")
    r3.cmd_raises("ip link set R3-eth3 master blue")

    r1.cmd_raises("ip link set up dev  R1-eth2")
    r1.cmd_raises("ip link set up dev  R1-eth3")
    r2.cmd_raises("ip link set up dev  R2-eth2")
    r2.cmd_raises("ip link set up dev  R2-eth3")
    r3.cmd_raises("ip link set up dev  R3-eth2")
    r3.cmd_raises("ip link set up dev  R3-eth3")

    # red vrf
    r1.cmd_raises("ip link add red type vrf table 1002")
    r1.cmd_raises("ip link set up dev red")
    r2.cmd_raises("ip link add red type vrf table 1002")
    r2.cmd_raises("ip link set up dev red")
    r3.cmd_raises("ip link add red type vrf table 1002")
    r3.cmd_raises("ip link set up dev red")

    r1.cmd_raises("ip link add lo2 type dummy")
    r1.cmd_raises("ip link set lo2 master red")
    r1.cmd_raises("ip link set up dev lo2")
    r2.cmd_raises("ip link add lo2 type dummy")
    r2.cmd_raises("ip link set up dev lo2")
    r2.cmd_raises("ip link set lo2 master red")
    r3.cmd_raises("ip link add lo2 type dummy")
    r3.cmd_raises("ip link set up dev lo2")
    r3.cmd_raises("ip link set lo2 master red")

    r1.cmd_raises("ip link set R1-eth4 master red")
    r1.cmd_raises("ip link set R1-eth5 master red")
    r2.cmd_raises("ip link set R2-eth4 master red")
    r2.cmd_raises("ip link set R2-eth5 master red")
    r3.cmd_raises("ip link set R3-eth4 master red")
    r3.cmd_raises("ip link set R3-eth5 master red")

    r1.cmd_raises("ip link set up dev  R1-eth4")
    r1.cmd_raises("ip link set up dev  R1-eth5")
    r2.cmd_raises("ip link set up dev  R2-eth4")
    r2.cmd_raises("ip link set up dev  R2-eth5")
    r3.cmd_raises("ip link set up dev  R3-eth4")
    r3.cmd_raises("ip link set up dev  R3-eth5")

    # This is a sample of configuration loading.
    router_list = tgen.routers()

    # For all registred routers, load the zebra configuration file
    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA, "zebra.conf")
        router.load_config(TopoRouter.RD_OSPF)
        router.load_config(TopoRouter.RD_BGP)

    # After copying the configurations, this function loads configured daemons.
    tgen.start_router()

    # Save the initial router config. reset_config_on_routers will return to this config.
    save_initial_config_on_routers(tgen)
예제 #30
0
def setup_module(mod):
    "Sets up the pytest environment"

    logger.info("\n\n---- Starting OSPF Segment Routing tests ----\n")

    tgen = Topogen(OspfSrTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
        )
        router.load_config(
            TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
        )

    # Initialize all routers.
    tgen.start_router()

    # Verify that version, MPLS and Segment Routing are OK
    for router in router_list.values():
        # Check for Version
        if router.has_version("<", "4"):
            tgen.set_error("Unsupported FRR version")
            break
        # Check that Segment Routing is available
        output = tgen.gears[router.name].vtysh_cmd(
            "show ip ospf database segment-routing json"
        )
        if output.find("Unknown") != -1:
            tgen.set_error("Segment Routing is not available")
예제 #31
0
def setup_module(mod):
    "Sets up the pytest environment"

    tgen = Topogen(BGPEVPNTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    krel = platform.release()
    if topotest.version_cmp(krel, "4.18") < 0:
        logger.info(
            'BGP EVPN RT5 NETNS tests will not run (have kernel "{}", but it requires 4.18)'
            .format(krel))
        return pytest.skip(
            "Skipping BGP EVPN RT5 NETNS Test. Kernel not supported")

    # create VRF vrf-101 on R1 and R2
    # create loop101
    cmds_vrflite = [
        "ip link add {}-vrf-101 type vrf table 101",
        "ip ru add oif {}-vrf-101 table 101",
        "ip ru add iif {}-vrf-101 table 101",
        "ip link set dev {}-vrf-101 up",
        "ip link add loop101 type dummy",
        "ip link set dev loop101 master {}-vrf-101",
        "ip link set dev loop101 up",
    ]
    cmds_netns = [
        "ip netns add {}-vrf-101",
        "ip link add loop101 type dummy",
        "ip link set dev loop101 netns {}-vrf-101",
        "ip netns exec {}-vrf-101 ip link set dev loop101 up",
    ]

    cmds_r2 = [  # config routing 101
        "ip link add name bridge-101 up type bridge stp_state 0",
        "ip link set bridge-101 master {}-vrf-101",
        "ip link set dev bridge-101 up",
        "ip link add name vxlan-101 type vxlan id 101 dstport 4789 dev r2-eth0 local 192.168.100.41",
        "ip link set dev vxlan-101 master bridge-101",
        "ip link set vxlan-101 up type bridge_slave learning off flood off mcast_flood off",
    ]

    cmds_r1_netns_method3 = [
        "ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21",
        "ip link set dev vxlan-{1} netns {0}-vrf-{1}",
        "ip netns exec {0}-vrf-{1} ip li set dev lo up",
        "ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0",
        "ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}",
        "ip netns exec {0}-vrf-{1} ip link set bridge-{1} up",
        "ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up",
    ]

    router = tgen.gears["r1"]
    for cmd in cmds_netns:
        logger.info("cmd to r1: " + cmd)
        output = router.run(cmd.format("r1"))
        logger.info("result: " + output)

    router = tgen.gears["r2"]
    for cmd in cmds_vrflite:
        logger.info("cmd to r2: " + cmd.format("r2"))
        output = router.run(cmd.format("r2"))
        logger.info("result: " + output)

    for cmd in cmds_r2:
        logger.info("cmd to r2: " + cmd.format("r2"))
        output = router.run(cmd.format("r2"))
        logger.info("result: " + output)

    router = tgen.gears["r1"]
    bridge_id = "101"
    for cmd in cmds_r1_netns_method3:
        logger.info("cmd to r1: " + cmd.format("r1", bridge_id))
        output = router.run(cmd.format("r1", bridge_id))
        logger.info("result: " + output)
    router = tgen.gears["r1"]

    for rname, router in router_list.items():
        if rname == "r1":
            router.load_config(
                TopoRouter.RD_ZEBRA,
                os.path.join(CWD, "{}/zebra.conf".format(rname)),
                "--vrfwnetns -o vrf0",
            )
        else:
            router.load_config(
                TopoRouter.RD_ZEBRA,
                os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, "{}/bgpd.conf".format(rname)))

    # Initialize all routers.
    tgen.start_router()
예제 #32
0
def setup_module(mod):
    "Sets up the pytest environment"
    # This function initiates the topology build with Topogen...
    tgen = Topogen(TemplateTopo, mod.__name__)
    # ... and here it calls Mininet initialization functions.
    tgen.start_topology()

    r1 = tgen.gears["R1"]
    r2 = tgen.gears["R2"]
    r3 = tgen.gears["R3"]

    # blue vrf
    r1.run("ip link add blue type vrf table 1001")
    r1.run("ip link set up dev blue")
    r2.run("ip link add blue type vrf table 1001")
    r2.run("ip link set up dev blue")
    r3.run("ip link add blue type vrf table 1001")
    r3.run("ip link set up dev blue")

    r1.run("ip link add lo1 type dummy")
    r1.run("ip link set lo1 master blue")
    r1.run("ip link set up dev lo1")
    r2.run("ip link add lo1 type dummy")
    r2.run("ip link set up dev lo1")
    r2.run("ip link set lo1 master blue")
    r3.run("ip link add lo1 type dummy")
    r3.run("ip link set up dev lo1")
    r3.run("ip link set lo1 master blue")

    r1.run("ip link set R1-eth2 master blue")
    r1.run("ip link set R1-eth3 master blue")
    r2.run("ip link set R2-eth2 master blue")
    r2.run("ip link set R2-eth3 master blue")
    r3.run("ip link set R3-eth2 master blue")
    r3.run("ip link set R3-eth3 master blue")

    r1.run("ip link set up dev  R1-eth2")
    r1.run("ip link set up dev  R1-eth3")
    r2.run("ip link set up dev  R2-eth2")
    r2.run("ip link set up dev  R2-eth3")
    r3.run("ip link set up dev  R3-eth2")
    r3.run("ip link set up dev  R3-eth3")

    # red vrf
    r1.run("ip link add red type vrf table 1002")
    r1.run("ip link set up dev red")
    r2.run("ip link add red type vrf table 1002")
    r2.run("ip link set up dev red")
    r3.run("ip link add red type vrf table 1002")
    r3.run("ip link set up dev red")

    r1.run("ip link add lo2 type dummy")
    r1.run("ip link set lo2 master red")
    r1.run("ip link set up dev lo2")
    r2.run("ip link add lo2 type dummy")
    r2.run("ip link set up dev lo2")
    r2.run("ip link set lo2 master red")
    r3.run("ip link add lo2 type dummy")
    r3.run("ip link set up dev lo2")
    r3.run("ip link set lo2 master red")

    r1.run("ip link set R1-eth4 master red")
    r1.run("ip link set R1-eth5 master red")
    r2.run("ip link set R2-eth4 master red")
    r2.run("ip link set R2-eth5 master red")
    r3.run("ip link set R3-eth4 master red")
    r3.run("ip link set R3-eth5 master red")

    r1.run("ip link set up dev  R1-eth4")
    r1.run("ip link set up dev  R1-eth5")
    r2.run("ip link set up dev  R2-eth4")
    r2.run("ip link set up dev  R2-eth5")
    r3.run("ip link set up dev  R3-eth4")
    r3.run("ip link set up dev  R3-eth5")

    # This is a sample of configuration loading.
    router_list = tgen.routers()

    # For all registred routers, load the zebra configuration file
    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_OSPF,
                           os.path.join(CWD, "{}/ospfd.conf".format(rname)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, "{}/bgpd.conf".format(rname)))

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()
예제 #33
0
def setup_module(mod):
    "pytest environment setup"

    tgen = Topogen(NetworkTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # Load router configuration

    ldp_id = 1
    bgp_id = 101
    lm_sock = '../lm/label_mgr.sock'

    for rname, router in router_list.iteritems():
        if rname == 'lm' :
            router.load_config(
                TopoRouter.RD_ZEBRA,
                os.path.join(CWD, '{}/zebra.conf'.format(rname)),
                '-z ' + lm_sock
            )
            continue

	rtype = ''.join([i for i in rname if not i.isdigit()])

        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, '{}/zebra.conf'.format(rname)),
            '-l ' + lm_sock
        )

        if router.check_capability(TopoRouter.RD_ZEBRA, '--vrfwnetns') == False:
            return pytest.skip('Skipping test: no VRF support')

        if rtype == 'ce' or rtype == 'pe':
            if router.check_capability(TopoRouter.RD_BGP, '--int_num') == False:
                return pytest.skip('Skipping test: no BGP LM support')
            router.load_config(
                TopoRouter.RD_BGP,
                os.path.join(CWD, '{}/bgpd.conf'.format(rname)),
                '-I %d' % bgp_id
            )
            bgp_id += 1

	if rtype == 'pe' or rtype == 'p':
            router.load_config(
                TopoRouter.RD_OSPF,
                os.path.join(CWD, '{}/ospfd.conf'.format(rname))
            )
            router.load_config(
                TopoRouter.RD_LDP,
                os.path.join(CWD, '{}/ldpd.conf'.format(rname)),
                '-n %d' % ldp_id
            )
            ldp_id += 1

    # Prepare VRF's

    router = tgen.gears['pe1']
    out = router.run('ip -h 2>&1 | grep vrf | wc -l')
    if int(out) == 0:
        return pytest.skip('Skipping test: ip/iproute2 has no VRF support')

    vrf_setup(tgen.gears['pe1'], 'pe1-eth0', vrf_name, '1')
    vrf_setup(tgen.gears['pe2'], 'pe2-eth0', vrf_name, '1')

    # Start routers

    tgen.start_router(tgen.gears['lm'])
    for rname, router in router_list.iteritems():
        if rname != 'lm':
            tgen.start_router(router)
예제 #34
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(ISISTopo1, mod.__name__)
    tgen.start_topology()

    logger.info("Testing with VRF Lite support")
    krel = platform.release()

    # May need to adjust handling of vrf traffic depending on kernel version
    l3mdev_accept = 0
    if (topotest.version_cmp(krel, "4.15") >= 0
            and topotest.version_cmp(krel, "4.18") <= 0):
        l3mdev_accept = 1

    if topotest.version_cmp(krel, "5.0") >= 0:
        l3mdev_accept = 1

    logger.info("krel '{0}' setting net.ipv4.tcp_l3mdev_accept={1}".format(
        krel, l3mdev_accept))

    cmds = [
        "ip link add {0}-cust1 type vrf table 1001",
        "ip link add loop1 type dummy",
        "ip link set {0}-eth0 master {0}-cust1",
        "ip link set {0}-eth1 master {0}-cust1",
    ]

    # For all registered routers, load the zebra configuration file
    for rname, router in tgen.routers().items():
        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
        for cmd in cmds:
            output = tgen.net[rname].cmd(cmd.format(rname))
        output = tgen.net[rname].cmd("sysctl -n net.ipv4.tcp_l3mdev_accept")
        logger.info("router {0}: existing tcp_l3mdev_accept was {1}".format(
            rname, output))

        if l3mdev_accept:
            output = tgen.net[rname].cmd(
                "sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(
                    l3mdev_accept))

    for rname, router in tgen.routers().items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_ISIS,
                           os.path.join(CWD, "{}/isisd.conf".format(rname)))
    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()

    has_version_20 = False
    for router in tgen.routers().values():
        if router.has_version("<", "4"):
            has_version_20 = True

    if has_version_20:
        logger.info("Skipping ISIS vrf tests for FRR 2.0")
        tgen.set_error("ISIS has convergence problems with IPv6")
예제 #35
0
def setup_module(mod):
    "Sets up the pytest environment"

    # skip tests is SNMP not installed
    snmpd = os.system("which snmpd")
    if snmpd:
        error_msg = "SNMP not installed - skipping"
        pytest.skip(error_msg)

    # This function initiates the topology build with Topogen...
    tgen = Topogen(TemplateTopo, mod.__name__)
    # ... and here it calls Mininet initialization functions.
    tgen.start_topology()

    r1 = tgen.gears["r1"]
    r2 = tgen.gears["r2"]
    r3 = tgen.gears["r3"]
    r4 = tgen.gears["r4"]

    # setup VRF-a in r1
    r1.run("ip link add VRF-a type vrf table 1001")
    r1.run("ip link set up dev VRF-a")
    r1.run("ip link add VRF-b type vrf table 1002")
    r1.run("ip link set up dev VRF-b")
    r4.run("ip link add VRF-a type vrf table 1001")
    r4.run("ip link set up dev VRF-a")

    # enslave vrf interfaces
    r1.run("ip link set r1-eth3 master VRF-a")
    r1.run("ip link set r1-eth4 master VRF-a")
    r1.run("ip link set r1-eth5 master VRF-b")
    r4.run("ip link set r4-eth1 master VRF-a")

    r1.run("sysctl -w net.ipv4.ip_forward=1")
    r2.run("sysctl -w net.ipv4.ip_forward=1")
    r3.run("sysctl -w net.ipv4.ip_forward=1")
    r4.run("sysctl -w net.ipv4.ip_forward=1")
    r1.run("sysctl -w net.mpls.conf.r1-eth0.input=1")
    r1.run("sysctl -w net.mpls.conf.r1-eth1.input=1")
    r1.run("sysctl -w net.mpls.conf.r1-eth2.input=1")
    r2.run("sysctl -w net.mpls.conf.r1-eth0.input=1")
    r2.run("sysctl -w net.mpls.conf.r1-eth1.input=1")
    r3.run("sysctl -w net.mpls.conf.r1-eth0.input=1")
    r3.run("sysctl -w net.mpls.conf.r1-eth1.input=1")
    r3.run("sysctl -w net.mpls.conf.r1-eth2.input=1")
    r4.run("sysctl -w net.mpls.conf.r1-eth0.input=1")
    r4.run("sysctl -w net.mpls.conf.r1-eth1.input=1")

    router_list = tgen.routers()

    # For all registred routers, load the zebra configuration file
    for rname, router in router_list.items():
        router.load_config(TopoRouter.RD_ZEBRA,
                           os.path.join(CWD, "{}/zebra.conf".format(rname)))
        router.load_config(TopoRouter.RD_ISIS,
                           os.path.join(CWD, "{}/isisd.conf".format(rname)))
        router.load_config(
            TopoRouter.RD_BGP,
            os.path.join(CWD, "{}/bgpd.conf".format(rname)),
            "-M snmp",
        )
        router.load_config(
            TopoRouter.RD_SNMP,
            os.path.join(CWD, "{}/snmpd.conf".format(rname)),
            "-Le -Ivacm_conf,usmConf,iquery -V -DAgentX,trap",
        )

    # After loading the configurations, this function loads configured daemons.
    tgen.start_router()
예제 #36
0
def setup_module(mod):
    "Sets up the pytest environment"
    tgen = Topogen(BFDTopo, mod.__name__)
    tgen.start_topology()

    router_list = tgen.routers()

    # check for zebra capability
    for rname, router in router_list.iteritems():
        if router.check_capability(TopoRouter.RD_ZEBRA,
                                   "--vrfwnetns") == False:
            return pytest.skip(
                "Skipping BFD Topo1 VRF NETNS feature. VRF NETNS backend not available on FRR"
            )

    if os.system("ip netns list") != 0:
        return pytest.skip(
            "Skipping BFD Topo1 VRF NETNS Test. NETNS not available on System")

    logger.info("Testing with VRF Namespace support")

    cmds = [
        "if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi",
        "ip netns add {0}-cust1",
        "ip link set dev {0}-eth0 netns {0}-cust1",
        "ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
    ]
    cmds2 = [
        "ip link set dev {0}-eth1 netns {0}-cust1",
        "ip netns exec {0}-cust1 ifconfig {0}-eth1 up",
        "ip link set dev {0}-eth2 netns {0}-cust1",
        "ip netns exec {0}-cust1 ifconfig {0}-eth2 up",
    ]

    for rname, router in router_list.iteritems():
        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
        for cmd in cmds:
            output = tgen.net[rname].cmd(cmd.format(rname))
        if rname == "r2":
            for cmd in cmds2:
                output = tgen.net[rname].cmd(cmd.format(rname))

    for rname, router in router_list.iteritems():
        router.load_config(
            TopoRouter.RD_ZEBRA,
            os.path.join(CWD, "{}/zebra.conf".format(rname)),
            "--vrfwnetns",
        )
        router.load_config(TopoRouter.RD_BFD,
                           os.path.join(CWD, "{}/bfdd.conf".format(rname)))
        router.load_config(TopoRouter.RD_BGP,
                           os.path.join(CWD, "{}/bgpd.conf".format(rname)))

    # Initialize all routers.
    tgen.start_router()

    # Verify that we are using the proper version and that the BFD
    # daemon exists.
    for router in router_list.values():
        # Check for Version
        if router.has_version("<", "5.1"):
            tgen.set_error("Unsupported FRR version")
            break