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)
def host_forwarding_configuration(self, host_conf): if (self.params.host_fwd == 'bridge'): host_conf.bridges = [] host_conf.host.br0 = BridgeDevice() host_conf.host.br1 = BridgeDevice() host_conf.host.br0.slave_add(host_conf.nics[0]) host_conf.host.br1.slave_add(host_conf.nics[1]) host_conf.host.br0.up() host_conf.host.br1.up() host_conf.bridges.append(host_conf.host.br0) host_conf.bridges.append(host_conf.host.br1) else: # TBD return
def guest_forwarding(self, guest_conf): guest = guest_conf.host if (self.params.guest_fwd == 'bridge'): guest.bridge = BridgeDevice() guest.bridge.name = 'guestbr0' for nic in guest_conf.nics: guest.bridge.slave_add(nic) nic.up() guest.run("echo 1 > /proc/sys/net/ipv4/ip_forward")
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=self.params.vlan_id) guest2.vlan0 = VlanDevice(realdev=guest2.eth0, vlan_id=self.params.vlan_id) 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
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
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
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
def test_wide_configuration(self): host1, host2, guest1, guest2, guest3, guest4 = (self.matched.host1, self.matched.host2, self.matched.guest1, self.matched.guest2, self.matched.guest3, self.matched.guest4) for host in [host1, host2]: for dev in [host.eth0, host.eth1, host.tap0, host.tap1]: dev.down() host.bond0 = BondDevice(mode=self.params.bonding_mode, miimon=self.params.miimon_value) host.bond0.slave_add(host.eth0) host.bond0.slave_add(host.eth1) host.br0 = BridgeDevice() host.br0.slave_add(host.tap0) host.br1 = BridgeDevice() host.br1.slave_add(host.tap1) for guest in (guest1, guest2, guest3, guest4): guest.eth0.down() host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=10, master=host1.br0) host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=20, master=host1.br1) host2.vlan0 = VlanDevice(realdev=host2.bond0, vlan_id=10, master=host2.br0) host2.vlan1 = VlanDevice(realdev=host2.bond0, vlan_id=20, master=host2.br1) configuration = super().test_wide_configuration() configuration.test_wide_devices = [ host1.br0, host2.br0, guest1.eth0, guest2.eth0, guest3.eth0, guest4.eth0 ] net_addr = "192.168" net_addr6 = "fc00:0:0" for host, (guest_a, guest_b), n in [(host1, (guest1, guest2), 1), (host2, (guest3, guest4), 3)]: host.br0.ip_add(ipaddress(net_addr + ".10." + str(n) + "/24")) host.br1.ip_add(ipaddress(net_addr + ".20." + str(n) + "/24")) guest_a.eth0.ip_add( ipaddress(net_addr + ".10." + str(n + 1) + "/24")) guest_a.eth0.ip_add( ipaddress(net_addr6 + ":1::" + str(n + 1) + "/64")) guest_b.eth0.ip_add( ipaddress(net_addr + ".20." + str(n + 1) + "/24")) guest_b.eth0.ip_add( ipaddress(net_addr6 + ":2::" + str(n + 1) + "/64")) for host in [host1, host2]: for dev in [ host.eth0, host.eth1, host.tap0, host.tap1, host.bond0, host.vlan0, host.vlan1, host.br0, host.br1 ]: dev.up() for guest in [guest1, guest2, guest3, guest4]: guest.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
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()