Esempio n. 1
0
    def _update_netlink(self, nl_msg):
        if getattr(self, "_deleted"):
            raise DeviceDeleted("Device was deleted.")

        if self.ifindex != nl_msg['index']:
            msg = "ifindex of netlink message (%s) doesn't match "\
                  "the device's (%s)." % (nl_msg['index'], self.ifindex)
            raise DeviceError(msg)

        if nl_msg['header']['type'] == RTM_NEWLINK:
            self._nl_msg = nl_msg
        elif nl_msg['header']['type'] == RTM_NEWADDR:
            if nl_msg['family'] == AF_INET:
                """
                from if_addr.h:
                /*
                 * Important comment:
                 * IFA_ADDRESS is prefix address, rather than local interface address.
                 * It makes no difference for normally configured broadcast interfaces,
                 * but for point-to-point IFA_ADDRESS is DESTINATION address,
                 * local address is supplied in IFA_LOCAL attribute.
                 */
                """
                addr = ipaddress(nl_msg.get_attr('IFA_LOCAL'),
                                 flags=nl_msg.get_attr("IFA_FLAGS"))
            else:
                addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS'),
                                 flags=nl_msg.get_attr("IFA_FLAGS"))

            addr.prefixlen = nl_msg["prefixlen"]

            if addr not in self._ip_addrs:
                self._ip_addrs.append(addr)
            else:
                old_idx = self._ip_addrs.index(addr)
                addr_old = self._ip_addrs[old_idx]
                if addr.flags != addr_old.flags:
                    self._ip_addrs.pop(old_idx)
                    self._ip_addrs.append(addr)

        elif nl_msg['header']['type'] == RTM_DELADDR:
            addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS'))
            addr.prefixlen = nl_msg["prefixlen"]

            if addr in self._ip_addrs:
                self._ip_addrs.remove(addr)
Esempio n. 2
0
    def test_wide_configuration(self):
        host1, host2, guest1, guest2 = (self.matched.host1,
            self.matched.host2, self.matched.guest1, self.matched.guest2)

        for host in [host1, host2]:
            host.br0 = BridgeDevice()
            for dev in [host.eth0, host.tap0]:
                dev.down()
                host.br0.slave_add(dev)

        guest1.eth0.down()
        guest2.eth0.down()

        guest1.vlan0 = VlanDevice(realdev=guest1.eth0, vlan_id=10)
        guest2.vlan0 = VlanDevice(realdev=guest2.eth0, vlan_id=10)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [guest1.vlan0, guest2.vlan0,
            host1.br0, host2.br0]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"
        host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
        host2.br0.ip_add(ipaddress(net_addr_1 + ".2/24"))

        for i, guest in enumerate([guest1, guest2]):
            guest.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
                "/24"))
            guest.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
                "/64"))

        for host in [host1, host2]:
            for dev in [host.eth0, host.tap0, host.br0]:
                dev.up()
        for guest in [guest1, guest2]:
            guest.eth0.up()
            guest.vlan0.up()

        if "perf_tool_cpu" in self.params:
            logging.info("'perf_tool_cpu' param (%d) to be set to None" %
                self.params.perf_tool_cpu)
            self.params.perf_tool_cpu = None

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 3
0
    def test_wide_configuration(self):
        host1, host2, guest1 = (self.matched.host1, self.matched.host2,
                                self.matched.guest1)

        for dev in [host1.eth0, host2.eth0, guest1.eth0, host1.tap0]:
            dev.down()

        net_addr = "192.168.0"
        vxlan_net_addr = "192.168.100"
        vxlan_net_addr6 = "fc00:0:0:0"
        #TODO: Enable usage of a proper address (like 239.1.1.1)
        vxlan_group_ip = "192.168.0.3"

        host1.br0 = BridgeDevice()
        host1.br0.slave_add(host1.eth0)
        host1.br0.slave_add(host1.tap0)

        for machine in [host1, guest1, host2]:
            machine.vxlan0 = VxlanDevice(vxlan_id=1, group=vxlan_group_ip)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [
            host1.br0, host1.vxlan0, guest1.eth0, guest1.vxlan0, host2.eth0,
            host2.vxlan0
        ]

        for i, (machine, dev) in enumerate([(host1, host1.br0),
                                            (guest1, guest1.eth0),
                                            (host2, host2.eth0)]):
            dev.ip_add(ipaddress(net_addr + "." + str(i + 1) + "/24"))
            machine.vxlan0.realdev = dev
            machine.vxlan0.ip_add(
                ipaddress(vxlan_net_addr + "." + str(i + 1) + "/24"))
            machine.vxlan0.ip_add(
                ipaddress(vxlan_net_addr6 + "::" + str(i + 1) + "/64"))

        for dev in [
                host1.eth0, host2.eth0, guest1.eth0, host1.tap0, host1.br0,
                host1.vxlan0, host2.vxlan0, guest1.vxlan0
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 4
0
    def create_tunnel(self, configuration):
        """
        OvS bridges are created on each of the matched hosts with two ports.
        One port as an integration port and another port of type VXLAN acting
        as a tunnel interface connecting tunneled networks.

        Integration ports are configured with IPv4 and IPv6 addresses
        of the tunneled networks.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        ip_filter = {"family": AF_INET}

        for i, (host, endpoint) in enumerate([(m1, endpoint2), (m2, endpoint1)]):
            remote_ip = endpoint.ips_filter(**ip_filter)[0]
            host.br0 = OvsBridgeDevice()
            host.int0 = host.br0.port_add(
                interface_options={"type": "internal", "ofport_request": 5}
            )
            configuration.tunnel_devices.append(host.int0)
            host.int0.ip_add(ipaddress("192.168.200." + str(i + 1) + "/24"))
            host.int0.ip_add(ipaddress("fc00::" + str(i + 1) + "/64"))

            host.br0.tunnel_add(
                "vxlan",
                {
                    "options:remote_ip": remote_ip,
                    "options:key": "flow",
                    "ofport_request": 10,
                },
            )

            host.br0.flows_add(
                [
                    "table=0,in_port=5,actions=set_field:1234->tun_id,output:10",
                    "table=0,in_port=10,tun_id=1234,actions=output:5",
                    "table=0,priority=100,actions=drop",
                ]
            )

            host.br0.up()
            host.int0.up()

        self.wait_tentative_ips(configuration.tunnel_devices)
Esempio n. 5
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        net_addr = "192.168.2"
        vxlan_net_addr = "192.168.100"
        vxlan_net_addr6 = "fc00:0:0:0"

        flow_entries = []
        flow_entries.append("table=0,in_port=5,actions=set_field:100->"
                            "tun_id,output:10")
        flow_entries.append("table=0,in_port=10,tun_id=100,actions="
                            "output:5")
        flow_entries.append("table=0,priority=100,actions=drop")

        for i, host in enumerate([host1, host2]):
            host.eth0.down()
            host.eth0.ip_add(ipaddress(net_addr + "." + str(i + 1) + "/24"))
            host.br0 = OvsBridgeDevice()
            host.int0 = host.br0.internal_port_add(ofport_request='5',
                                                   name="int0")
            host.int0.ip_add(
                ipaddress(vxlan_net_addr + "." + str(i + 1) + "/24"))
            host.int0.ip_add(
                ipaddress(vxlan_net_addr6 + "::" + str(i + 1) + "/64"))
            tunnel_opts = {
                "option:remote_ip": net_addr + "." + str(2 - i),
                "option:key": "flow",
                "ofport_request": "10"
            }
            host.br0.tunnel_add("vxlan", tunnel_opts)
            host.br0.flows_add(flow_entries)
            host.eth0.up()
            host.int0.up()
            host.br0.up()

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [
            host1.eth0, host1.int0, host2.eth0, host2.int0
        ]

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 6
0
    def configure_underlying_network(self, configuration):
        """
        The underlying network for the tunnel consists of

        - an Ethernet device on each of the matched hosts
        - a pair of veth devices on each host with one end of the pair
          connected to Ethernet device through bridge and the second one
          moved to a network namespace

        The veth devices in the namespaces are assigned an IPv6 address and
        will be used as tunnel endpoints
        """
        host1, host2 = self.matched.host1, self.matched.host2

        host1.newns = NetNamespace("host1-net1")
        host2.newns = NetNamespace("host2-net1")

        # veth_pair
        host1.veth0, host1.veth1 = VethPair()
        host2.veth0, host2.veth1 = VethPair()

        # one veth end to netns
        host1.newns.veth1 = host1.veth1
        host2.newns.veth1 = host2.veth1

        # second veth bridged with NIC
        host1.bridge = BridgeDevice()
        host1.bridge.slave_add(host1.veth0)
        host1.bridge.slave_add(host1.eth0)
        host2.bridge = BridgeDevice()
        host2.bridge.slave_add(host2.veth0)
        host2.bridge.slave_add(host2.eth0)

        for device in [
                host1.veth0,
                host2.veth0,
                host1.bridge,
                host2.bridge,
                host1.eth0,
                host2.eth0,
        ]:
            device.up()
            configuration.test_wide_devices.append(device)

        for i, device in enumerate([host1.newns.veth1, host2.newns.veth1]):
            device.ip_add(ipaddress("fc00:0:0:0::" + str(i + 1) + "/64"))
            device.up()
            configuration.test_wide_devices.append(device)

        for i, device in enumerate([host1.veth0, host2.veth0]):
            device.up()

        self.wait_tentative_ips(configuration.test_wide_devices)
        configuration.tunnel_endpoints = (host1.newns.veth1, host2.newns.veth1)
Esempio n. 7
0
    def __init__(self, ifmanager, *args, **kwargs):
        if "group" in kwargs and "remote" in kwargs:
            raise DeviceError(
                "group and remote cannot both be specified for vxlan")

        if "group" not in kwargs and "remote" not in kwargs:
            raise DeviceError(
                "One of group or remote must be specified for vxlan")

        if kwargs.get("remote", False) and ipaddress(
                kwargs["remote"]).is_multicast:
            logging.debug("ATTENTION: non-unicast remote IP set: %s" %
                          str(kwargs["remote"]))

        if kwargs.get("group",
                      False) and not ipaddress(kwargs["group"]).is_multicast:
            logging.debug("ATTENTION: non-multicast group IP set: %s" %
                          str(kwargs["group"]))

        super(VxlanDevice, self).__init__(ifmanager, *args, **kwargs)
    def test_wide_configuration(self):
        host1, host2, guest1 = (self.matched.host1, self.matched.host2,
                                self.matched.guest1)

        host1.br0 = BridgeDevice()
        for dev in [host1.eth0, host1.tap0]:
            dev.down()
            host1.br0.slave_add(dev)

        host2.eth0.down()
        guest1.eth0.down()

        host2.vlan0 = VlanDevice(realdev=host2.eth0,
                                 vlan_id=self.params.vlan_id)
        guest1.vlan0 = VlanDevice(realdev=guest1.eth0,
                                  vlan_id=self.params.vlan_id)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [
            guest1.vlan0, host1.br0, host2.vlan0
        ]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"

        host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
        for i, machine in enumerate([host2, guest1]):
            machine.vlan0.ip_add(
                ipaddress(net_addr_1 + "." + str(i + 2) + "/24"))
            machine.vlan0.ip_add(
                ipaddress(net_addr6_1 + "::" + str(i + 2) + "/64"))

        for dev in [
                host1.eth0, host1.tap0, host1.br0, host2.eth0, host2.vlan0,
                guest1.eth0, guest1.vlan0
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 9
0
    def arp_ip_target(self, val):
        if isinstance(val, list):
            new = []
            for i in val:
                try:
                    new.append(str(ipaddress(i)))
                except:
                    DeviceError(
                        "Invalid value, expected a list of ip addresses")
        elif val is None:
            new = []
        else:
            try:
                new = [ipaddress(val)]
            except:
                raise DeviceError(
                    "Invalid value, expected a list of ip addresses")

        ip_str = ",".join(new)
        self._set_linkinfo_data_attr("IFLA_BOND_ARP_IP_TARGET", ip_str)
        self._nl_link_sync("set")
Esempio n. 10
0
    def configure_underlying_network(self, configuration):
        """
        The underlying network for the tunnel consists of the Ethernet
        devices on the matched hosts.
        """
        host1, host2 = self.matched.host1, self.matched.host2
        for i, device in enumerate([host1.eth0, host2.eth0]):
            device.ip_add(ipaddress("192.168.101." + str(i + 1) + "/24"))
            device.up()
            configuration.test_wide_devices.append(device)

        configuration.tunnel_endpoints = (host1.eth0, host2.eth0)
Esempio n. 11
0
    def test_wide_configuration(self):
        host1, host2, guest1 = (self.matched.host1, self.matched.host2,
                                self.matched.guest1)

        host1.eth0.down()
        host1.tap0.down()
        host1.br0 = BridgeDevice()
        host1.br0.slave_add(host1.tap0)

        host2.eth0.down()
        guest1.eth0.down()

        host1_vlan_args0 = dict()
        host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10)

        host1.vlan0 = VlanDevice(realdev=host1.eth0,
                                 vlan_id=10,
                                 master=host1.br0)
        host2.vlan0 = VlanDevice(**host2_vlan_args0)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [guest1.eth0, host2.vlan0, host1.br0]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"

        host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
        for i, dev in enumerate([host2.vlan0, guest1.eth0]):
            dev.ip_add(ipaddress(net_addr_1 + "." + str(i + 2) + "/24"))
            dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i + 2) + "/64"))

        for dev in [
                host1.eth0, host1.tap0, host1.vlan0, host1.br0, host2.eth0,
                host2.vlan0, guest1.eth0
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 12
0
    def ip_del(self, addr):
        """remove an ip address

        Args:
            addr -- an address accepted by the ipaddress factory method
        """
        ip = ipaddress(addr)
        if ip in self.ips:
            self._ipr_wrapper("addr",
                              "del",
                              index=self.ifindex,
                              address=str(ip),
                              mask=ip.prefixlen)
Esempio n. 13
0
    def test_wide_configuration(self):
        """
        Test wide configuration for this recipe involves just adding an IPv4 and
        IPv6 address to the matched eth0 nics on both hosts.

        host1.eth0 = 192.168.101.1/24 and fc00::1/64

        host2.eth0 = 192.168.101.2/24 and fc00::2/64
        """
        host1, host2 = self.matched.host1, self.matched.host2
        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = []

        for i, host in enumerate([host1, host2]):
            host.eth0.ip_add(ipaddress("192.168.101." + str(i + 1) + "/24"))
            host.eth0.ip_add(ipaddress("fc00::" + str(i + 1) + "/64"))
            host.eth0.up()
            configuration.test_wide_devices.append(host.eth0)

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 14
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        net_addr = "192.168.101"
        net_addr6 = "fc00:0:0:0"
        for i, host in enumerate([host1, host2]):
            host.bond0 = BondDevice(mode=self.params.bonding_mode,
                                    miimon=self.params.miimon_value)
            for dev in [host.eth0, host.eth1]:
                dev.down()
                host.bond0.slave_add(dev)
            host.bond0.ip_add(ipaddress(net_addr + "." + str(i + 1) + "/24"))
            host.bond0.ip_add(ipaddress(net_addr6 + "::" + str(i + 1) + "/64"))
            for dev in [host.eth0, host.eth1, host.bond0]:
                dev.up()

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [host1.bond0, host2.bond0]

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 15
0
    def test_wide_configuration(self):
        """
        Test wide configuration for this recipe involves just adding an IPv4 and
        IPv6 address to the matched eth0 nics on both hosts and route between them.

        host1.eth0 = 192.168.101.1/24 and fc00::1/64

        host2.eth0 = 192.168.101.2/24 and fc00::2/64
        """
        host1, host2 = self.matched.host1, self.matched.host2

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [host1.eth0, host2.eth0]

        net_addr = "192.168."
        net_addr6 = "fc00:"
        for i, host in enumerate([host1, host2]):
            host.eth0.down()
            host.eth0.ip_add(ipaddress(net_addr + str(i + 99) + ".1/24"))
            host.eth0.ip_add(ipaddress(net_addr6 + str(i + 1) + "::1/64"))
            host.eth0.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        if self.params.ping_parallel or self.params.ping_bidirect:
            logging.debug(
                "Parallelism in pings is not supported for this "
                "recipe, ping_parallel/ping_bidirect will be ignored.")

        for host, dst in [(host1, host2), (host2, host1)]:
            for family in [AF_INET, AF_INET6]:
                host.run(
                    "ip route add %s dev %s" %
                    (dst.eth0.ips_filter(family=family)[0], host.eth0.name))

        configuration.endpoint1 = host1.eth0
        configuration.endpoint2 = host2.eth0

        return configuration
Esempio n. 16
0
    def test_wide_configuration(self):
        host1, host2, guest1, guest2 = (self.matched.host1,
            self.matched.host2, self.matched.guest1, self.matched.guest2)

        for host in [host1, host2]:
            host.br0 = OvsBridgeDevice()
            host.eth0.down()
            host.tap0.down()
            host.br0.port_add(host.eth0)
            host.br0.port_add(host.tap0, port_options={'tag': self.params.vlan_id})

        guest1.eth0.down()
        guest2.eth0.down()

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [guest1.eth0, guest2.eth0]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"
        for i, guest in enumerate([guest1, guest2]):
            guest.eth0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
                "/24"))
            guest.eth0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
                "/64"))

        for host in [host1, host2]:
            for dev in [host.eth0, host.tap0, host.br0]:
                dev.up()
        guest1.eth0.up()
        guest2.eth0.up()

        if "perf_tool_cpu" in self.params:
            logging.info("'perf_tool_cpu' param (%d) to be set to None" %
                self.params.perf_tool_cpu)
            self.params.perf_tool_cpu = None

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 17
0
    def _prepare_server(self, flow: Flow) -> Job:
        host = flow.receiver
        server_params = dict(workload = flow.type,
                             bind = ipaddress(flow.receiver_bind),
                             test_length = flow.duration)

        self._set_cpupin_params(server_params, flow.cpupin)

        if flow.msg_size:
            server_params["request_size"] = flow.msg_size
            server_params["response_size"] = flow.msg_size

        return host.prepare_job(NeperServer(**server_params),
                                job_level=ResultLevel.NORMAL)
Esempio n. 18
0
    def create_tunnel(self, configuration):
        """
        The ip6tnl tunnel devices are configured with IPv6 addresses.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        ip_filter = {"family": AF_INET6}
        endpoint1_ip = endpoint1.ips_filter(**ip_filter)[0]
        endpoint2_ip = endpoint2.ips_filter(**ip_filter)[0]

        a_ip6 = ipaddress("3001:db8:ac10:fe01::2/64")
        b_ip6 = ipaddress("3001:db8:ac10:fe01::3/64")

        m1.ip6tnl = Ip6TnlDevice(
            local=endpoint1_ip,
            remote=endpoint2_ip,
            mode=self.params.tunnel_mode,
            ttl=64,
        )
        m2.ip6tnl = Ip6TnlDevice(
            local=endpoint2_ip,
            remote=endpoint1_ip,
            mode=self.params.tunnel_mode,
            ttl=64,
        )

        # A
        m1.ip6tnl.up()
        m1.ip6tnl.ip_add(a_ip6)

        # B
        m2.ip6tnl.up()
        m2.ip6tnl.ip_add(b_ip6)

        configuration.tunnel_devices.extend([m1.ip6tnl, m2.ip6tnl])
        self.wait_tentative_ips(configuration.tunnel_devices)
Esempio n. 19
0
    def test_wide_configuration(self, config):
        config.generator.host = self.matched.m1
        config.generator.nics.append(self.matched.m1.eth0)
        config.generator.nics.append(self.matched.m1.eth1)
        self.matched.m1.eth0.ip_add(ipaddress("192.168.1.1/24"))
        self.matched.m1.eth1.ip_add(ipaddress("192.168.1.3/24"))
        self.base_dpdk_configuration(config.generator)

        config.dut.host = self.matched.m2
        config.dut.nics.append(self.matched.m2.eth0)
        config.dut.nics.append(self.matched.m2.eth1)
        self.matched.m2.eth0.ip_add(ipaddress("192.168.1.2/24"))
        self.matched.m2.eth1.ip_add(ipaddress("192.168.1.4/24"))
        self.base_dpdk_configuration(config.dut)
        self.ovs_dpdk_bridge_configuration(config.dut)

        self.init_guest_virtctl(config.dut, config.guest)
        self.shutdown_guest(config.guest)
        self.configure_guest_xml(config.dut, config.guest)

        self.ovs_dpdk_bridge_vm_configuration(config.dut, config.guest)
        self.ovs_dpdk_bridge_flow_configuration(config.dut)

        guest = self.create_guest(config.dut, config.guest)
        self.guest_vfio_modprobe(config.guest)
        self.base_dpdk_configuration(config.guest)

        config.guest.testpmd = guest.run(TestPMD(
            coremask=self.params.guest_testpmd_cores,
            pmd_coremask=self.params.guest_dpdk_cores,
            forward_mode="mac",
            nics=[nic.bus_info for nic in config.guest.nics],
            peer_macs=[nic.hwaddr for nic in config.generator.nics]),
                                         bg=True)

        time.sleep(5)
        return config
Esempio n. 20
0
    def _prepare_server(self, flow):
        host = flow.receiver
        server_params = dict(bind = ipaddress(flow.receiver_bind),
                             oneoff = True)

        self._set_cpupin_params(server_params, flow.cpupin)

        if flow.type == "mptcp_stream":
            server_params["mptcp"] = True

        if flow.receiver_port is not None:
            server_params["port"] = flow.receiver_port

        return host.prepare_job(IperfServer(**server_params),
                                job_level=ResultLevel.NORMAL)
Esempio n. 21
0
    def create_tunnel(self, configuration):
        """
        The ipip tunnel devices are configured with IPv4 addresses.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        ip_filter = {"family": AF_INET}
        endpoint1_ip = endpoint1.ips_filter(**ip_filter)[0]
        endpoint2_ip = endpoint2.ips_filter(**ip_filter)[0]

        a_ip4 = ipaddress("192.168.200.1/24")
        b_ip4 = ipaddress("192.168.200.2/24")

        m1.ipip_tunnel = IpIpDevice(
            local=endpoint1_ip,
            remote=endpoint2_ip,
            mode=self.params.tunnel_mode,
            ttl=64,
        )
        m2.ipip_tunnel = IpIpDevice(
            local=endpoint2_ip,
            remote=endpoint1_ip,
            mode=self.params.tunnel_mode,
            ttl=64,
        )

        # A
        m1.ipip_tunnel.up()
        m1.ipip_tunnel.ip_add(a_ip4)

        # B
        m2.ipip_tunnel.up()
        m2.ipip_tunnel.ip_add(b_ip4)

        configuration.tunnel_devices.extend([m1.ipip_tunnel, m2.ipip_tunnel])
Esempio n. 22
0
    def _prepare_server(self, flow):
        host = flow.receiver
        server_params = dict(bind=ipaddress(flow.receiver_bind), oneoff=True)

        if flow.cpupin is not None and flow.cpupin >= 0:
            if flow.parallel_streams == 1:
                server_params["cpu_bind"] = flow.cpupin
            else:
                raise RecipeError("Unsupported combination of single cpupin "
                                  "with parallel perf streams.")
        elif flow.cpupin is not None:
            raise RecipeError("Negative perf cpupin value provided.")

        return host.prepare_job(IperfServer(**server_params),
                                job_level=ResultLevel.NORMAL)
Esempio n. 23
0
    def _update_netlink(self, nl_msg):
        if getattr(self, "_deleted"):
            raise DeviceDeleted("Device was deleted.")

        if self.ifindex != nl_msg['index']:
            msg = "ifindex of netlink message (%s) doesn't match "\
                  "the device's (%s)." % (nl_msg['index'], self.ifindex)
            raise DeviceError(msg)

        if nl_msg['header']['type'] == RTM_NEWLINK:
            self._nl_msg = nl_msg
        elif nl_msg['header']['type'] == RTM_NEWADDR:
            addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS'),
                             flags=nl_msg.get_attr("IFA_FLAGS"))
            addr.prefixlen = nl_msg["prefixlen"]

            if addr not in self._ip_addrs:
                self._ip_addrs.append(addr)
        elif nl_msg['header']['type'] == RTM_DELADDR:
            addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS'))
            addr.prefixlen = nl_msg["prefixlen"]

            if addr in self._ip_addrs:
                self._ip_addrs.remove(addr)
Esempio n. 24
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [host1.eth0, host2.eth0]

        net_addr = "192.168.101"
        for i, host in enumerate([host1, host2], 10):
            host.eth0.down()
            host.eth0.ip_add(ipaddress(net_addr + "." + str(i) + "/24"))
            host.eth0.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 25
0
    def test_wide_configuration(self):
        """
        Test wide configuration for this recipe involves creating three
        VLAN (802.1Q) tunnels on top of the matched host's NIC with vlan
        ids 10, 20, 30. The same tunnels are configured on the second host.

        An IPv4 and IPv6 address is configured on each tunnel endpoint.

        | host1.vlan0 = 192.168.10.1/24 and fc00:0:0:1::1/64
        | host1.vlan1 = 192.168.20.1/24 and fc00:0:0:2::1/64
        | host1.vlan2 = 192.168.30.1/24 and fc00:0:0:3::1/64

        | host2.vlan0 = 192.168.10.2/24 and fc00:0:0:1::2/64
        | host2.vlan1 = 192.168.20.2/24 and fc00:0:0:2::2/64
        | host2.vlan2 = 192.168.30.2/24 and fc00:0:0:3::2/64

        """
        host1, host2 = self.matched.host1, self.matched.host2

        host1.eth0.down()
        host2.eth0.down()

        host1.vlan0 = VlanDevice(realdev=host1.eth0, vlan_id=10)
        host1.vlan1 = VlanDevice(realdev=host1.eth0, vlan_id=20)
        host1.vlan2 = VlanDevice(realdev=host1.eth0, vlan_id=30)
        host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10)
        host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20)
        host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = []
        for host in [host1, host2]:
            configuration.test_wide_devices.extend(
                [host.vlan0, host.vlan1, host.vlan2])

        net_addr = "192.168"
        net_addr6 = "fc00:0:0"

        for i, host in enumerate([host1, host2]):
            host.vlan0.ip_add(ipaddress('{}.10.{}/24'.format(net_addr, i + 1)))
            host.vlan1.ip_add(ipaddress('{}.20.{}/24'.format(net_addr, i + 1)))
            host.vlan2.ip_add(ipaddress('{}.30.{}/24'.format(net_addr, i + 1)))
            host.vlan0.ip_add(ipaddress('{}:1::{}/64'.format(net_addr6,
                                                             i + 1)))
            host.vlan1.ip_add(ipaddress('{}:2::{}/64'.format(net_addr6,
                                                             i + 1)))
            host.vlan2.ip_add(ipaddress('{}:3::{}/64'.format(net_addr6,
                                                             i + 1)))
            for dev in [host.eth0, host.vlan0, host.vlan1, host.vlan2]:
                dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 26
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        #The config argument needs to be used with a team device normally
        #(e.g  to specify the runner mode), but it is not used here due to
        #a bug in the TeamDevice module
        host1.team0 = TeamDevice()
        for dev in [host1.eth0, host1.eth1]:
            dev.down()
            host1.team0.slave_add(dev)

        host1.vlan0 = VlanDevice(realdev=host1.team0, vlan_id=10)
        host1.vlan1 = VlanDevice(realdev=host1.team0, vlan_id=20)
        host1.vlan2 = VlanDevice(realdev=host1.team0, vlan_id=30)
        host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10)
        host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20)
        host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = []
        for host in [host1, host2]:
            configuration.test_wide_devices.extend(
                [host.vlan0, host.vlan1, host.vlan2])
        configuration.test_wide_devices.append(host1.team0)

        net_addr = "192.168"
        net_addr6 = "fc00:0:0"

        for i, host in enumerate([host1, host2]):
            host.vlan0.ip_add(
                ipaddress(net_addr + '.10' + '.' + str(i + 1) + "/24"))
            host.vlan0.ip_add(
                ipaddress(net_addr6 + ":1::" + str(i + 1) + "/64"))
            host.vlan1.ip_add(
                ipaddress(net_addr + '.20' + '.' + str(i + 1) + "/24"))
            host.vlan1.ip_add(
                ipaddress(net_addr6 + ":2::" + str(i + 1) + "/64"))
            host.vlan2.ip_add(
                ipaddress(net_addr + '.30' + '.' + str(i + 1) + "/24"))
            host.vlan2.ip_add(
                ipaddress(net_addr6 + ":3::" + str(i + 1) + "/64"))

        for dev in [
                host1.eth0, host1.eth1, host1.team0, host1.vlan0, host1.vlan1,
                host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 27
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [host1.eth0, host2.eth0]

        net_addr = "192.168.0"
        for i, host in enumerate([host1, host2]):
            host.eth0.down()
            host.eth0.ip_add(ipaddress(net_addr + '.' + str(i + 1) + "/24"))

        self.wait_tentative_ips(configuration.test_wide_devices)

        configuration.endpoint1 = host1.eth0
        configuration.endpoint2 = host2.eth0
        configuration.host1 = host1
        configuration.host2 = host2

        return configuration
Esempio n. 28
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        host1.bond0 = BondDevice(mode=self.params.bonding_mode,
                                 miimon=self.params.miimon_value)
        for dev in [host1.eth0, host1.eth1]:
            dev.down()
            host1.bond0.slave_add(dev)

        host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=10)
        host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=20)
        host1.vlan2 = VlanDevice(realdev=host1.bond0, vlan_id=30)
        host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10)
        host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20)
        host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = []
        for host in [host1, host2]:
            configuration.test_wide_devices.extend(
                [host.vlan0, host.vlan1, host.vlan2])
        configuration.test_wide_devices.append(host1.bond0)

        net_addr = "192.168"
        net_addr6 = "fc00:0:0"

        for i, host in enumerate([host1, host2]):
            host.vlan0.ip_add(
                ipaddress(net_addr + '.10' + '.' + str(i + 1) + "/24"))
            host.vlan0.ip_add(
                ipaddress(net_addr6 + ":1::" + str(i + 1) + "/64"))
            host.vlan1.ip_add(
                ipaddress(net_addr + '.20' + '.' + str(i + 1) + "/24"))
            host.vlan1.ip_add(
                ipaddress(net_addr6 + ":2::" + str(i + 1) + "/64"))
            host.vlan2.ip_add(
                ipaddress(net_addr + '.30' + '.' + str(i + 1) + "/24"))
            host.vlan2.ip_add(
                ipaddress(net_addr6 + ":3::" + str(i + 1) + "/64"))

        for dev in [
                host1.eth0, host1.eth1, host1.bond0, host1.vlan0, host1.vlan1,
                host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
Esempio n. 29
0
    def _prepare_server(self, flow: Flow) -> Job:
        host = flow.receiver
        server_params = dict(workload = flow.type,
                             bind = ipaddress(flow.receiver_bind),
                             test_length = flow.duration)

        if flow.cpupin is not None and flow.cpupin >= 0:
            if flow.parallel_streams == 1:
                server_params["cpu_bind"] = flow.cpupin
            else:
                raise RecipeError("Unsupported combination of single cpupin "
                                  "with parallel perf streams.")
        elif flow.cpupin is not None:
            raise RecipeError("Negative perf cpupin value provided.")

        if flow.msg_size:
            server_params["request_size"] = flow.msg_size
            server_params["response_size"] = flow.msg_size

        return host.prepare_job(NeperServer(**server_params),
                                job_level=ResultLevel.NORMAL)
Esempio n. 30
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        host1.team0 = TeamDevice(
            config={'runner': {
                'name': self.params.runner_name
            }})
        for dev in [host1.eth0, host1.eth1]:
            dev.down()
            host1.team0.slave_add(dev)

        host1.vlan0 = VlanDevice(realdev=host1.team0, vlan_id=10)
        host1.vlan1 = VlanDevice(realdev=host1.team0, vlan_id=20)
        host1.vlan2 = VlanDevice(realdev=host1.team0, vlan_id=30)
        host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10)
        host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20)
        host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = []
        for host in [host1, host2]:
            configuration.test_wide_devices.extend(
                [host.vlan0, host.vlan1, host.vlan2])
        configuration.test_wide_devices.append(host1.team0)

        net_addr = "192.168"
        net_addr6 = "fc00:0:0"

        for i, host in enumerate([host1, host2]):
            host.vlan0.ip_add(ipaddress('{}.10.{}/24'.format(net_addr, i + 1)))
            host.vlan1.ip_add(ipaddress('{}.20.{}/24'.format(net_addr, i + 1)))
            host.vlan2.ip_add(ipaddress('{}.30.{}/24'.format(net_addr, i + 1)))
            host.vlan0.ip_add(ipaddress('{}:1::{}/64'.format(net_addr6,
                                                             i + 1)))
            host.vlan1.ip_add(ipaddress('{}:2::{}/64'.format(net_addr6,
                                                             i + 1)))
            host.vlan2.ip_add(ipaddress('{}:3::{}/64'.format(net_addr6,
                                                             i + 1)))

        for dev in [
                host1.eth0, host1.eth1, host1.team0, host1.vlan0, host1.vlan1,
                host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2
        ]:
            dev.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration