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(): 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))) # What is this? OSPF Unnumbered depends on the rp_filter # being set appropriately( HA! ) # Effectively we are putting different /32's on the interface # the multicast packet delivery is somewhat controlled by # the rp_filter. Setting it to '0' allows the OS to pass # up the mcast packet not destined for the local routers # network. topotest.sysctl_assure(tgen.net["r1"], "net.ipv4.conf.r1-eth1.rp_filter", 0) topotest.sysctl_assure(tgen.net["r1"], "net.ipv4.conf.all.rp_filter", 0) topotest.sysctl_assure(tgen.net["r2"], "net.ipv4.conf.r2-eth1.rp_filter", 0) topotest.sysctl_assure(tgen.net["r2"], "net.ipv4.conf.all.rp_filter", 0) # Initialize all routers. tgen.start_router()
def start(self): """ Start router: * Load modules * Clean up files * Configure interfaces * Start daemons (e.g. FRR) * Configure daemon logging files """ nrouter = self.net result = nrouter.startRouter(self.tgen) # Enable command logging # Enable all daemon command logging, logging files # and set them to the start dir. for daemon, enabled in nrouter.daemons.items(): if enabled and daemon != "snmpd": self.vtysh_cmd( "\n".join([ "clear log cmdline-targets", "conf t", "log file {}.log debug".format(daemon), "log commands", "log timestamp precision 3", ]), daemon=daemon, ) if result != "": self.tgen.set_error(result) elif nrouter.daemons["ldpd"] == 1 or nrouter.daemons["pathd"] == 1: # Enable MPLS processing on all interfaces. for interface in self.links: topotest.sysctl_assure( nrouter, "net.mpls.conf.{}.input".format(interface), 1) return result
def setup_module(mod): "Sets up the pytest environment" # This function initiates the topology build with Topogen... tgen = Topogen(build_topo, mod.__name__) # Skip if no mpls support if not tgen.hasmpls: logger.info("MPLS is not available, skipping test") pytest.skip("MPLS is not available, skipping") return # ... and here it calls Mininet initialization functions. tgen.start_topology() # This is a sample of configuration loading. router_list = tgen.routers() # Enable mpls input for routers, so we can ping sval = "net.mpls.conf.{}.input" topotest.sysctl_assure(router_list["R2"], sval.format("R2-eth0"), 1) topotest.sysctl_assure(router_list["R1"], sval.format("R1-eth0"), 1) topotest.sysctl_assure(router_list["R1"], sval.format("R1-eth1"), 1) topotest.sysctl_assure(router_list["R4"], sval.format("R4-eth0"), 1) # 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_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))) # Have static config for R3 too if router == router_list["R3"]: router.load_config( TopoRouter.RD_STATIC, os.path.join(CWD, "{}/staticd.conf".format(rname))) # After loading the configurations, this function loads configured daemons. tgen.start_router()