예제 #1
0
    def create_tunnel(self, configuration):
        """
        The Vxlan tunnel devices are created with external flag specified
        so that the encapsulation can be defined externally by routes.

        Routes for IPv4 and IPv6 networks to be tunneled through the Vxlan are
        added.

        IPv4 and IPv6 addresses of the tunneled networks are configured on
        the loopback devices of the matched hosts.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        if self.params.carrier_ipversion == "ipv4":
            ip_filter = {"family": AF_INET}
        else:
            ip_filter = {"family": AF_INET6, "is_link_local": False}

        endpoint1_ip = endpoint1.ips_filter(**ip_filter)[0]
        endpoint2_ip = endpoint2.ips_filter(**ip_filter)[0]

        m1_dummy_ip = ipaddress("172.16.10.1/32")
        m1_dummy_ip6 = ipaddress("fc00:a::1/128")
        m2_dummy_ip = ipaddress("172.16.20.1/32")
        m2_dummy_ip6 = ipaddress("fc00:b::1/128")

        m1.vxlan_tunnel = VxlanDevice(external=True)
        m2.vxlan_tunnel = VxlanDevice(external=True)
        m1.lo = LoopbackDevice()
        m2.lo = LoopbackDevice()

        # A
        m1.lo.ip_add(m1_dummy_ip)
        m1.lo.ip_add(m1_dummy_ip6)
        m1.vxlan_tunnel.mtu = 1400
        m1.vxlan_tunnel.up()

        # B
        m2.lo.ip_add(m2_dummy_ip)
        m2.lo.ip_add(m2_dummy_ip6)
        m2.vxlan_tunnel.mtu = 1400
        m2.vxlan_tunnel.up()

        tunnel_id = 1234
        encap = "ip" if self.params.carrier_ipversion == "ipv4" else "ip6"
        m1.run("ip route add {} encap {} id {} dst {} dev {}".format(
            m2_dummy_ip, encap, tunnel_id, endpoint2_ip, m1.vxlan_tunnel.name))
        m2.run("ip route add {} encap {} id {} dst {} dev {}".format(
            m1_dummy_ip, encap, tunnel_id, endpoint1_ip, m2.vxlan_tunnel.name))
        m1.run("ip route add {} encap {} id {} dst {} dev {}".format(
            m2_dummy_ip6, encap, tunnel_id, endpoint2_ip,
            m1.vxlan_tunnel.name))
        m2.run("ip route add {} encap {} id {} dst {} dev {}".format(
            m1_dummy_ip6, encap, tunnel_id, endpoint1_ip,
            m2.vxlan_tunnel.name))

        configuration.tunnel_devices.extend([m1.vxlan_tunnel, m2.vxlan_tunnel])
        self.wait_tentative_ips([m1.lo, m2.lo])
예제 #2
0
    def create_tunnel(self, configuration):
        """
        The VXLAN tunnel devices are created in the network namespaces and
        configured with local and remote ip addresses matching the veth
        devices IP addresses.

        The VXLAN tunnel devices are configured with IPv4 and IPv6 addresses
        of individual networks. Routes are configured accordingly.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns

        a_ip4 = Ip4Address("192.168.6.2/24")
        a_net4 = "192.168.6.0/24"
        b_ip4 = Ip4Address("192.168.7.2/24")
        b_net4 = "192.168.7.0/24"

        a_ip6 = Ip6Address("6001:db8:ac10:fe01::2/64")
        a_net6 = "6001:db8:ac10:fe01::0/64"
        b_ip6 = Ip6Address("7001:db8:ac10:fe01::2/64")
        b_net6 = "7001:db8:ac10:fe01::0/64"

        vxlan_group_ip = "239.1.1.1"

        m1.vxlan_tunnel = VxlanDevice(vxlan_id=1234,
                                      realdev=endpoint1,
                                      group=vxlan_group_ip)
        m2.vxlan_tunnel = VxlanDevice(vxlan_id=1234,
                                      realdev=endpoint2,
                                      group=vxlan_group_ip)

        # A
        m1.vxlan_tunnel.up()
        m1.vxlan_tunnel.ip_add(a_ip4)
        m1.vxlan_tunnel.ip_add(a_ip6)
        m1.run("ip -4 route add {} dev {}".format(b_net4,
                                                  m1.vxlan_tunnel.name))
        m1.run("ip -6 route add {} dev {}".format(b_net6,
                                                  m1.vxlan_tunnel.name))

        # B
        m2.vxlan_tunnel.up()
        m2.vxlan_tunnel.ip_add(b_ip4)
        m2.vxlan_tunnel.ip_add(b_ip6)
        m2.run("ip -4 route add {} dev {}".format(a_net4,
                                                  m2.vxlan_tunnel.name))
        m2.run("ip -6 route add {} dev {}".format(a_net6,
                                                  m2.vxlan_tunnel.name))

        configuration.tunnel_devices.extend([m1.vxlan_tunnel, m2.vxlan_tunnel])
        self.wait_tentative_ips(configuration.tunnel_devices)
예제 #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"
        vxlan_group_ip = "239.1.1.1"

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

        host1.vxlan0 = VxlanDevice(vxlan_id=1,
                                   realdev=host1.br0,
                                   group=vxlan_group_ip)
        for machine in [guest1, host2]:
            machine.vxlan0 = VxlanDevice(vxlan_id=1,
                                         realdev=machine.eth0,
                                         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
예제 #4
0
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        for host in [host1, host2]:
            host.eth0.down()

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

        for i, host in enumerate([host1, host2]):
            host.eth0.ip_add(ipaddress(net_addr + "." + str(i + 1) + "/24"))
            host.vxlan0 = VxlanDevice(vxlan_id='1',
                                      remote=net_addr + "." + str(2 - i))

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

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

        for host in [host1, host2]:
            host.eth0.up()
            host.vxlan0.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
예제 #5
0
    def test(self):
        self.matched.m1.eth0.ip_add(ipaddress("192.168.1.1/24"))
        self.matched.m1.eth0.up()
        self.matched.m2.eth0.ip_add(ipaddress("192.168.1.2/24"))
        self.matched.m2.eth0.up()
        ping_job = self.matched.m1.run(
            Ping(dst=self.matched.m2.eth0,
                 interval=0,
                 iface=self.matched.m1.eth0))

        netserver_job = self.matched.m1.run(
            Netserver(bind=self.matched.m1.eth0), bg=True)

        netperf_job = self.matched.m2.run(
            Netperf(server=self.matched.m1.eth0,
                    duration=1,
                    confidence="99,5",
                    runs="5",
                    debug=0,
                    max_deviation={
                        'type': "percent",
                        'value': 20.0
                    },
                    testname="TCP_STREAM"))

        netserver_job.kill(signal=signal.SIGINT)

        #examples of how to create soft devices
        self.matched.m1.eth0.down()

        m1 = self.matched.m1
        eth0 = m1.eth0

        #Bonding
        m1.bond = BondDevice(mode="active-backup", name="my_bond0")
        m1.bond.slave_add(eth0)
        m1.bond.up()
        m1.run("ip a")
        m1.bond.destroy()

        #Bridging
        m1.br = BridgeDevice()
        m1.br.slave_add(eth0)
        m1.br.up()
        m1.run("ip a")
        m1.br.destroy()

        #Teaming
        m1.team = TeamDevice()
        m1.team.slave_add(eth0)
        m1.team.up()
        m1.run("ip a")
        m1.team.destroy()

        #VethPair
        m1.veth0, m1.veth1 = VethPair()
        m1.veth0.up()
        m1.veth1.up()
        m1.run("ip a")
        m1.veth0.destroy()

        #Macvlan
        m1.mvlan = MacvlanDevice(realdev=eth0)
        m1.mvlan.up()
        m1.run("ip a")
        m1.mvlan.destroy()

        #Vlan
        eth0.up()
        m1.vlan = VlanDevice(realdev=eth0, vlan_id=123)
        m1.vlan.up()
        m1.run("ip a")
        m1.vlan.destroy()
        eth0.down()

        #Vti
        m1.vti = VtiDevice(local="1.2.3.4", ikey=123, okey=321)
        m1.vti.up()
        m1.run("ip a")
        m1.vti.destroy()

        #Vxlan
        m1.vxlan0 = VxlanDevice(vxlan_id=123, remote='1.2.3.4')
        m1.vxlan0.up()
        self.matched.m1.run("ip a")
        m1.vxlan0.destroy()