def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5] tl = TestLib(ctl, aliases) mt = MrouteTest(tl, hosts, ifaces) sleep(30) mt.init() # add vifs mt.add_vif(sw_if1, 0) mt.add_vif(sw_if2, 1) mt.add_vif(sw_if3, 2) mt.add_vif(sw_if4, 3) mt.add_vif(sw_if5, 4) mt.pimreg_add(5) # add an (S,G) route pointing to a lone pimreg route1 = mt.mroute_create(ipv4(test_ip(5, 2)), mcgrp(1), 4, [5]) # add an (S,G) route with pimgreg dev as ingress route2 = mt.mroute_create(ipv4(test_ip(5, 2)), mcgrp(2), 5, [1, 2, 3]) mt.fini()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5] tl = TestLib(ctl, aliases) mt = MrouteTest(tl, hosts, ifaces) sleep(30) mt.init() # add vifs for vif_index, port in enumerate(sw_ports): mt.add_vif(port, vif_index) # add a (*,G) route starg = mt.mroute_create("0.0.0.0", mcgrp(1), 0, [0, 1, 3]) # add a more specific (S,G) route with the same group sg = mt.mroute_create(ipv4(test_ip(1, 1)), mcgrp(1), 0, [2, 3, 4]) # remove the (S,G) route and see that the (*,G) is still functional mt.mroute_remove(sg, test=False) mt.mroute_test(starg) # clean mt.mroute_remove(starg) mt.fini()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.reset() m2_if1.reset() m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(1, 1)) m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 1)) sw_if1_10 = sw.create_vlan(sw_if1, 10, ip=test_ip(1, 2)) sw_if2_10 = sw.create_vlan(sw_if2, 10, ip=test_ip(2, 2)) m1_if1_10.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 2, []))]) m2_if1_10.add_nhs_route(ipv4(test_ip(1, 0)), [ipv4(test_ip(2, 2, []))]) m1_if1.add_nhs_route(ipv6(test_ip(2, 0)), [ipv6(test_ip(1, 2, []))], ipv6=True) m2_if1.add_nhs_route(ipv6(test_ip(1, 0)), [ipv6(test_ip(2, 2, []))], ipv6=True) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.ping_simple(m1_if1_10, m2_if1_10) tl.netperf_tcp(m1_if1_10, m2_if1_10) tl.netperf_udp(m1_if1_10, m2_if1_10)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces tl = TestLib(ctl, aliases) prio_test = PrioTestLib(tl, sw, {sw_if1: m1_if1, sw_if2: m2_if1}) prio_test.create_bottleneck(aliases) prio_test.set_prio(bands=3, priomap="1 1 1 1 1 0 0 0 0") sleep(30) logging.info("Start traffic in band 0") prio_test.send_bg_traffic(6) sleep(30) logging.info("Send traffic in band 1 (shouldn't pass)") prio_test.check_traffic_passes(0, False) logging.info("Remap background traffic to band 6") prio_test.set_prio(bands=7, priomap="1 1 1 1 6 6 6 6") sleep(30) logging.info("Send traffic in band 1 (should pass)") prio_test.check_traffic_passes(0, True) logging.info("Remap background traffic to band 0") prio_test.set_prio(bands=3, priomap="1 1 1 1 0 0 0 0") sleep(30) logging.info("Send traffic in band 1 (shouldn't pass)") prio_test.check_traffic_passes(0, False) prio_test.stop_bg_traffic()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5] tl = TestLib(ctl, aliases) mt = MrouteTest(tl, hosts, ifaces) tl.wait_for_if(ifaces) mt.init() # add vifs mt.add_vif(sw_if1, 0) mt.add_vif(sw_if2, 1) mt.add_vif(sw_if3, 2) mt.add_vif(sw_if4, 3) mt.add_vif(sw_if5, 4) # add an (S,G) route sg = mt.mroute_create(ipv4(test_ip(5, 2)), mcgrp(1), 4, [0, 2, 3]) # replace it with a different route sg = mt.mroute_create(ipv4(test_ip(5, 2)), mcgrp(1), 4, [0, 1]) # clean mt.mroute_remove(sg) mt.fini()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1_85 = m1.create_vlan(m1_if1, 85, ip=["192.168.101.10/24", "2002::1/64"]) m2_if1_65 = m2.create_vlan(m2_if1, 65, ip=["192.168.101.11/24", "2002::2/64"]) sw_br1 = sw.create_bridge(slaves=[sw_if1, sw_if2], options={ "vlan_filtering": 1, "multicast_snooping": 0 }) sw_if1.add_br_vlan(85) sw_if2.add_br_vlan(65) q1 = Qdisc(sw_if1, 0xffff, "ingress") q1.filter_add("protocol all flower skip_sw action vlan modify id 65") q2 = Qdisc(sw_if2, 0xffff, "ingress") q2.filter_add("protocol all flower skip_sw action vlan modify id 85") sleep(10) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1_85, m2_if1_65)
def do_task(ctl, hosts, ifaces, bridges, aliases): m1, m2, sw = hosts m1_if, m2_if, m3_if, m4_if, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces peers = {m1_if: sw_if1, m2_if: sw_if2, m3_if: sw_if3, m4_if: sw_if4} for bridge in bridges: bridge.set_br_mcast_snooping(False) # Create a bridge sw_ports = peers.values() sw_br = sw.create_bridge(slaves=sw_ports, options={"vlan_filtering": 1, "multicast_querier": 1}) m1_if.set_addresses(test_ip(1,1)) m2_if.set_addresses(test_ip(1,2)) m3_if.set_addresses(test_ip(1,3)) m4_if.set_addresses(test_ip(1,4)) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.check_cpu_traffic(sw_ports, test=False) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.enable_multicast() test_standard_multicast(tl, m1_if, [m2_if, m4_if], mcgrp(3), sw_br, peers) test_standard_multicast(tl, m1_if, [m4_if], mcgrp(4), sw_br, peers) test_standard_multicast(tl, m2_if, [m1_if, m2_if, m4_if], mcgrp(5), sw_br, peers) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.disable_multicast() tl.check_cpu_traffic(sw_ports)
def do_task(ctl, hosts, ifaces, aliases): tl = TestLib(ctl, aliases) sw = hosts sw_if1, sw_if2, = ifaces sw_if1_mac = sw_if1.get_hwaddr() sw_if2_mac = sw_if2.get_hwaddr() sw_if1_devname = str(sw_if1.get_devname()) sw_if2_devname = str(sw_if2.get_devname()) dbm = DBManager() current_distro = sw.run("cat /etc/redhat-release | grep -o [0-9].[0-9]").out().strip() pre_distro = str(float(current_distro) - 0.1) hostname = sw.run("hostname|head -n 1").out().strip() sw_if1_devname_old = dbm.get_devname(pre_distro,sw_if1.get_driver(),hostname,sw_if1_mac) sw_if2_devname_old = dbm.get_devname(pre_distro,sw_if2.get_driver(),hostname,sw_if2_mac) if sw_if1_devname_old != "null" and sw_if1_devname_old != sw_if1_devname: failMod = ctl.get_module("DummyFailing") print "devname check failed, %s vs %s" %(sw_if1_devname,sw_if1_devname_old) sw.run(failMod) dbm.new_devname(current_distro,sw_if1.get_driver(),hostname,sw_if1_mac,sw_if1_devname)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.reset(ip=test_ip(1, 1)) m2_if1.reset(ip=test_ip(2, 1)) sw_if1.reset(ip=test_ip(1, 2)) sw_if2.reset(ip=test_ip(2, 2)) m1_if1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 2, []))]) m2_if1.add_nhs_route(ipv4(test_ip(1, 0)), [ipv4(test_ip(2, 2, []))]) m1_if1.add_nhs_route(ipv6(test_ip(2, 0)), [ipv6(test_ip(1, 2, []))], ipv6=True) m2_if1.add_nhs_route(ipv6(test_ip(1, 0)), [ipv6(test_ip(2, 2, []))], ipv6=True) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.ping_simple(m1_if1, m2_if1) # Remove route and check that traffic is not passing sw_if1.set_addresses(ips=[]) sw_if2.set_addresses(ips=[]) tl.ping_simple(m1_if1, m2_if1, fail_expected=True)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces bond_options = {"mode": "802.3ad", "miimon": "100"} m1_lag1 = m1.create_bond(slaves=[m1_if1, m1_if2], options=bond_options, ip=["192.168.101.10/24", "2002::1/64"]) m2_lag1 = m2.create_bond(slaves=[m2_if1, m2_if2], options=bond_options, ip=["192.168.101.11/24", "2002::2/64"]) sw_lag1 = sw.create_bond(slaves=[sw_if1, sw_if2], options=bond_options) sw_lag2 = sw.create_bond(slaves=[sw_if3, sw_if4], options=bond_options) sw.create_bridge(slaves=[sw_lag1, sw_lag2], options={ "vlan_filtering": 1, "multicast_snooping": 0 }) test_ifaces = m1_lag1, m2_lag1, sw_lag1, sw_lag2 tl = TestLib(ctl, aliases, test_ifaces) tl.wait_for_if(ifaces) tl.link_status_show() tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if, m2_if, m3_if, m4_if, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces # Create a bridge sw_ifaces = [sw_if1, sw_if2, sw_if3, sw_if4] sw_br = sw.create_bridge(slaves=sw_ifaces, options={"vlan_filtering": 1}) m1_if.set_addresses(test_ip(1, 1)) m2_if.set_addresses(test_ip(1, 2)) m3_if.set_addresses(test_ip(1, 3)) m4_if.set_addresses(test_ip(1, 4)) sleep(15) tl = TestLib(ctl, aliases) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.enable_multicast() tl.check_cpu_traffic(sw_ifaces, test=False) test_mcast_onoff(tl, sw_br, m1_if, [], [m3_if, m2_if, m4_if], mcgrp(1)) test_mcast_onoff(tl, sw_br, m1_if, [m2_if], [m3_if, m4_if], mcgrp(2)) test_mcast_onoff(tl, sw_br, m1_if, [m2_if, m4_if], [m3_if], mcgrp(3)) test_mcast_onoff(tl, sw_br, m3_if, [m1_if, m4_if], [m2_if], mcgrp(4)) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.disable_multicast() tl.check_cpu_traffic(sw_ifaces)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces team_config = '{"runner" : {"name" : "lacp"}}' m1_lag1 = m1.create_team(slaves=[m1_if1, m1_if2], config=team_config, ip=test_ip(1, 1)) m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config, ip=test_ip(2, 1)) m1_lag1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 2, []))]) m2_lag1.add_nhs_route(ipv4(test_ip(1, 0)), [ipv4(test_ip(2, 2, []))]) m1_if1.add_nhs_route(ipv6(test_ip(2, 0)), [ipv6(test_ip(1, 2, []))], ipv6=True) m2_if1.add_nhs_route(ipv6(test_ip(1, 0)), [ipv6(test_ip(2, 2, []))], ipv6=True) sw_lag1 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config, ip=test_ip(1, 2)) sw_lag2 = sw.create_team(slaves=[sw_if3, sw_if4], config=team_config, ip=test_ip(2, 2)) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces vrf_None = None tl = TestLib(ctl, aliases) # Test that offloaded routes do have "offload" flag. with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d: with gre(sw, None, vrf_None, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5") as g, \ encap_route(sw, vrf_None, 2, g, ip=ipv4), \ encap_route(sw, vrf_None, 2, g, ip=ipv6): sleep(30) ulip = onet2_ip(ctl, 0, [24, 64]) (r4,), _ = sw.get_routes("table 0 %s" % ipv4(ulip)) if "offload" not in r4["flags"]: tl.custom(sw, "ipip", "IPv4 encap route not offloaded") (r6,), _ = sw.get_routes("table 0 %s" % ipv6(ulip)) if "offload" not in r6["flags"]: tl.custom(sw, "ipip", "IPv6 encap route not offloaded") (dcr4,), _ = sw.get_routes("table local 1.2.3.4") if "offload" not in dcr4["flags"]: tl.custom(sw, "ipip", "IPv4 decap route not offloaded") sleep(5) (dcr4,), _ = sw.get_routes("table local 1.2.3.4") if "offload" in dcr4["flags"]: tl.custom(sw, "ipip", "IPv4 decap still flagged offloaded")
def do_task(ctl, hosts, ifaces, aliases): tl = TestLib(ctl, aliases) m1, m2, sw = hosts m1_if1, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3 = ifaces m1.sync_resources(modules=["PacketAssert"]) # configure interfaces m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"]) m2_if1.reset(ip=["192.168.101.11/24", "2002::2/64"]) sw_if3.set_link_up() m2_if2.set_link_up() sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1}) mirred_port = MirredPort(sw_if2) sleep(30) mirror_status = {"ingress": False, "egress": False} for i in range(10): change = random.choice(mirror_status.keys()) change_mirror_status(mirror_status, change, mirred_port, sw_if3) in_num = 10 if mirror_status["ingress"] else 0 out_num = 10 if mirror_status["egress"] else 0 assert_procs = run_packet_assert(in_num, m2_if2, m2_if1, m1_if1, aliases["ipv"]) assert_procs += run_packet_assert(out_num, m2_if2, m1_if1, m2_if1, aliases["ipv"]) tl.ping_simple(m1_if1, m2_if1, count=10) for assert_proc in assert_procs: assert_proc.intr() return 0
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"]) m2_if1.reset(ip=["192.168.101.11/24", "2002::2/64"]) sleep(30) sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1}) sw_if1.add_br_vlan(10) sw_if2.add_br_vlan(10) tl = TestLib(ctl, aliases) sw.enable_service("lldpad") sw_if1.enable_lldp() tl.lldp_ets_default_set(sw_if1, willing=False) m1.enable_service("lldpad") m1_if1.enable_lldp() tl.lldp_ets_default_set(m1_if1) tl.ping_simple(m1_if1, m2_if1) for prio in range(1, 8): tl.lldp_ets_up2tc_set(sw_if1, [(prio, prio)]) tl.devlink_clearmax(sw, sw_if1.get_devlink_name()) sleep(5) # lldpad's event loop runs every second. tl.pktgen(m1_if1, m2_if1, m1_if1.get_mtu(), vlan_id=10, vlan_p=prio) check_itc_max_occ(tl, sw_if1, prio) tl.lldp_ets_up2tc_set(sw_if1, [(prio, 0)])
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces bond_options = {"mode": "802.3ad", "miimon": "100"} m1_lag1 = m1.create_bond(slaves=[m1_if1, m1_if2], options=bond_options, ip=test_ip(1, 1)) m2_lag1 = m2.create_bond(slaves=[m2_if1, m2_if2], options=bond_options, ip=test_ip(2, 1)) m1_lag1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 2, []))]) m2_lag1.add_nhs_route(ipv4(test_ip(1, 0)), [ipv4(test_ip(2, 2, []))]) m1_if1.add_nhs_route(ipv6(test_ip(2, 0)), [ipv6(test_ip(1, 2, []))], ipv6=True) m2_if1.add_nhs_route(ipv6(test_ip(1, 0)), [ipv6(test_ip(2, 2, []))], ipv6=True) sw_lag1 = sw.create_bond(slaves=[sw_if1, sw_if2], options=bond_options, ip=test_ip(1, 2)) sw_lag2 = sw.create_bond(slaves=[sw_if3, sw_if4], options=bond_options, ip=test_ip(2, 2)) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces # We can't set STP state if kernel's STP is running. br_options = {"stp_state": 0, "vlan_filtering": 1, "ageing_time": 1000, "multicast_querier": 1} sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options) m1_if1.reset(ip=test_ip(1, 1)) m2_if1.reset(ip=test_ip(1, 2)) sleep(40) tl = TestLib(ctl, aliases) # Set STP state to DISABLED and make sure ping fails and FDB is not # populated. sw_if1.set_br_state(0) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True, False) # Set STP state to LISTENING and make sure ping fails and FDB is not # populated. sw_if1.set_br_state(1) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True, False) # Set STP state to LEARNING and make sure ping fails, but FDB *is* # populated. sw_if1.set_br_state(2) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True) sleep(40) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True, False) # Set STP state to FORWARDING and make sure ping works and FDB is # populated. sw_if1.set_br_state(3) tl.ping_simple(m1_if1, m2_if1) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True) sleep(40) tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, True, True, False) # Make sure that even with a static FDB record we don't get traffic # when state is DISABLED, LEARNING or LISTENING. sw_if2.add_br_fdb(str(m2_if1.get_hwaddr()), master=True, vlan_tci=1) sw_if1.set_br_state(0) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) sw_if1.set_br_state(1) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) sw_if1.set_br_state(2) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) # Cleanup sw_if2.del_br_fdb(str(m2_if1.get_hwaddr()), master=True, vlan_tci=1)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5] tl = TestLib(ctl, aliases) mt = MrouteTest(tl, hosts, ifaces) sleep(30) mt.init() # add vifs mt.add_vif(sw_if1, 0) mt.add_vif(sw_if2, 1) mt.add_vif(sw_if3, 2) mt.add_vif(sw_if4, 3) mt.add_vif(sw_if5, 4) vifs = [0, 1, 2, 3, 4] mroutes = [] for i in range(1, 10): ivif = random_ivif(vifs) evifs = random_evifs(vifs, ivif) mroutes.append(nocache_route(mt, ivif, mcgrp(i), evifs)) for mroute in mroutes: mt.mroute_remove(mroute) mt.fini()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 1, []))]) m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(test_ip(99, 1, []))]) vrf_None = None tl = TestLib(ctl, aliases) sw_if1.reset(ip=test_ip(1, 1)) sw_if2.reset(ip=test_ip(99, 1)) logging.info("=== Hierarchical configuration") with vrf(sw) as vrf_u, \ vrf(sw) as vrf_o: connect_host_ifaces(sw, sw_if1, vrf_o, sw_if2, vrf_u) sw_if1.reset() sw_if2.reset() add_forward_route(sw, vrf_u, "1.2.3.5") with encap_route(m2, vrf_None, 1, "ipip1", ip=ipv4): # - Set up encap route before decap route. # - Tear down encap route before decap route. logging.info("--- Dup, Eup, Edown, Ddown") with dummy(sw, vrf_u, ip=["1.2.3.4/32"]) as d, \ ipip(sw, d, vrf_o, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5") as g, \ encap_route(sw, vrf_o, 2, g): sleep(15) ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if, m2_if, m3_if, m4_if, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces # Create a bridge sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4] sw_br = sw.create_bridge(slaves=sw_ports, options={ "vlan_filtering": 1, "multicast_querier": 1 }) m1_if.set_addresses(test_ip(1, 1)) m2_if.set_addresses(test_ip(1, 2)) m3_if.set_addresses(test_ip(1, 3)) m4_if.set_addresses(test_ip(1, 4)) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.check_cpu_traffic(sw_ports, test=False) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.enable_multicast() test_standard_mutlicast(tl, m1_if, [m2_if, m4_if], [m3_if], mcgrp(3)) test_standard_mutlicast(tl, m1_if, [m4_if], [m2_if, m3_if], mcgrp(4)) test_standard_mutlicast(tl, m2_if, [m3_if, m4_if, m1_if], [], mcgrp(5)) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.disable_multicast() tl.check_cpu_traffic(sw_ports)
def do_task(ctl, hosts, ifaces, aliases): m1, sw, m2 = hosts m1_if1, sw_if1, sw_if2, sw_if3, m2_if1, m2_if2, m2_if3, m3_if1 = ifaces ecmp_sw_ifaces = [sw_if2, sw_if3] ecmp_m_ifaces = [m2_if1, m2_if2] m2.config("/proc/sys/net/ipv4/ip_forward", "1") m2.config("/proc/sys/net/ipv6/conf/all/forwarding", "1") ecmp_common.create_topology(m1_if1, sw_if1, ecmp_sw_ifaces, ecmp_m_ifaces, m2_if3, m3_if1, num_nexthops=MAX_NEXTHOPS) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.ping_simple(m1_if1, m3_if1) tl.netperf_udp(m1_if1, m3_if1) ecmp_common.test_traffic(tl, m1_if1, m3_if1, sw_if1, ecmp_sw_ifaces) routes_filter = "to match %s" % m3_if1.get_ip() dc_routes, nh_routes = sw.get_routes(routes_filter=routes_filter) if len(nh_routes) != 1: tl.custom(sw, "route", "could not find the ecmp route") for nh in nh_routes[0]["nexthops"]: if "offload" not in nh["flags"]: tl.custom(sw, "route", "ecmp route is not offloaded")
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1_85 = m1.create_vlan(m1_if1, 85, ip=["192.168.101.10/24", "2002::1/64"]) m2_if1_65 = m2.create_vlan(m2_if1, 65, ip=["192.168.101.11/24", "2002::2/64"]) sw_br1 = sw.create_bridge(slaves=[sw_if1, sw_if2], options={ "vlan_filtering": 1, "multicast_snooping": 0 }) sw_if1.add_br_vlan(85) sw_if2.add_br_vlan(65) # These 2 aren't needed functionally, but used to prevent logged errors - # Learning fails upon receiving packets on a non-configured {port, vlan} sw_if1.add_br_vlan(65) sw_if2.add_br_vlan(85) q1 = Qdisc(sw_if1, 0xffff, "ingress") q1.filter_add("protocol all flower skip_sw action vlan modify id 65") q2 = Qdisc(sw_if2, 0xffff, "ingress") q2.filter_add("protocol all flower skip_sw action vlan modify id 85") sleep(10) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1_85, m2_if1_65)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5] tl = TestLib(ctl, aliases) mt = MrouteTest(tl, hosts, ifaces) tl.wait_for_if(ifaces) mt.init() # add vifs mt.add_vif(sw_if1, 0) mt.add_vif(sw_if2, 1) mt.add_vif(sw_if3, 2) mt.add_vif(sw_if4, 3) mt.add_vif(sw_if5, 4) mt.pimreg_add(5) # add an (S,G) route pointing to pimreg (among others) evifs = [0, 1, 2, 5] sg = mt.mroute_create(ipv4(test_ip(5,2)), mcgrp(1), 4, evifs) mt.fini()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3 = ifaces subnet0 = aliases["subnet0"] + ".0/24" subnet1 = aliases["subnet1"] + ".0/24" subnet2 = aliases["subnet2"] + ".0/24" subnet3 = aliases["subnet3"] + ".0/24" tl = TestLib(ctl, aliases) # +----------------------------------+ # | | # | | # | sw_if1 sw_if2 sw_if3 | # +---+-----------------+-------+----+ # | | | # | | | # | | | # | | | # + + + # m1_if1 m2_if1 m2_if2 cmd = "ip -4 route add {subnet} nexthop via {gw_ip} dev {nh_dev}" m1.run(cmd.format(subnet=subnet3, gw_ip=sw_if1.get_ip(0), nh_dev=m1_if1.get_devname())) cmd = ("ip -4 route add {subnet} nexthop via {gw_ip0} dev {nh_dev0} " "nexthop via {gw_ip1} dev {nh_dev1}") m2.run(cmd.format(subnet=subnet0, gw_ip0=sw_if2.get_ip(0), nh_dev0=m2_if1.get_devname(), gw_ip1=sw_if3.get_ip(0), nh_dev1=m2_if2.get_devname())) cmd = ("ip -4 route add {subnet} nexthop via {gw_ip0} dev {nh_dev0} " "nexthop via {gw_ip1} dev {nh_dev1}") sw.run(cmd.format(subnet=subnet3, gw_ip0=m2_if1.get_ip(0), nh_dev0=sw_if2.get_devname(), gw_ip1=m2_if2.get_ip(0), nh_dev1=sw_if3.get_devname())) sleep(30) # Basic sanity check to make sure test is not failing due to # setup issues. ping(ctl, m1_if1, m2_if2.get_ip(1)) # Use only source and destination IP for IPv4 multipath hash. sw.run("sysctl -w net.ipv4.fib_multipath_hash_policy=0") multipath_test(ctl, hosts, ifaces, aliases, False, False) multipath_test(ctl, hosts, ifaces, aliases, True, True) # Use a 5-tuple for the multipath hash. sw.run("sysctl -w net.ipv4.fib_multipath_hash_policy=1") multipath_test(ctl, hosts, ifaces, aliases, False, True) multipath_test(ctl, hosts, ifaces, aliases, True, True)
def do_task(ctl, hosts, ifaces, aliases): m1_if1, sw_if1 = ifaces m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"]) sw_if1.reset(ip=["192.168.101.11/24", "2002::2/64"]) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) linkneg(tl, sw_if1, m1_if1)
def do_task(ctl, hosts, ifaces, aliases): """ This test deffines MAX_ROUTES number of routes on the switch with different 32bit prefixes in the range 192.168.[10..].[1..254] and redirects them to a nexthop on machine2. The test than checks that: - All routes has the offloaded flag - Traffic destined to each of the route prefixes did end up on machine2, as the route specifies """ m1, sw, m2 = hosts m1_if1, sw_if1, sw_if2, m2_if1 = ifaces m1_if1.reset(ip=test_ip(1, 1)) sw_if1.reset(ip=test_ip(1, 2)) sw_if2.reset(ip=test_ip(2, 2)) m2_if1.reset(ip=test_ip(2, 3)) for route_index in range(ROUTES_COUNT): route_major = get_route_major(route_index) route_minor = get_route_minor(route_index) sw_if1.add_nhs_route(ipv4(test_ip(route_major, route_minor, [])), [ipv4(test_ip(2, 3, []))]) sleep(30) tl = TestLib(ctl, aliases) # check that there are ROUTES_COUNT offloaded routes dc_routes, nh_routes = sw.get_routes() offloaded_routes_num = 0 for nh_route in nh_routes: if "offload" in nh_route["flags"]: offloaded_routes_num += 1 if offloaded_routes_num < ROUTES_COUNT: tl.custom( sw, "route", "Only %d out of %d routes offloaded" % (offloaded_routes_num, ROUTES_COUNT)) # run traffic, and validate that each route will be hit sleep(2) before_stats = m2_if1.link_stats()["rx_packets"] total_sent = 0 for major in get_all_route_majors(): total_sent += traffic_route_major(tl, major, m1_if1, m2_if1, sw_if1) sleep(2) after_stats = m2_if1.link_stats()["rx_packets"] recieved = after_stats - before_stats # validate that all traffic went according to the routes thresh = total_sent * 0.95 if recieved < thresh: tl.custom(sw, "route", "Recieved %d out of %d packets" % (recieved, thresh))
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts (m1_if1_10, m1_if1_20, m2_if1_10, m2_if1_20, sw_if1_10, sw_if1_20, sw_if2_10, sw_if2_20) = ifaces m2_if1_10.add_nhs_route("1.2.3.4/32", [ipv4(test_ip(99, 1, []))]) vrf_None = None tl = TestLib(ctl, aliases) logging.info("=== Decap-only flow in default VRF") with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4, src=ipv4(test_ip(2, 33, []))), \ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \ dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d, \ gre(sw, None, vrf_None, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5") as g: add_forward_route(sw, vrf_None, "1.2.3.5") sleep(15) ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True) ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g) logging.info("=== Decap-only flow in hierarchical configuration") with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4, src=ipv4(test_ip(2, 33, []))), \ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \ vrf(sw) as vrf_u, \ vrf(sw) as vrf_o, \ dummy(sw, vrf_u, ip=["1.2.3.4/32"]) as d, \ gre(sw, d, vrf_o, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5") as g: connect_host_ifaces(sw, sw_if1_10, vrf_o, sw_if2_10, vrf_u) refresh_addrs(sw, sw_if1_10) add_forward_route(sw, vrf_u, "1.2.3.5") ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True) ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if, m2_if, m3_if, m4_if, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces # Create a bridge sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4] sw_br = sw.create_bridge(slaves=sw_ports, options={"vlan_filtering": 1}) m1_if.set_addresses(test_ip(1, 1)) m2_if.set_addresses(test_ip(1, 2)) m3_if.set_addresses(test_ip(1, 3)) m4_if.set_addresses(test_ip(1, 4)) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.enable_multicast() tl._ctl.wait(2) tl.check_cpu_traffic(sw_ports, test=False) mcast_iface = [m2_if, m3_if, m4_if] sw_if2.set_mcast_router(MCAST_ROUTER_PORT.FIXED_ON) sw_if2.set_mcast_flood(False) result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(1)) tl.mc_ipref_compare_result(mcast_iface, result, [True, False, False]) tl.check_cpu_traffic(sw_ports) sw_br.set_br_mcast_snooping(False) tl._ctl.wait(2) result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(1)) tl.mc_ipref_compare_result(mcast_iface, result, [False, True, True]) tl.check_cpu_traffic(sw_ports) sw_if2.set_mcast_flood(True) sw_if2.set_mcast_router(MCAST_ROUTER_PORT.FIXED_OFF) sw_if3.set_mcast_router(MCAST_ROUTER_PORT.FIXED_ON) sw_if3.set_mcast_flood(False) result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(1)) tl.mc_ipref_compare_result(mcast_iface, result, [True, False, True]) tl.check_cpu_traffic(sw_ports) sw_br.set_br_mcast_snooping() tl._ctl.wait(2) result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(1)) tl.mc_ipref_compare_result(mcast_iface, result, [False, True, False]) tl.check_cpu_traffic(sw_ports) sw_if2.set_mcast_router(MCAST_ROUTER_PORT.LEARNING) sw_if2.set_mcast_router(MCAST_ROUTER_PORT.LEARNING) sw_if3.set_mcast_flood(True) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.disable_multicast()
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 1, []))]) m1_if1.add_nhs_route(ipv6(test_ip(2, 0)), [ipv6(test_ip(1, 1, []))]) m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(test_ip(99, 1, []))]) vrf_None = None tl = TestLib(ctl, aliases) sw_if1.reset(ip=test_ip(1, 1)) sw_if2.reset(ip=test_ip(99,1)) # Check the behavior when two tunnels with conflicting local addresses are # used. logging.info("=== Conflict in GRE local endpoint") with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4), \ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \ vrf(sw) as vrf1, \ dummy(sw, vrf1, ip=["1.2.3.4/32"]) as d, \ gre(sw, None, vrf1, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5") as g, \ encap_route(sw, vrf1, 2, g, ip=ipv4), \ encap_route(sw, vrf1, 2, g, ip=ipv6): connect_host_ifaces(sw, sw_if1, vrf1, sw_if2, vrf1) sw_if1.reset() sw_if2.reset() add_forward_route(sw, vrf1, "1.2.3.5") # Now create another tunnel whose local address conflicts with this one. # The original tunnel should keep working, even if it has to be # temporarily brought to slow path. with gre(sw, None, vrf1, tos="inherit", local_ip="1.2.3.4", remote_ip="1.2.3.5", key=3333) as g2, \ encap_route(sw, vrf1, 4, g2, ip=ipv4), \ encap_route(sw, vrf1, 4, g2, ip=ipv6): sleep(15) ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g, ipv6=True, require_fastpath=False) ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g, require_fastpath=False) # After the conflicting tunnel is gone, the traffic should again go # through fast path. sleep(15) ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g, ipv6=True) ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
def do_task(ctl, hosts, ifaces, aliases): m1, m2, sw = hosts m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces team_config = '{"runner" : {"name" : "lacp"}}' m1_lag1 = m1.create_team(slaves=[m1_if1, m1_if2], config=team_config, ip=["192.168.101.10/24", "2002::1/64"]) m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config, ip=["192.168.101.11/24", "2002::2/64"]) sw_lag1 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config) sw_lag2 = sw.create_team(slaves=[sw_if3, sw_if4], config=team_config) sw_br = sw.create_bridge(slaves=[sw_lag1, sw_lag2], options={ "vlan_filtering": 1, "multicast_querier": 1 }) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1) sw_lag1.slave_del(sw_if1.get_id()) sw_lag1.slave_del(sw_if2.get_id()) m1_lag1.slave_del(m1_if1.get_id()) # Make sure slowpath is working. sw_if1.reset(ip=["192.168.102.10/24", "2003::1/64"]) m1_if1.reset(ip=["192.168.102.11/24", "2003::2/64"]) sleep(30) tl.ping_simple(sw_if1, m1_if1) # Repopulate the LAGs and make sure fastpath is OK. sw_if1.set_addresses([]) # LAG port can't have IP address. sw_lag3 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config) sw_br.slave_add(sw_lag3.get_id()) m1_lag1.slave_add(m1_if1.get_id()) sleep(30) tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1)