Esempio n. 1
0
    def test_memif_ping(self):
        """Memif ping"""

        memif = VppMemif(
            self,
            VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
            VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
        )

        remote_socket = VppSocketFilename(self.remote_test, 1,
                                          "%s/memif.sock" % self.tempdir)
        remote_socket.add_vpp_config()

        remote_memif = VppMemif(
            self.remote_test,
            VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
            VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=1,
        )

        memif.add_vpp_config()
        memif.config_ip4()
        memif.admin_up()

        remote_memif.add_vpp_config()
        remote_memif.config_ip4()
        remote_memif.admin_up()

        self.assertTrue(memif.wait_for_link_up(5))
        self.assertTrue(remote_memif.wait_for_link_up(5))

        # add routing to remote vpp
        route = VppIpRoute(
            self.remote_test,
            self.pg0._local_ip4_subnet,
            24,
            [VppRoutePath(memif.ip_prefix.network_address, 0xFFFFFFFF)],
            register=False,
        )

        route.add_vpp_config()

        # create ICMP echo-request from local pg to remote memif
        packet_num = 10
        pkts = self._create_icmp(self.pg0, remote_memif, packet_num)

        self.pg0.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()
        capture = self.pg0.get_capture(packet_num, timeout=2)
        seq = 0
        for c in capture:
            self._verify_icmp(self.pg0, remote_memif, c, seq)
            seq += 1

        route.remove_vpp_config()
Esempio n. 2
0
    def test_memif_ping(self):
        """ Memif ping """

        memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)

        remote_socket = VppSocketFilename(
            self.remote_test, 1, b"%s/memif.sock" %
            six.ensure_binary(self.tempdir, encoding='utf-8'))
        remote_socket.add_vpp_config()

        remote_memif = VppMemif(self.remote_test,
                                MEMIF_ROLE.MASTER,
                                MEMIF_MODE.ETHERNET,
                                socket_id=1)

        memif.add_vpp_config()
        memif.config_ip4()
        memif.admin_up()

        remote_memif.add_vpp_config()
        remote_memif.config_ip4()
        remote_memif.admin_up()

        self.assertTrue(memif.wait_for_link_up(5))
        self.assertTrue(remote_memif.wait_for_link_up(5))

        # add routing to remote vpp
        route = VppIpRoute(self.remote_test,
                           self.pg0._local_ip4_subnet,
                           24, [VppRoutePath(memif.ip4_addr, 0xffffffff)],
                           register=False)

        route.add_vpp_config()

        # create ICMP echo-request from local pg to remote memif
        packet_num = 10
        pkts = self._create_icmp(self.pg0, remote_memif, packet_num)

        self.pg0.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()
        capture = self.pg0.get_capture(packet_num, timeout=2)
        seq = 0
        for c in capture:
            self._verify_icmp(self.pg0, remote_memif, c, seq)
            seq += 1

        route.remove_vpp_config()
Esempio n. 3
0
    def test_memif_ping(self):
        """ Memif ping """
        memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)

        remote_socket = VppSocketFilename(
            self.remote_test, 1, b"%s/memif.sock" %
            six.ensure_binary(self.tempdir, encoding='utf-8'))
        remote_socket.add_vpp_config()

        remote_memif = VppMemif(self.remote_test,
                                MEMIF_ROLE.MASTER,
                                MEMIF_MODE.ETHERNET,
                                socket_id=1)

        memif.add_vpp_config()
        memif.config_ip4()
        memif.admin_up()

        remote_memif.add_vpp_config()
        remote_memif.config_ip4()
        remote_memif.admin_up()

        self.assertTrue(memif.wait_for_link_up(5))
        self.assertTrue(remote_memif.wait_for_link_up(5))

        # add routing to remote vpp
        dst_addr = socket.inet_pton(socket.AF_INET, self.pg0._local_ip4_subnet)
        dst_addr_len = 24
        next_hop_addr = socket.inet_pton(socket.AF_INET, memif.ip4_addr)
        self.remote_test.vapi.ip_add_del_route(dst_address=dst_addr,
                                               dst_address_length=dst_addr_len,
                                               next_hop_address=next_hop_addr)

        # create ICMP echo-request from local pg to remote memif
        packet_num = 10
        pkts = self._create_icmp(self.pg0, remote_memif, packet_num)

        self.pg0.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()
        capture = self.pg0.get_capture(packet_num, timeout=2)
        seq = 0
        for c in capture:
            self._verify_icmp(self.pg0, remote_memif, c, seq)
            seq += 1