Exemple #1
0
    def test_memif_connect(self):
        """ Memif connect """
        memif = VppMemif(self,
                         VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
                         VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
                         ring_size=1024,
                         buffer_size=2048,
                         secret="abc")

        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,
            VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
            VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=1,
            ring_size=1024,
            buffer_size=2048,
            secret="abc")

        self._connect_test_interface_pair(memif, remote_memif)

        memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER
        remote_memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE

        self._connect_test_interface_pair(memif, remote_memif)
Exemple #2
0
    def test_memif_connect(self):
        """ Memif connect """
        memif = VppMemif(self,
                         MEMIF_ROLE.SLAVE,
                         MEMIF_MODE.ETHERNET,
                         ring_size=1024,
                         buffer_size=2048)

        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,
                                ring_size=1024,
                                buffer_size=2048)

        self._connect_test_interface_pair(memif, remote_memif)

        memif.role = MEMIF_ROLE.MASTER
        remote_memif.role = MEMIF_ROLE.SLAVE

        self._connect_test_interface_pair(memif, remote_memif)
Exemple #3
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()
Exemple #4
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()
Exemple #5
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
Exemple #6
0
    def test_memif_admin_up_down_up(self):
        """Memif admin up/down/up"""
        memif = VppMemif(
            self,
            VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
            VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            ring_size=1024,
            buffer_size=2048,
            secret="abc",
        )

        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,
            ring_size=1024,
            buffer_size=2048,
            secret="abc",
        )

        memif.add_vpp_config()
        remote_memif.add_vpp_config()

        memif.admin_up()
        remote_memif.admin_up()
        memif.admin_down()
        remote_memif.admin_down()
        memif.admin_up()
        remote_memif.admin_up()

        self._connect_test_one_interface(memif)
        self._connect_test_one_interface(remote_memif)

        memif.remove_vpp_config()
        remote_memif.remove_vpp_config()
        remote_socket.remove_vpp_config()
Exemple #7
0
    def test_marker_request(self):
        """ Marker Request test """

        # topology
        #
        #             +-+      +-+
        # memif1 -----|B|      |B|---- memif11
        #             |o|      |o|
        #             |n|------|n|
        #             |d|      |d|
        # pg0    -----|0|      |1|
        #             +-+      +-+

        socket1 = VppSocketFilename(self,
                                    socket_id=1,
                                    socket_filename="%s/memif.sock1" %
                                    self.tempdir)
        socket1.add_vpp_config()

        socket11 = VppSocketFilename(self,
                                     socket_id=2,
                                     socket_filename="%s/memif.sock1" %
                                     self.tempdir)
        socket11.add_vpp_config()

        memif1 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=1)
        memif1.add_vpp_config()
        memif1.admin_up()

        memif11 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=2)
        memif11.add_vpp_config()
        memif11.admin_up()

        bond0 = VppBondInterface(
            self,
            mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP,
            use_custom_mac=1,
            mac_address=bond_mac)

        bond0.add_vpp_config()
        bond0.admin_up()

        bond1 = VppBondInterface(
            self, mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP)
        bond1.add_vpp_config()
        bond1.admin_up()

        bond0.enslave_vpp_bond_interface(sw_if_index=memif1.sw_if_index)
        bond1.enslave_vpp_bond_interface(sw_if_index=memif11.sw_if_index)

        # wait for memif protocol exchange and hardware carrier to come up
        self.assertEqual(memif1.wait_for_link_up(10), True)
        self.assertEqual(memif11.wait_for_link_up(10), True)

        # verify memif1 in bond0
        intfs = self.vapi.sw_interface_slave_dump(
            sw_if_index=bond0.sw_if_index)
        for intf in intfs:
            self.assertEqual(intf.sw_if_index, memif1.sw_if_index)

        # verify memif11 in bond1
        intfs = self.vapi.sw_interface_slave_dump(
            sw_if_index=bond1.sw_if_index)
        for intf in intfs:
            self.assertEqual(intf.sw_if_index, memif11.sw_if_index)

        self.vapi.ppcli("trace add memif-input 100")

        # create marker request
        marker = (Ether(src=bond_mac, dst=lacp_dst_mac) / SlowProtocol() /
                  MarkerProtocol(marker_type=1,
                                 requester_port=1,
                                 requester_system=bond_mac,
                                 requester_transaction_id=1))

        bond1.enslave_vpp_bond_interface(sw_if_index=self.pg0.sw_if_index)
        self.pg0.add_stream(marker)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        show_trace = self.vapi.ppcli("show trace max 100")
        self.assertIn("Marker Information TLV:", show_trace)

        bond0.remove_vpp_config()
        bond1.remove_vpp_config()
Exemple #8
0
    def test_lacp_connect(self):
        """ LACP protocol connect test """

        # topology
        #
        #             +-+      +-+
        # memif1 -----|B|      |B|---- memif11
        #             |o|      |o|
        #             |n|------|n|
        #             |d|      |d|
        # memif2 -----|0|      |1|---- memif12
        #             +-+      +-+

        socket1 = VppSocketFilename(self,
                                    socket_id=1,
                                    socket_filename="%s/memif.sock1" %
                                    self.tempdir)
        socket1.add_vpp_config()

        socket11 = VppSocketFilename(self,
                                     socket_id=2,
                                     socket_filename="%s/memif.sock1" %
                                     self.tempdir)
        socket11.add_vpp_config()

        socket2 = VppSocketFilename(self,
                                    socket_id=3,
                                    socket_filename="%s/memif.sock2" %
                                    self.tempdir)
        socket2.add_vpp_config()

        socket22 = VppSocketFilename(self,
                                     socket_id=4,
                                     socket_filename="%s/memif.sock2" %
                                     self.tempdir)
        socket22.add_vpp_config()

        memif1 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=1)
        memif1.add_vpp_config()
        memif1.admin_up()

        memif11 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=2)
        memif11.add_vpp_config()
        memif11.admin_up()

        memif2 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=3)
        memif2.add_vpp_config()
        memif2.admin_up()

        memif12 = VppMemif(
            self,
            role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
            mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
            socket_id=4)
        memif12.add_vpp_config()
        memif12.admin_up()

        self.logger.info(self.vapi.ppcli("debug lacp on"))
        bond0 = VppBondInterface(
            self,
            mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP,
            use_custom_mac=1,
            mac_address=bond_mac)

        bond0.add_vpp_config()
        bond0.admin_up()

        bond1 = VppBondInterface(
            self, mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP)
        bond1.add_vpp_config()
        bond1.admin_up()

        # enslave memif1 and memif2 to bond0
        bond0.enslave_vpp_bond_interface(sw_if_index=memif1.sw_if_index)
        bond0.enslave_vpp_bond_interface(sw_if_index=memif2.sw_if_index)

        # enslave memif11 and memif12 to bond1
        bond1.enslave_vpp_bond_interface(sw_if_index=memif11.sw_if_index)
        bond1.enslave_vpp_bond_interface(sw_if_index=memif12.sw_if_index)

        # wait for memif protocol exchange and hardware carrier to come up
        self.assertEqual(memif1.wait_for_link_up(10), True)
        self.assertEqual(memif2.wait_for_link_up(10), True)
        self.assertEqual(memif11.wait_for_link_up(10), True)
        self.assertEqual(memif12.wait_for_link_up(10), True)

        # verify memif1 and memif2 in bond0
        intfs = self.vapi.sw_interface_slave_dump(
            sw_if_index=bond0.sw_if_index)
        for intf in intfs:
            self.assertIn(intf.sw_if_index,
                          (memif1.sw_if_index, memif2.sw_if_index))

        # verify memif11 and memif12 in bond1
        intfs = self.vapi.sw_interface_slave_dump(
            sw_if_index=bond1.sw_if_index)
        for intf in intfs:
            self.assertIn(intf.sw_if_index,
                          (memif11.sw_if_index, memif12.sw_if_index))
            self.assertEqual(intf.is_long_timeout, 0)
            self.assertEqual(intf.is_passive, 0)

        # Let LACP create the bundle
        self.wait_for_lacp_connect(30)

        intfs = self.vapi.sw_interface_lacp_dump()
        for intf in intfs:
            self.assertEqual(intf.actor_state,
                             LACP_COLLECTION_AND_DISTRIBUTION_STATE)
            self.assertEqual(intf.partner_state,
                             LACP_COLLECTION_AND_DISTRIBUTION_STATE)

        intfs = self.vapi.sw_interface_bond_dump()
        for intf in intfs:
            self.assertEqual(intf.slaves, 2)
            self.assertEqual(intf.active_slaves, 2)
            self.assertEqual(intf.mode,
                             VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP)

        self.logger.info(self.vapi.ppcli("show lacp"))
        self.logger.info(self.vapi.ppcli("show lacp details"))

        # detach slave memif1
        bond0.detach_vpp_bond_interface(sw_if_index=memif1.sw_if_index)

        self.wait_for_slave_detach(bond0, timeout=10, count=1)
        intfs = self.vapi.sw_interface_bond_dump()
        for intf in intfs:
            if (bond0.sw_if_index == intf.sw_if_index):
                self.assertEqual(intf.slaves, 1)
                self.assertEqual(intf.active_slaves, 1)
                self.assertEqual(intf.mode,
                                 VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP)

        # detach slave memif2
        bond0.detach_vpp_bond_interface(sw_if_index=memif2.sw_if_index)
        self.wait_for_slave_detach(bond0, timeout=10, count=0)

        intfs = self.vapi.sw_interface_bond_dump()
        for intf in intfs:
            if (bond0.sw_if_index == intf.sw_if_index):
                self.assertEqual(intf.slaves, 0)
                self.assertEqual(intf.active_slaves, 0)

        bond0.remove_vpp_config()
        bond1.remove_vpp_config()