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)
def create_tunnel(self, configuration): """ The SIT 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 ip_filter = {"family": AF_INET} endpoint1_ip = endpoint1.ips_filter(**ip_filter)[0] endpoint2_ip = endpoint2.ips_filter(**ip_filter)[0] 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" m1.sit_tunnel = SitDevice(local=endpoint1_ip, remote=endpoint2_ip, mode=self.params.tunnel_mode) m2.sit_tunnel = SitDevice(local=endpoint2_ip, remote=endpoint1_ip, mode=self.params.tunnel_mode) # A m1.sit_tunnel.up() m1.sit_tunnel.ip_add(a_ip4) m1.sit_tunnel.ip_add(a_ip6) m1.run("ip -4 route add {} dev {}".format(b_net4, m1.sit_tunnel.name)) m1.run("ip -6 route add {} dev {}".format(b_net6, m1.sit_tunnel.name)) # B m2.sit_tunnel.up() m2.sit_tunnel.ip_add(b_ip4) m2.sit_tunnel.ip_add(b_ip6) m2.run("ip -4 route add {} dev {}".format(a_net4, m2.sit_tunnel.name)) m2.run("ip -6 route add {} dev {}".format(a_net6, m2.sit_tunnel.name)) configuration.tunnel_devices.extend([m1.sit_tunnel, m2.sit_tunnel]) self.wait_tentative_ips(configuration.tunnel_devices)
def create_tunnel(self, configuration): """ The GRE tunnel devices are created in the network namespaces and configured with local and remote ip addresses matching the veth devices IP addresses. The IP6GRE 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 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] 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" m1.gre6_tunnel = Ip6GreDevice(local=endpoint1_ip, remote=endpoint2_ip) m2.gre6_tunnel = Ip6GreDevice(local=endpoint2_ip, remote=endpoint1_ip) # A m1.gre6_tunnel.up() m1.gre6_tunnel.ip_add(a_ip4) m1.gre6_tunnel.ip_add(a_ip6) m1.run("ip -4 route add {} dev {}".format(b_net4, m1.gre6_tunnel.name)) m1.run("ip -6 route add {} dev {}".format(b_net6, m1.gre6_tunnel.name)) # B m2.gre6_tunnel.up() m2.gre6_tunnel.ip_add(b_ip4) m2.gre6_tunnel.ip_add(b_ip6) m2.run("ip -4 route add {} dev {}".format(a_net4, m2.gre6_tunnel.name)) m2.run("ip -6 route add {} dev {}".format(a_net6, m2.gre6_tunnel.name)) configuration.tunnel_devices.extend([m1.gre6_tunnel, m2.gre6_tunnel]) self.wait_tentative_ips(configuration.tunnel_devices)
def create_tunnel(self, configuration): """ The Geneve tunnel devices are configured with IPv4 and IPv6 addresses. """ 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] a_ip4 = Ip4Address("20.0.0.10/8") b_ip4 = Ip4Address("20.0.0.20/8") a_ip6 = Ip6Address("fee0::10/64") b_ip6 = Ip6Address("fee0::20/64") m1.gnv_tunnel = GeneveDevice(remote=endpoint2_ip, id=1234) m2.gnv_tunnel = GeneveDevice(remote=endpoint1_ip, id=1234) # A m1.gnv_tunnel.mtu = 1400 m1.gnv_tunnel.up() m1.gnv_tunnel.ip_add(a_ip4) m1.gnv_tunnel.ip_add(a_ip6) # B m2.gnv_tunnel.mtu = 1400 m2.gnv_tunnel.up() m2.gnv_tunnel.ip_add(b_ip4) m2.gnv_tunnel.ip_add(b_ip6) configuration.tunnel_devices.extend([m1.gnv_tunnel, m2.gnv_tunnel]) self.wait_tentative_ips(configuration.tunnel_devices)