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); sleep(30) tl = TestLib(ctl, aliases) 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): 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(15) 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 in_assert_proc = run_packet_assert(in_num, m2_if2, m2_if1, m1_if1) out_assert_proc = run_packet_assert(out_num, m2_if2, m1_if1, m2_if1) tl.ping_simple(m1_if1, m2_if1, count=10) in_assert_proc.intr() out_assert_proc.intr() return 0
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)) sleep(30) tl = TestLib(ctl, aliases) 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, 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(15) ulip = test_ip(2, 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): """ 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["nexthops"][0]["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, 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"]) sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1}) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1)
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, 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, 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) sleep(30) tl = TestLib(ctl, aliases) 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)
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 peers = {m1_if: sw_if1, m2_if: sw_if2, m3_if: sw_if3, m4_if: sw_if4} # 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)) sleep(30) tl = TestLib(ctl, aliases) 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): 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) sleep(30) tl = TestLib(ctl, aliases) 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, 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) # Test that non-IPIP traffic gets to slow path. with 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, \ encap_route(sw, vrf_None, 2, g, ip=ipv4): sleep(15) ping_test(tl, m2, sw, "1.2.3.4", m2_if1, g, count=20) # Configure the wrong interface on M2 to test that the traffic gets trapped # to CPU. with encap_route(m2, vrf_None, 1, "gre3"): add_forward_route(sw, vrf_None, "1.2.3.5") with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d, \ gre(sw, None, vrf_None, local_ip="1.2.3.4", remote_ip="1.2.3.5") as g: sleep(15) before_stats = sw_if2.link_stats()["rx_packets"] ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1, g, count=20, fail_expected=True) after_stats = sw_if2.link_stats()["rx_packets"] delta = after_stats - before_stats if delta < 15: tl.custom(sw, "ipip", "Too few packets (%d) observed in slow path" % delta)
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, aliases): m1, m2, sw = hosts m1_if1, m2_if1, sw_if1, sw_if2 = ifaces m1_if1.reset(ip=test_ip(1, 1)) m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(2, 1)) m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=test_ip(3, 1)) m1_if1_30 = m1.create_vlan(m1_if1, 30, ip=test_ip(4, 1)) m2_if1.reset(ip=test_ip(1, 2)) m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 2)) m2_if1_21 = m2.create_vlan(m2_if1, 21, ip=test_ip(3, 2)) m2_if1_30 = m2.create_vlan(m2_if1, 30, ip=test_ip(4, 2)) br_options = {"vlan_filtering": 1} sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options) sw_if1_10 = sw.create_vlan(sw_if1, 10, ip=test_ip(2, 3)) sw_if2_10 = sw.create_vlan(sw_if2, 10) sw_br = sw.create_bridge(slaves=[sw_if1_10, sw_if2_10], options=br_options) sw_if1_20 = sw.create_vlan(sw_if1, 20) sw_if2_21 = sw.create_vlan(sw_if2, 21) sw.create_bridge(slaves=[sw_if1_20, sw_if2_21], options=br_options) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1) tl.ping_simple(m1_if1_10, m2_if1_10) tl.ping_simple(m1_if1_20, m2_if1_21) tl.ping_simple(m1_if1_30, m2_if1_30, fail_expected=True) sw_br.slave_del(sw_if1_10.get_id()) sleep(5) tl.ping_simple(sw_if1_10, m1_if1_10)
def do_task(ctl, hosts, ifaces, aliases): m1, sw = hosts m1_if1, sw_if1 = ifaces m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=["192.168.101.10/24", "2002::1/64"]) sw_if1_10 = sw.create_vlan(sw_if1, 10, ip=["192.168.101.11/24", "2002::2/64"]) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1_10, sw_if1_10) tl.netperf_tcp(m1_if1_10, sw_if1_10) tl.netperf_udp(m1_if1_10, sw_if1_10)
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"]) sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1}) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1) tl.netperf_tcp(m1_if1, m2_if1) tl.netperf_udp(m1_if1, m2_if1)
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)) m1_lag1_10 = m1.create_vlan(m1_lag1, 10, ip=test_ip(2, 1)) m1_lag1_20 = m1.create_vlan(m1_lag1, 20, ip=test_ip(3, 1)) m1_lag1_30 = m1.create_vlan(m1_lag1, 30, ip=test_ip(4, 1)) m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config, ip=test_ip(1, 2)) m2_lag1_10 = m2.create_vlan(m2_lag1, 10, ip=test_ip(2, 2)) m2_lag1_21 = m2.create_vlan(m2_lag1, 21, ip=test_ip(3, 2)) m2_lag1_30 = m2.create_vlan(m2_lag1, 30, ip=test_ip(4, 2)) 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) br_options = {"vlan_filtering": 1, "multicast_snooping": 0} sw.create_bridge(slaves=[sw_lag1, sw_lag2], options=br_options) sw_lag1_10 = sw.create_vlan(sw_lag1, 10) sw_lag2_10 = sw.create_vlan(sw_lag2, 10) sw.create_bridge(slaves=[sw_lag1_10, sw_lag2_10], options={"multicast_snooping": 0}) sw_lag1_20 = sw.create_vlan(sw_lag1, 20) sw_lag2_21 = sw.create_vlan(sw_lag2, 21) sw.create_bridge(slaves=[sw_lag1_20, sw_lag2_21], options={"multicast_snooping": 0}) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.ping_simple(m1_lag1, m2_lag1) tl.ping_simple(m1_lag1_10, m2_lag1_10) tl.ping_simple(m1_lag1_20, m2_lag1_21) tl.ping_simple(m1_lag1_30, m2_lag1_30, fail_expected=True)
def do_task(ctl, hosts, ifaces, aliases): m1, sw = hosts 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"]) sleep(30) tl = TestLib(ctl, aliases) for x in range(64, 1500): tl.pktgen(sw_if1, m1_if1, x) for x in range(64, 1500): tl.pktgen(m1_if1, sw_if1, x) # Make sure switch is not stuck by performing ping test tl.ping_simple(m1_if1, sw_if1)
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(onet2_ip(ctl, 0)), [ipv4(onet1_ip(ctl, 1, []))]) m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(unet_ip(ctl, 1, []))]) vrf_None = None tl = TestLib(ctl, aliases) 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): tl.wait_for_if(ifaces) ping_test(tl, m1, sw, ipv4(onet2_ip(ctl, 33, [])), m1_if1, g, require_fastpath=False)
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)) m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(2, 1)) m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=test_ip(3, 1)) m1_if1_30 = m1.create_vlan(m1_if1, 30, ip=test_ip(4, 1)) m2_if1.reset(ip=test_ip(1, 2)) m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 2)) m2_if1_21 = m2.create_vlan(m2_if1, 21, ip=test_ip(3, 2)) m2_if1_30 = m2.create_vlan(m2_if1, 30, ip=test_ip(4, 2)) br_options = {"vlan_filtering": 1, "multicast_querier": 1} sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options) sw_if1_10 = sw.create_vlan(sw_if1, 10) sw_if2_10 = sw.create_vlan(sw_if2, 10) sw_br = sw.create_bridge(slaves=[sw_if1_10, sw_if2_10], options={"multicast_querier": 1}) sw_if1_20 = sw.create_vlan(sw_if1, 20) sw_if2_21 = sw.create_vlan(sw_if2, 21) sw.create_bridge(slaves=[sw_if1_20, sw_if2_21], options={"multicast_querier": 1}) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1) tl.ping_simple(m1_if1_10, m2_if1_10) tl.ping_simple(m1_if1_20, m2_if1_21) tl.ping_simple(m1_if1_30, m2_if1_30, fail_expected=True) sw_br.slave_del(sw_if1_10.get_id()) sw_if1_10.reset(ip=test_ip(2, 3)) sleep(30) tl.ping_simple(sw_if1_10, m1_if1_10)
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(onet2_ip(ctl, 0)), [ipv4(onet1_ip(ctl, 1, []))]) m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(unet_ip(ctl, 1, []))]) m2_gre3 = m2.get_interface("gre3") vrf_None = None tl = TestLib(ctl, aliases) # Test that non-IPIP traffic gets to slow path. with 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, \ encap_route(sw, vrf_None, 2, g, ip=ipv4): tl.wait_for_if(ifaces) ping_test(tl, m2, sw, "1.2.3.4", m2_if1, g, count=20) # Configure the wrong interface on M2 to test that the traffic gets trapped # to CPU. with encap_route(m2, vrf_None, 1, "gre3"): add_forward_route(sw, vrf_None, "1.2.3.5") with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d, \ gre(sw, None, vrf_None, local_ip="1.2.3.4", remote_ip="1.2.3.5") as g: tl.wait_for_if(ifaces) before_stats = sw_if2.link_stats()["rx_packets"] ping_test(tl, m2, sw, ipv4(onet1_ip(ctl, 33, [])), m2_gre3, g, count=20, fail_expected=True) after_stats = sw_if2.link_stats()["rx_packets"] delta = after_stats - before_stats if delta < 15: tl.custom(sw, "ipip", "Too few packets (%d) observed in slow path" % delta)
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, "multicast_querier": 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, sw = hosts 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"]) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, sw_if1) tl.netperf_tcp(m1_if1, sw_if1) tl.netperf_udp(m1_if1, sw_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, m2_if1, sw_if1, sw_if2 = ifaces tl = TestLib(ctl, aliases) dlname = sw_if1.get_devlink_name() if not dlname: raise UnavailableDevlinkNameException() ports = get_ports(sw, dlname) pools = get_pools(sw, dlname) check_pools(tl, sw, dlname, pools) check_tcbind(tl, sw, dlname, ports, pools) check_portpool(tl, sw, dlname, ports, pools)
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) sw_if1.reset(ip=test_ip(1, 2)) sw_if2.reset(ip=test_ip(99, 1)) # 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(15) ulip = test_ip(2, 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): 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) 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)
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_br = sw.create_bridge(slaves=[sw_if1, sw_if2, sw_if3, sw_if4], options={"vlan_filtering": 1}) m1_if.set_addresses(["192.168.101.10/24", "2002::1/64"]) m2_if.set_addresses(["192.168.101.11/24", "2002::2/64"]) m3_if.set_addresses(["192.168.101.13/24", "2002::3/64"]) m4_if.set_addresses(["192.168.101.14/24", "2002::4/64"]) sleep(30) tl = TestLib(ctl, aliases) tl.iperf_mc(m1_if, [m2_if, m4_if], [m3_if], "239.255.1.3") tl.iperf_mc(m1_if, [m4_if], [], "239.255.1.4") tl.iperf_mc(m2_if, [m3_if, m4_if, m1_if], [], "239.255.1.5")
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,[]))]); sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1) tl.netperf_tcp(m1_if1, m2_if1) tl.netperf_udp(m1_if1, m2_if1)
def do_task(ctl, hosts, ifaces, aliases): m1, sw = hosts 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"]) sleep(15) tl = TestLib(ctl, aliases) for x in range(64, 1500): tl.pktgen(sw_if1, m1_if1, x) for x in range(64, 1500): tl.pktgen(m1_if1, sw_if1, x) # Make sure switch is not stuck by performing ping test tl.ping_simple(m1_if1, sw_if1)
def multipath_test(ctl, hosts, ifaces, aliases, l3, should_multipath): m1_if1, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3 = ifaces tl = TestLib(ctl, aliases) m1, m2, sw = hosts if2_pre = sw_if2.link_stats()["tx_packets"] if3_pre = sw_if3.link_stats()["tx_packets"] if l3: pktgen_l3(ctl, m1_if1, sw_if1.get_hwaddr(), aliases["subnet0"], aliases["subnet3"]) else: pktgen_l4(ctl, m1_if1, m2_if2.get_ip(1), sw_if1.get_hwaddr()) if2_post = sw_if2.link_stats()["tx_packets"] if3_post = sw_if3.link_stats()["tx_packets"] check_res(tl, m1, if2_post - if2_pre, if3_post - if3_pre, should_multipath)
def do_task(ctl, hosts, ifaces, aliases): m1, sw = hosts m1_if1, sw_if1 = ifaces m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=["192.168.101.10/24", "2002::1/64"]) sw_if1_20 = sw.create_vlan(sw_if1, 20, ip=["192.168.101.11/24", "2002::2/64"]) # We need to get a netlink message with the VLAN devices' info, # so make sure we wait long enough. sleep(30) tl = TestLib(ctl, aliases) for x in range(64, 1500): tl.pktgen(sw_if1_20, m1_if1_20, x) for x in range(64, 1500): tl.pktgen(m1_if1_20, sw_if1_20, x) # Make sure switch is not stuck by performing ping test tl.ping_simple(m1_if1_20, sw_if1_20)
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)) m1_lag1_10 = m1.create_vlan(m1_lag1, 10, ip=test_ip(2, 1)) m1_lag1_20 = m1.create_vlan(m1_lag1, 20, ip=test_ip(3, 1)) m1_lag1_30 = m1.create_vlan(m1_lag1, 30, ip=test_ip(4, 1)) m2_lag1 = m2.create_bond(slaves=[m2_if1, m2_if2], options=bond_options, ip=test_ip(1, 2)) m2_lag1_10 = m2.create_vlan(m2_lag1, 10, ip=test_ip(2, 2)) m2_lag1_21 = m2.create_vlan(m2_lag1, 21, ip=test_ip(3, 2)) m2_lag1_30 = m2.create_vlan(m2_lag1, 30, ip=test_ip(4, 2)) 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) br_options = {"vlan_filtering": 1, "multicast_querier": 1} sw.create_bridge(slaves=[sw_lag1, sw_lag2], options=br_options) sw_lag1_10 = sw.create_vlan(sw_lag1, 10) sw_lag2_10 = sw.create_vlan(sw_lag2, 10) sw.create_bridge(slaves=[sw_lag1_10, sw_lag2_10], options={"multicast_querier": 1}) sw_lag1_20 = sw.create_vlan(sw_lag1, 20) sw_lag2_21 = sw.create_vlan(sw_lag2, 21) sw.create_bridge(slaves=[sw_lag1_20, sw_lag2_21], options={"multicast_querier": 1}) sleep(30) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.ping_simple(m1_lag1_10, m2_lag1_10) tl.ping_simple(m1_lag1_20, m2_lag1_21) tl.ping_simple(m1_lag1_30, m2_lag1_30, fail_expected=True)
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"]) sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1, "multicast_snooping": 0}) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) tl.ping_simple(m1_if1, m2_if1)
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_br = sw.create_bridge(slaves=[sw_if1, sw_if2, sw_if3, sw_if4], options={"vlan_filtering": 1}) m1_if.set_addresses(["192.168.101.10/24", "2002::1/64"]) m2_if.set_addresses(["192.168.101.11/24", "2002::2/64"]) m3_if.set_addresses(["192.168.101.13/24", "2002::3/64"]) m4_if.set_addresses(["192.168.101.14/24", "2002::4/64"]) sleep(15) tl = TestLib(ctl, aliases) tl.iperf_mc(m1_if, [m2_if, m4_if], [m3_if], "239.255.1.3") tl.iperf_mc(m1_if, [m4_if], [], "239.255.1.4") tl.iperf_mc(m2_if, [m3_if, m4_if, m1_if] , [], "239.255.1.5")
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, []))]) sleep(30) tl = TestLib(ctl, aliases) 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, 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}) 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, sw = hosts m1_if1, m1_if2, m1_if3, m1_if4, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"]) m1_if2.reset(ip=["192.168.102.10/24", "2003::1/64"]) m1_if3.reset(ip=["192.168.103.10/24", "2004::1/64"]) m1_if4.reset(ip=["192.168.104.10/24", "2005::1/64"]) sw_if1.reset(ip=["192.168.101.11/24", "2002::2/64"]) sw_if2.reset(ip=["192.168.102.11/24", "2003::2/64"]) sw_if3.reset(ip=["192.168.103.11/24", "2004::2/64"]) sw_if4.reset(ip=["192.168.104.11/24", "2005::2/64"]) sleep(30) tl = TestLib(ctl, aliases) for (if1, if2) in [(sw_if1, m1_if1), (sw_if2, m1_if2), (sw_if3, m1_if3), (sw_if4, m1_if4)]: linkneg(tl, if1, if2) linkneg(tl, if2, if1)
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="2 2 0 0 1 1 1") sleep(30) logging.info("Start traffic in band 1") prio_test.send_bg_traffic(6) sleep(60) logging.info("Send traffic in band 0 (should pass)") prio_test.check_traffic_passes(2, True) logging.info("Send traffic in band 2 (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, 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,[]))]); 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, 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) # add an (S,G) route evifs = [0, 1, 2] sg = mt.mroute_create(ipv4(test_ip(5,2)), mcgrp(1), 4, evifs) # remove RIF mt.del_rif(sw_if3) # add it back mt.add_rif(sw_if3) sleep(90) mt.mroute_test(sg) # remove another RIF mt.del_rif(sw_if1) mt.mroute_remove(sg) mt.fini() return
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}) sleep(15) 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, sw, m2 = hosts m1_if1, sw_if1, sw_if2, sw_if3, sw_if4, sw_if5, m2_if1, m2_if2, m2_if3, \ m2_if4, m2_if5, m3_if1 = ifaces ecmp_sw_ifaces = [sw_if2, sw_if3, sw_if4, sw_if5] ecmp_m_ifaces = [m2_if1, m2_if2, m2_if3, m2_if4] m2.config("/proc/sys/net/ipv4/ip_forward", "1") ecmp_common.create_topology(m1_if1, sw_if1, ecmp_sw_ifaces, ecmp_m_ifaces, m2_if5, m3_if1) sleep(30) tl = TestLib(ctl, aliases) 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)
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() mt.add_vif(sw_if1, 0) mt.send_mc_traffic(mcgrp(1), m1_if1, 1) tl.expect_mr_notif(sw, MROUTE.NOTIF_NOCACHE, m1_if1.get_ip(0), 0, mcgrp(1)) mt.fini()
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)) m1_lag1_10 = m1.create_vlan(m1_lag1, 10, ip=test_ip(2, 1)) m1_lag1_20 = m1.create_vlan(m1_lag1, 20, ip=test_ip(3, 1)) m1_lag1_30 = m1.create_vlan(m1_lag1, 30, ip=test_ip(4, 1)) m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config, ip=test_ip(1, 2)) m2_lag1_10 = m2.create_vlan(m2_lag1, 10, ip=test_ip(2, 2)) m2_lag1_21 = m2.create_vlan(m2_lag1, 21, ip=test_ip(3, 2)) m2_lag1_30 = m2.create_vlan(m2_lag1, 30, ip=test_ip(4, 2)) 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) br_options = {"vlan_filtering": 1} sw.create_bridge(slaves=[sw_lag1, sw_lag2], options=br_options) sw_lag1_10 = sw.create_vlan(sw_lag1, 10) sw_lag2_10 = sw.create_vlan(sw_lag2, 10) sw.create_bridge(slaves=[sw_lag1_10, sw_lag2_10], options=br_options) sw_lag1_20 = sw.create_vlan(sw_lag1, 20) sw_lag2_21 = sw.create_vlan(sw_lag2, 21) sw.create_bridge(slaves=[sw_lag1_20, sw_lag2_21], options=br_options) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.ping_simple(m1_lag1_10, m2_lag1_10) tl.ping_simple(m1_lag1_20, m2_lag1_21) tl.ping_simple(m1_lag1_30, m2_lag1_30, fail_expected=True)
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" weight0 = int(aliases["weight0"]) weight1 = int(aliases["weight1"]) 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} " "weight {w0} nexthop via {gw_ip1} dev {nh_dev1} weight {w1}") sw.run( cmd.format(subnet=subnet3, gw_ip0=m2_if1.get_ip(0), nh_dev0=sw_if2.get_devname(), w0=weight0, gw_ip1=m2_if2.get_ip(0), nh_dev1=sw_if3.get_devname(), w1=weight1)) # Make sure the kernel uses L4 fields for multipath hash, since we # are going to use random UDP source and destination ports. sw.run("sysctl -w net.ipv4.fib_multipath_hash_policy=1") sleep(30) # Basic sanity check to make sure test is not failing due to # setup issues. ping(ctl, m1_if1, m2_if2) if2_pre = sw_if2.link_stats()["tx_packets"] if3_pre = sw_if3.link_stats()["tx_packets"] # Send different flows from m1 to m2, so that traffic is hashed # according to provided weights. pktgen(ctl, m1_if1, m2_if2, sw_if1.get_hwaddr()) if2_post = sw_if2.link_stats()["tx_packets"] if3_post = sw_if3.link_stats()["tx_packets"] check_res(tl, m1, weight0, weight1, if2_post - if2_pre, if3_post - if3_pre)
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, m2_if1, sw_if1, sw_if2 = ifaces m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(1,1)) m2_if1_20 = m2.create_vlan(m2_if1, 20, ip=test_ip(1,2)) sw_if1_10 = sw.create_vlan(sw_if1, 10) sw_if2_20 = sw.create_vlan(sw_if2, 20) # Ageing time is 10 seconds. br_options = {"vlan_filtering": 0, "ageing_time": 1000} sw_br = sw.create_bridge(slaves = [sw_if1_10, sw_if2_20], options=br_options) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software") tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") sleep(20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False) # Disable learning and make sure FDB is not populated. sw_if1_10.set_br_learning(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False) # Disable flooding and make sure ping fails. sw_if1_10.set_br_flooding(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True) # Set a static FDB entry and make sure ping works again. sw_if1_10.add_br_fdb(str(m1_if1_10.get_hwaddr()), self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") # Remove static FDB entry. Ping should fail. sw_if1_10.del_br_fdb(str(m1_if1_10.get_hwaddr()), self=True) tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False) # Enable learning_sync and make sure both FDBs are populated. sw_if1_10.set_br_learning(on=True, self=True) sw_if1_10.set_br_flooding(on=True, self=True) sw_if1_10.set_br_learning_sync(on=True, self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software") tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") sleep(20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False) # Disable learning_sync and make sure only hardware FDB is populated. sw_if1_10.set_br_learning_sync(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") # Remove port from bridge and add it back. Disable flooding and learning # and make sure ping doesn't work. Note that port must be removed from # bridge when the FDB entry exists only in the hardware table. Otherwise, # bridge code will flush it himself, instead of driver. sw_br.slave_del(sw_if1_10.get_id()) sw_br.slave_add(sw_if1_10.get_id()) # Enables learning sync by default. sw_if1_10.set_br_learning(on=False, self=True) sw_if1_10.set_br_flooding(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True) # Enable learning and make sure ping works again. sw_if1_10.set_br_learning(on=True, self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software") tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") sleep(20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False) # Insert a static FDB entry and disable learning sync. Ping should work. sw_if1_10.add_br_fdb(str(m1_if1_10.get_hwaddr()), self=True) sw_if1_10.set_br_learning_sync(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") sleep(20) # Make sure static entry is not aged out. tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False) tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware") # Remove port from bridge and add it back. Disable flooding and learning # and make sure ping doesn't work. Note that port must be removed from # bridge when the FDB entry exists only in the hardware table. Otherwise, # bridge code will flush it himself, instead of driver. Unlike the # previous case, here we check if the driver correctly removes the static # entry. sw_br.slave_del(sw_if1_10.get_id()) sw_br.slave_add(sw_if1_10.get_id()) sw_if1_10.set_br_learning(on=False, self=True) sw_if1_10.set_br_flooding(on=False, self=True) tl.ping_simple(m1_if1_10, m2_if1_20, 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 team_config = '{"runner" : {"name" : "lacp"}}' m1_lag1 = m1.create_team(slaves=[m1_if1, m1_if2], config=team_config, ip=test_ip(1, 1)) m1_lag1_10 = m1.create_vlan(m1_lag1, 10, ip=test_ip(2, 1)) m1_lag1_20 = m1.create_vlan(m1_lag1, 20, ip=test_ip(3, 1)) m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config, ip=test_ip(1, 2)) m2_lag1_10 = m2.create_vlan(m2_lag1, 10, ip=test_ip(2, 2)) m2_lag1_21 = m2.create_vlan(m2_lag1, 21, ip=test_ip(3, 2)) 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) br_options = {"vlan_filtering": 1} sw_br1 = sw.create_bridge(slaves=[sw_lag1, sw_lag2], options=br_options) sw_lag1_10 = sw.create_vlan(sw_lag1, 10) sw_lag2_10 = sw.create_vlan(sw_lag2, 10) sw_br2 = sw.create_bridge(slaves=[sw_lag1_10, sw_lag2_10], options=br_options) sw_lag1_20 = sw.create_vlan(sw_lag1, 20) sw_lag2_21 = sw.create_vlan(sw_lag2, 21) sw_br3 = sw.create_bridge(slaves=[sw_lag1_20, sw_lag2_21], options=br_options) sleep(15) 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) tl.ping_simple(m1_lag1_10, m2_lag1_10) tl.netperf_tcp(m1_lag1_10, m2_lag1_10) tl.netperf_udp(m1_lag1_10, m2_lag1_10) tl.ping_simple(m1_lag1_20, m2_lag1_21) tl.netperf_tcp(m1_lag1_20, m2_lag1_21) tl.netperf_udp(m1_lag1_20, m2_lag1_21) 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=test_ip(4, 1)) m1_if1.reset(ip=test_ip(4, 2)) sleep(15) tl.ping_simple(sw_if1, m1_if1) # Repopulate the LAGs and make sure fastpath is OK. sw_lag3 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config) sw_br1.slave_add(sw_lag3.get_id()) sw_lag3_10 = sw.create_vlan(sw_lag3, 10) sw_br2.slave_add(sw_lag3_10.get_id()) sw_lag3_20 = sw.create_vlan(sw_lag3, 20) sw_br3.slave_add(sw_lag3_20.get_id()) m1_lag1.slave_add(m1_if1.get_id()) sleep(15) tl.ping_simple(m1_lag1, m2_lag1) tl.netperf_tcp(m1_lag1, m2_lag1) tl.netperf_udp(m1_lag1, m2_lag1) tl.ping_simple(m1_lag1_10, m2_lag1_10) tl.netperf_tcp(m1_lag1_10, m2_lag1_10) tl.netperf_udp(m1_lag1_10, m2_lag1_10) tl.ping_simple(m1_lag1_20, m2_lag1_21) tl.netperf_tcp(m1_lag1_20, m2_lag1_21) tl.netperf_udp(m1_lag1_20, m2_lag1_21)
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)) sleep(15) tl = TestLib(ctl, aliases) for iface in [m1_if, m2_if, m3_if, m4_if]: iface.enable_multicast() logging.info("%s join %s" % (m3_if.get_devname(), mcgrp(1))) s_procs_1 = [tl.iperf_mc_listen(m3_if, mcgrp(1))] logging.info("%s and %s join %s" % (m2_if.get_devname(), m3_if.get_devname(), mcgrp(2))) s_procs_2 = [tl.iperf_mc_listen(listener, mcgrp(2)) for listener in [m2_if, m3_if]] tl._ctl.wait(2) logging.info("set mrouter on") mcast_iface = [m2_if, m3_if, m4_if] sw_if2.set_mcast_router(MCAST_ROUTER_PORT.FIXED_ON) logging.info("check registered mid flood") tl.check_cpu_traffic(sw_ports, test=False) result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(1)) tl.mc_ipref_compare_result(mcast_iface, result, [True, True, False]) tl.check_cpu_traffic(sw_ports) logging.info("check registered mid with mrouter flood") result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(2)) tl.mc_ipref_compare_result(mcast_iface, result, [True, True, False]) tl.check_cpu_traffic(sw_ports) logging.info("check unregistered mc flood") result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(3)) tl.mc_ipref_compare_result(mcast_iface, result, [True, False, False]) tl.check_cpu_traffic(sw_ports) logging.info("set mrouter off") sw_if2.set_mcast_router(MCAST_ROUTER_PORT.FIXED_OFF) tl._ctl.wait(2) logging.info("check registered mid flood") 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) logging.info("check registered mid with mrouter flood") result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(2)) tl.mc_ipref_compare_result(mcast_iface, result, [True, True, False]) tl.check_cpu_traffic(sw_ports) logging.info("check unregistered mc flood") result = tl.iperf_mc(m1_if, mcast_iface, mcgrp(3)) tl.mc_ipref_compare_result(mcast_iface, result, [False, False, False]) tl.check_cpu_traffic(sw_ports) sw_if2.set_mcast_router(MCAST_ROUTER_PORT.LEARNING) for proc in s_procs_1 + s_procs_2: proc.intr() for iface in mcast_iface: 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.reset(ip=test_ip(1, 1)) m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(2, 1)) m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=test_ip(3, 1)) m1_if1_30 = m1.create_vlan(m1_if1, 30, ip=test_ip(4, 1)) m2_if1.reset(ip=test_ip(1, 2)) m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 2)) m2_if1_20 = m2.create_vlan(m2_if1, 20, ip=test_ip(3, 2)) m2_if1_30 = m2.create_vlan(m2_if1, 30, ip=test_ip(4, 2)) sw_if1.reset(ip=test_ip(1, 3)) br_options = {"vlan_filtering": 1} sw_br = sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options) sw_if1.add_br_vlan(10) sw_if2.add_br_vlan(10) sw_if1.add_br_vlan(20) sw_if2.add_br_vlan(20) sleep(15) tl = TestLib(ctl, aliases) check_vlan(tl, sw_if1, 10) check_vlan(tl, sw_if2, 10) check_vlan(tl, sw_if1, 20) check_vlan(tl, sw_if2, 20) tl.ping_simple(m1_if1, m2_if1) tl.ping_simple(m1_if1_10, m2_if1_10) tl.ping_simple(m1_if1_20, m2_if1_20) tl.ping_simple(m1_if1_30, m2_if1_30, fail_expected=True) sw_if1.add_br_vlan(500, pvid=True, untagged=True) check_vlan(tl, sw_if1, 500, pvid=True, untagged=True) sleep(1) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) sw_if2.add_br_vlan(500, pvid=True, untagged=True) check_vlan(tl, sw_if2, 500, pvid=True, untagged=True) sleep(1) tl.ping_simple(m1_if1, m2_if1) sw_if2.add_br_vlan(500, pvid=True, untagged=False) sleep(1) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) sw_if2.add_br_vlan(500, pvid=True, untagged=True) sleep(1) tl.ping_simple(m1_if1, m2_if1) sw_if2.add_br_vlan(500, pvid=False, untagged=True) sleep(1) tl.ping_simple(m1_if1, m2_if1, fail_expected=True) sw_if2.add_br_vlan(500, pvid=True, untagged=True) sleep(1) tl.ping_simple(m1_if1, m2_if1) sw_br.slave_del(sw_if1.get_id()) sleep(5) tl.ping_simple(sw_if1, m1_if1)
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_snooping": 0 }) tl = TestLib(ctl, aliases) tl.wait_for_if(ifaces) 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"]) tl.wait_for_if([sw_if1, m1_if1]) 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()) tl.wait_for_if(ifaces) 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, 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}) sleep(15) 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(15) 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(15) 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 m1_if1.reset(ip=test_ip(1, 1)) m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(2, 1)) m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=test_ip(3, 1)) m2_if1.reset(ip=test_ip(1, 2)) m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 2)) m2_if1_21 = m2.create_vlan(m2_if1, 21, ip=test_ip(3, 2)) br_options = {"vlan_filtering": 1} sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options) sw_if1_10 = sw.create_vlan(sw_if1, 10) sw_if2_10 = sw.create_vlan(sw_if2, 10) sw.create_bridge(slaves=[sw_if1_10, sw_if2_10], options=br_options) sw_if1_20 = sw.create_vlan(sw_if1, 20) sw_if2_21 = sw.create_vlan(sw_if2, 21) sw.create_bridge(slaves=[sw_if1_20, sw_if2_21], options=br_options) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_if1, m2_if1) tl.netperf_tcp(m1_if1, m2_if1) tl.netperf_udp(m1_if1, m2_if1) 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) tl.ping_simple(m1_if1_20, m2_if1_21) tl.netperf_tcp(m1_if1_20, m2_if1_21) tl.netperf_udp(m1_if1_20, m2_if1_21)
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) # Ageing time is 10 seconds. br_options = {"vlan_filtering": 1, "ageing_time": 1000} sw_br = sw.create_bridge(slaves = [sw_lag1, sw_lag2], options=br_options) sleep(15) tl = TestLib(ctl, aliases) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software") tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") sleep(20) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False) # Disable learning and make sure FDB is not populated. sw_lag1.set_br_learning(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False) # Disable flooding and make sure ping fails. sw_lag1.set_br_flooding(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True) # Set a static FDB entry and make sure ping works again. sw_lag1.add_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") # Remove static FDB entry. Ping should fail. sw_lag1.del_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1) tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False) # Enable learning_sync and make sure both FDBs are populated. sw_lag1.set_br_learning(on=True, self=True) sw_lag1.set_br_flooding(on=True, self=True) sw_lag1.set_br_learning_sync(on=True, self=True) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software") tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") sleep(20) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False) # Disable learning_sync and make sure only hardware FDB is populated. sw_lag1.set_br_learning_sync(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") # Remove port from bridge and add it back. Disable flooding and learning # and make sure ping doesn't work. Note that port must be removed from # bridge when the FDB entry exists only in the hardware table. Otherwise, # bridge code will flush it himself, instead of driver. sw_br.slave_del(sw_lag1.get_id()) sw_br.slave_add(sw_lag1.get_id()) # Enables learning sync by default. sw_lag1.set_br_learning(on=False, self=True) sw_lag1.set_br_flooding(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True) # Enable learning and make sure ping works again. sw_lag1.set_br_learning(on=True, self=True) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software") tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") sleep(20) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False) # Insert a static FDB entry and disable learning sync. Ping should work. sw_lag1.add_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1) sw_lag1.set_br_learning_sync(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") sleep(20) # Make sure static entry is not aged out. tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False) tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware") # Remove port from bridge and add it back. Disable flooding and learning # and make sure ping doesn't work. Note that port must be removed from # bridge when the FDB entry exists only in the hardware table. Otherwise, # bridge code will flush it himself, instead of driver. Unlike the # previous case, here we check if the driver correctly removes the static # entry. sw_br.slave_del(sw_lag1.get_id()) sw_br.slave_add(sw_lag1.get_id()) sw_lag1.set_br_learning(on=False, self=True) sw_lag1.set_br_flooding(on=False, self=True) tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True)