Example #1
0
 def __del__(self):
     if (self.tuntype == 'gnv' and self.host):
         if self.transit_agent is not None:
             self.host.unload_transit_agent_xdp(self.veth_peer)
         if self.veth_allocated:
             veth_allocator.getInstance().reclaim_veth(
                 self.mac, self.ns.replace(self.tuntype + '_', ''),
                 self.veth_peer.replace(self.tuntype + '_', ''))
Example #2
0
    def __del__(self):
        if (self.tuntype == 'gnv' and self.host):
            if self.transit_agent is not None:
                self.host.unload_transit_agent_xdp(self.veth_peer)
        if self.veth_allocated:
            if self.ns == "":  # Host endpoint case
                veth_allocator.getInstance().reclaim_veth(
                    self.mac, self.saved_ns.replace(self.tuntype + '_', ''),
                    self.veth_peer.replace("host_" + self.tuntype + '_', ''))
            else:
                veth_allocator.getInstance().reclaim_veth(
                    self.mac, self.ns.replace(self.tuntype + '_', ''),
                    self.veth_peer.replace(self.tuntype + '_', ''))

            self.veth_allocated = False
Example #3
0
    def unprovision(self):
        if self.host is None:
            return

        if self.tuntype == 'vxn':
            return
        else:
            self.transit_agent = None
            self.host.delete_ep(self)
            self.host.unprovision_simple_endpoint(self)
            veth_allocator.getInstance().reclaim_veth(
                self.mac, self.ns.replace(self.tuntype + '_', ''),
                self.veth_peer.replace(self.tuntype + '_', ''))
            self.veth_allocated = False

        self.ready = False
Example #4
0
    def __init__(self,
                 vni,
                 netid,
                 ip,
                 prefixlen,
                 gw_ip,
                 host,
                 tuntype='gnv',
                 bridge='br0'):
        """
        Defines a simple endpoint in the VPC and network. Also defines
        a phantom endpoint that is not hosted on any host (switch only respond for ARP requests).

        1. Calls provision_simple_endpoint on the droplet to create a
           veth pair and load the transit agent xdp program
        2. Calls update_ep on endpoint's host.
        """
        self.vni = vni
        self.netid = netid
        v = veth_allocator.getInstance().allocate_veth()
        self.veth_name = "veth0"
        self.mac = v[0]
        self.ns = tuntype + '_' + v[1]
        self.veth_peer = tuntype + '_' + v[2]
        self.veth_allocated = True
        self.ip = ip
        self.prefixlen = prefixlen
        self.gw_ip = gw_ip
        self.eptype = 1  # Simple ep
        self.host = host
        self.transit_agent = None
        self.tuntype = tuntype
        self.tunitf = 'tun_' + self.veth_peer  # Only for ovs
        self.bridge = bridge
        self.bridge_port = None

        self.provision()

        # endpoint commands
        self.output_dir = '/mnt/Transit/test/trn_func_tests/output'
        self.tcp_recv_file = f'''{self.output_dir}/{self.ns}_{self.ip}_tcp_recv'''
        self.tcp_sent_file = f'''{self.output_dir}/{self.ns}_{self.ip}_tcp_sent'''

        self.udp_recv_file = f'''{self.output_dir}/{self.ns}_{self.ip}_udp_recv'''
        self.udp_sent_file = f'''{self.output_dir}/{self.ns}_{self.ip}_udp_sent'''

        self.ns_exec = f'''ip netns exec {self.ns}'''

        self.ping_cmd = f'''{self.ns_exec} ping'''
        self.curl_cmd = f'''{self.ns_exec} curl'''
        self.python_cmd = f'''{self.ns_exec} python3'''
        self.diff_cmd = f'''{self.ns_exec} diff'''
        self.bash_cmd = f'''{self.ns_exec} bash -c'''
        self.httpd_cmd = f'''{self.bash_cmd} 'pushd /tmp/{self.ns}_{self.ip}; python3 -m http.server > /tmp/{self.ns}_{self.ip}/httpd.log 2>&1' '''
        self.tcp_server_cmd = f'''{self.bash_cmd} '(nc -l -p 9001 > {self.tcp_recv_file})' '''
        self.udp_server_cmd = f'''{self.bash_cmd} '(nc -u -l -p 5001 > {self.udp_recv_file})' '''
        self.iperf3_server_cmd = f'''{self.bash_cmd} 'iperf3 -s > /tmp/{self.ns}_{self.ip}/iperf_server.log 2>&1' '''
Example #5
0
    def unprovision(self):
        if self.tuntype == 'vxn':
            return
        if self.host is not None:
            self.transit_agent = None
            self.host.delete_ep(self)
            self.host.unprovision_simple_endpoint(self)

        if self.ns == "":  # Host endpoint case
            veth_allocator.getInstance().reclaim_veth(
                self.mac, self.saved_ns.replace(self.tuntype + '_', ''),
                self.veth_peer.replace("host_" + self.tuntype + '_', ''))
        else:
            veth_allocator.getInstance().reclaim_veth(
                self.mac, self.ns.replace(self.tuntype + '_', ''),
                self.veth_peer.replace(self.tuntype + '_', ''))

        self.veth_allocated = False
        self.ready = False
Example #6
0
    def __init__(
            self,
            vni,
            netid,
            ip,
            vpc_cidr,
            net_cidr,
            gw_ip,
            host,
            tuntype='gnv',
            bridge='br0',
            host_ep=False,
            eptype=CONSTANTS.TRAN_SIMPLE_EP,
            backends=None,
            scaled_ep_obj='/trn_xdp/trn_transit_scaled_endpoint_ebpf_debug.o'):
        """
        Defines a simple endpoint in the VPC and network. Also defines
        a phantom endpoint that is not hosted on any host (switch only respond for ARP requests).

        1. Calls provision_simple_endpoint on the droplet to create a
           veth pair and load the transit agent xdp program
        2. Calls update_ep on endpoint's host.
        """
        self.vni = vni
        self.netid = netid
        v = veth_allocator.getInstance().allocate_veth()
        self.veth_name = "veth0"
        self.mac = v[0]
        self.ns = tuntype + '_' + v[1]
        self.veth_peer = tuntype + '_' + v[2]
        self.veth_allocated = True
        self.ip = ip
        self.prefixlen = net_cidr.prefixlen
        self.netip = net_cidr.ip
        self.vpc_cidr = vpc_cidr
        self.gw_ip = gw_ip
        self.eptype = eptype
        self.host = host
        self.transit_agent = None
        self.tuntype = tuntype
        self.tunitf = 'tun_' + self.veth_peer  # Only for ovs
        self.bridge = bridge
        self.bridge_port = None
        self.host_ep = host_ep
        self.ns_exec = f'''ip netns exec {self.ns} '''
        if host_ep:
            self.veth_name = "host_" + self.veth_name
            self.veth_peer = "host_" + self.veth_peer
            self.saved_ns = self.ns
            self.ns = ""
            self.ns_exec = ""
        self.backends = backends
        self.scaled_ep_obj = scaled_ep_obj

        self.provision()

        # endpoint commands
        self.output_dir = '/mnt/Transit/test/trn_func_tests/output'
        self.tcp_recv_file = f'''{self.output_dir}/{self.ns}_{self.ip}_tcp_recv'''
        self.tcp_sent_file = f'''{self.output_dir}/{self.ns}_{self.ip}_tcp_sent'''

        self.udp_recv_file = f'''{self.output_dir}/{self.ns}_{self.ip}_udp_recv'''
        self.udp_sent_file = f'''{self.output_dir}/{self.ns}_{self.ip}_udp_sent'''

        self.ping_cmd = f'''{self.ns_exec}ping'''
        self.curl_cmd = f'''{self.ns_exec}curl'''
        self.python_cmd = f'''{self.ns_exec}python3'''
        self.diff_cmd = f'''{self.ns_exec}diff'''
        self.bash_cmd = f'''{self.ns_exec}bash -c'''
        self.httpd_cmd = f'''{self.bash_cmd} 'pushd /tmp/{self.ns}_{self.ip}; python3 -m http.server > /tmp/{self.ns}_{self.ip}/httpd.log 2>&1' '''
        self.tcp_server_cmd = f'''{self.bash_cmd} '(nc -l -p 9001 > {self.tcp_recv_file})' '''
        self.udp_server_cmd = f'''{self.bash_cmd} '(nc -u -l -p 5001 > {self.udp_recv_file})' '''
        self.iperf3_server_cmd = f'''{self.bash_cmd} 'iperf3 -s > /tmp/{self.ns}_{self.ip}/iperf_server.log 2>&1' '''

        self.tcp_serv_idle_cmd = f'''{self.bash_cmd} './mnt/Transit/tools/tcp_server.py '''
        self.tcp_client_idle_cmd = f'''{self.bash_cmd} './mnt/Transit/tools/tcp_client.py '''
Example #7
0
 def __del__(self):
     if (self.tuntype == 'gnv' and self.host):
         self.host.unload_transit_agent_xdp(self.veth_peer)
     veth_allocator.getInstance().reclaim_veth(self.mac, self.ns, self.veth_peer)