Paul Vinciguerra | a279d9c | 2019-02-28 09:00:09 -0800 | [diff] [blame] | 1 | import socket |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 2 | import unittest |
| 3 | |
| 4 | from scapy.layers.l2 import Ether |
| 5 | from scapy.layers.inet import IP, ICMP |
| 6 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 7 | from framework import VppTestCase, VppTestRunner |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 8 | from framework import tag_run_solo |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 9 | from remote_test import RemoteClass, RemoteVppTestCase |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 10 | from vpp_memif import remove_all_memif_vpp_config, VppSocketFilename, VppMemif |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 11 | from vpp_ip_route import VppIpRoute, VppRoutePath |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 12 | from vpp_papi import VppEnum |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 13 | |
| 14 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 15 | @tag_run_solo |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 16 | class TestMemif(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 17 | """Memif Test Case""" |
| 18 | |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 19 | remote_class = RemoteVppTestCase |
| 20 | |
| 21 | @classmethod |
| 22 | def get_cpus_required(cls): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 23 | return super().get_cpus_required() + cls.remote_class.get_cpus_required() |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 24 | |
| 25 | @classmethod |
| 26 | def assign_cpus(cls, cpus): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 27 | remote_cpus = cpus[: cls.remote_class.get_cpus_required()] |
| 28 | my_cpus = cpus[cls.remote_class.get_cpus_required() :] |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 29 | cls.remote_class.assign_cpus(remote_cpus) |
| 30 | super().assign_cpus(my_cpus) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 31 | |
| 32 | @classmethod |
| 33 | def setUpClass(cls): |
| 34 | # fork new process before client connects to VPP |
Klement Sekera | 558ceab | 2021-04-08 19:37:41 +0200 | [diff] [blame] | 35 | cls.remote_test = RemoteClass(cls.remote_class) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 36 | cls.remote_test.start_remote() |
| 37 | cls.remote_test.set_request_timeout(10) |
| 38 | super(TestMemif, cls).setUpClass() |
| 39 | cls.remote_test.setUpClass(cls.tempdir) |
| 40 | cls.create_pg_interfaces(range(1)) |
| 41 | for pg in cls.pg_interfaces: |
| 42 | pg.config_ip4() |
| 43 | pg.admin_up() |
| 44 | pg.resolve_arp() |
| 45 | |
| 46 | @classmethod |
| 47 | def tearDownClass(cls): |
| 48 | cls.remote_test.tearDownClass() |
| 49 | cls.remote_test.quit_remote() |
| 50 | for pg in cls.pg_interfaces: |
| 51 | pg.unconfig_ip4() |
| 52 | pg.set_table_ip4(0) |
| 53 | pg.admin_down() |
| 54 | super(TestMemif, cls).tearDownClass() |
| 55 | |
| 56 | def tearDown(self): |
| 57 | remove_all_memif_vpp_config(self) |
| 58 | remove_all_memif_vpp_config(self.remote_test) |
| 59 | super(TestMemif, self).tearDown() |
| 60 | |
| 61 | def _check_socket_filename(self, dump, socket_id, filename): |
| 62 | for d in dump: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 63 | if (d.socket_id == socket_id) and (d.socket_filename == filename): |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 64 | return True |
| 65 | return False |
| 66 | |
| 67 | def test_memif_socket_filename_add_del(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 68 | """Memif socket filename add/del""" |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 69 | |
| 70 | # dump default socket filename |
| 71 | dump = self.vapi.memif_socket_filename_dump() |
| 72 | self.assertTrue( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 73 | self._check_socket_filename(dump, 0, "%s/memif.sock" % self.tempdir) |
| 74 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 75 | |
| 76 | memif_sockets = [] |
| 77 | # existing path |
| 78 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 79 | VppSocketFilename(self, 1, "%s/memif1.sock" % self.tempdir) |
| 80 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 81 | # default path (test tempdir) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 82 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 83 | VppSocketFilename(self, 2, "memif2.sock", add_default_folder=True) |
| 84 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 85 | # create new folder in default folder |
| 86 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 87 | VppSocketFilename(self, 3, "sock/memif3.sock", add_default_folder=True) |
| 88 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 89 | |
| 90 | for sock in memif_sockets: |
| 91 | sock.add_vpp_config() |
| 92 | dump = sock.query_vpp_config() |
| 93 | self.assertTrue( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 94 | self._check_socket_filename(dump, sock.socket_id, sock.socket_filename) |
| 95 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 96 | |
| 97 | for sock in memif_sockets: |
| 98 | sock.remove_vpp_config() |
| 99 | |
| 100 | dump = self.vapi.memif_socket_filename_dump() |
| 101 | self.assertTrue( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 102 | self._check_socket_filename(dump, 0, "%s/memif.sock" % self.tempdir) |
| 103 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 104 | |
| 105 | def _create_delete_test_one_interface(self, memif): |
| 106 | memif.add_vpp_config() |
| 107 | |
| 108 | dump = memif.query_vpp_config() |
| 109 | |
| 110 | self.assertTrue(dump) |
| 111 | self.assertEqual(dump.sw_if_index, memif.sw_if_index) |
| 112 | self.assertEqual(dump.role, memif.role) |
| 113 | self.assertEqual(dump.mode, memif.mode) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 114 | if memif.socket_id is not None: |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 115 | self.assertEqual(dump.socket_id, memif.socket_id) |
| 116 | |
| 117 | memif.remove_vpp_config() |
| 118 | |
| 119 | dump = memif.query_vpp_config() |
| 120 | |
| 121 | self.assertFalse(dump) |
| 122 | |
| 123 | def _connect_test_one_interface(self, memif): |
| 124 | self.assertTrue(memif.wait_for_link_up(5)) |
| 125 | dump = memif.query_vpp_config() |
| 126 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 127 | if memif.role == VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE: |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 128 | self.assertEqual(dump.ring_size, memif.ring_size) |
| 129 | self.assertEqual(dump.buffer_size, memif.buffer_size) |
| 130 | else: |
| 131 | self.assertEqual(dump.ring_size, 1) |
| 132 | self.assertEqual(dump.buffer_size, 0) |
| 133 | |
| 134 | def _connect_test_interface_pair(self, memif0, memif1): |
| 135 | memif0.add_vpp_config() |
| 136 | memif1.add_vpp_config() |
| 137 | |
| 138 | memif0.admin_up() |
| 139 | memif1.admin_up() |
| 140 | |
| 141 | self._connect_test_one_interface(memif0) |
| 142 | self._connect_test_one_interface(memif1) |
| 143 | |
| 144 | memif0.remove_vpp_config() |
| 145 | memif1.remove_vpp_config() |
| 146 | |
| 147 | def test_memif_create_delete(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 148 | """Memif create/delete interface""" |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 149 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 150 | memif = VppMemif( |
| 151 | self, |
| 152 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 153 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 154 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 155 | self._create_delete_test_one_interface(memif) |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 156 | memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 157 | self._create_delete_test_one_interface(memif) |
| 158 | |
| 159 | def test_memif_create_custom_socket(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 160 | """Memif create with non-default socket filename""" |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 161 | |
| 162 | memif_sockets = [] |
| 163 | # existing path |
| 164 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 165 | VppSocketFilename(self, 1, "%s/memif1.sock" % self.tempdir) |
| 166 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 167 | # default path (test tempdir) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 168 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 169 | VppSocketFilename(self, 2, "memif2.sock", add_default_folder=True) |
| 170 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 171 | # create new folder in default folder |
| 172 | memif_sockets.append( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 173 | VppSocketFilename(self, 3, "sock/memif3.sock", add_default_folder=True) |
| 174 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 175 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 176 | memif = VppMemif( |
| 177 | self, |
| 178 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 179 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 180 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 181 | |
| 182 | for sock in memif_sockets: |
| 183 | sock.add_vpp_config() |
| 184 | memif.socket_id = sock.socket_id |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 185 | memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 186 | self._create_delete_test_one_interface(memif) |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 187 | memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 188 | self._create_delete_test_one_interface(memif) |
| 189 | |
| 190 | def test_memif_connect(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 191 | """Memif connect""" |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 192 | memif = VppMemif( |
| 193 | self, |
| 194 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
| 195 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 196 | ring_size=1024, |
| 197 | buffer_size=2048, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 198 | secret="abc", |
| 199 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 200 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 201 | remote_socket = VppSocketFilename( |
| 202 | self.remote_test, 1, "%s/memif.sock" % self.tempdir |
| 203 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 204 | remote_socket.add_vpp_config() |
| 205 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 206 | remote_memif = VppMemif( |
| 207 | self.remote_test, |
| 208 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 209 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 210 | socket_id=1, |
| 211 | ring_size=1024, |
| 212 | buffer_size=2048, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 213 | secret="abc", |
| 214 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 215 | |
| 216 | self._connect_test_interface_pair(memif, remote_memif) |
| 217 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 218 | memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER |
| 219 | remote_memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 220 | |
| 221 | self._connect_test_interface_pair(memif, remote_memif) |
| 222 | |
| 223 | def _create_icmp(self, pg, memif, num): |
| 224 | pkts = [] |
| 225 | for i in range(num): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 226 | pkt = ( |
| 227 | Ether(dst=pg.local_mac, src=pg.remote_mac) |
| 228 | / IP(src=pg.remote_ip4, dst=str(memif.ip_prefix.network_address)) |
| 229 | / ICMP(id=memif.if_id, type="echo-request", seq=i) |
| 230 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 231 | pkts.append(pkt) |
| 232 | return pkts |
| 233 | |
| 234 | def _verify_icmp(self, pg, memif, rx, seq): |
| 235 | ip = rx[IP] |
Neale Ranns | efd7bc2 | 2019-11-11 08:32:34 +0000 | [diff] [blame] | 236 | self.assertEqual(ip.src, str(memif.ip_prefix.network_address)) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 237 | self.assertEqual(ip.dst, pg.remote_ip4) |
| 238 | self.assertEqual(ip.proto, 1) |
| 239 | icmp = rx[ICMP] |
| 240 | self.assertEqual(icmp.type, 0) # echo-reply |
| 241 | self.assertEqual(icmp.id, memif.if_id) |
| 242 | self.assertEqual(icmp.seq, seq) |
| 243 | |
| 244 | def test_memif_ping(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 245 | """Memif ping""" |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 246 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 247 | memif = VppMemif( |
| 248 | self, |
| 249 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 250 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 251 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 252 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 253 | remote_socket = VppSocketFilename( |
| 254 | self.remote_test, 1, "%s/memif.sock" % self.tempdir |
| 255 | ) |
Jakub Grajciar | 9974391 | 2018-10-09 12:28:21 +0200 | [diff] [blame] | 256 | remote_socket.add_vpp_config() |
| 257 | |
Jakub Grajciar | 546f955 | 2019-08-21 10:51:21 +0200 | [diff] [blame] | 258 | remote_memif = VppMemif( |
| 259 | self.remote_test, |
| 260 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 261 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 262 | socket_id=1, |
| 263 | ) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 264 | |
| 265 | memif.add_vpp_config() |
| 266 | memif.config_ip4() |
| 267 | memif.admin_up() |
| 268 | |
| 269 | remote_memif.add_vpp_config() |
| 270 | remote_memif.config_ip4() |
| 271 | remote_memif.admin_up() |
| 272 | |
| 273 | self.assertTrue(memif.wait_for_link_up(5)) |
| 274 | self.assertTrue(remote_memif.wait_for_link_up(5)) |
| 275 | |
| 276 | # add routing to remote vpp |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 277 | route = VppIpRoute( |
| 278 | self.remote_test, |
| 279 | self.pg0._local_ip4_subnet, |
| 280 | 24, |
| 281 | [VppRoutePath(memif.ip_prefix.network_address, 0xFFFFFFFF)], |
| 282 | register=False, |
| 283 | ) |
Jakub Grajciar | 7db35de | 2019-06-25 10:22:11 +0200 | [diff] [blame] | 284 | |
| 285 | route.add_vpp_config() |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 286 | |
| 287 | # create ICMP echo-request from local pg to remote memif |
| 288 | packet_num = 10 |
| 289 | pkts = self._create_icmp(self.pg0, remote_memif, packet_num) |
| 290 | |
| 291 | self.pg0.add_stream(pkts) |
| 292 | self.pg_enable_capture(self.pg_interfaces) |
| 293 | self.pg_start() |
| 294 | capture = self.pg0.get_capture(packet_num, timeout=2) |
| 295 | seq = 0 |
| 296 | for c in capture: |
| 297 | self._verify_icmp(self.pg0, remote_memif, c, seq) |
| 298 | seq += 1 |
| 299 | |
Jakub Grajciar | 7db35de | 2019-06-25 10:22:11 +0200 | [diff] [blame] | 300 | route.remove_vpp_config() |
| 301 | |
Daniel Béreš | 90c397c | 2021-11-03 08:55:04 +0000 | [diff] [blame] | 302 | def test_memif_admin_up_down_up(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 303 | """Memif admin up/down/up""" |
Daniel Béreš | 90c397c | 2021-11-03 08:55:04 +0000 | [diff] [blame] | 304 | memif = VppMemif( |
| 305 | self, |
| 306 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
| 307 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 308 | ring_size=1024, |
| 309 | buffer_size=2048, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 310 | secret="abc", |
| 311 | ) |
Daniel Béreš | 90c397c | 2021-11-03 08:55:04 +0000 | [diff] [blame] | 312 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 313 | remote_socket = VppSocketFilename( |
| 314 | self.remote_test, 1, "%s/memif.sock" % self.tempdir |
| 315 | ) |
Daniel Béreš | 90c397c | 2021-11-03 08:55:04 +0000 | [diff] [blame] | 316 | remote_socket.add_vpp_config() |
| 317 | |
| 318 | remote_memif = VppMemif( |
| 319 | self.remote_test, |
| 320 | VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 321 | VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
| 322 | socket_id=1, |
| 323 | ring_size=1024, |
| 324 | buffer_size=2048, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 325 | secret="abc", |
| 326 | ) |
Daniel Béreš | 90c397c | 2021-11-03 08:55:04 +0000 | [diff] [blame] | 327 | |
| 328 | memif.add_vpp_config() |
| 329 | remote_memif.add_vpp_config() |
| 330 | |
| 331 | memif.admin_up() |
| 332 | remote_memif.admin_up() |
| 333 | memif.admin_down() |
| 334 | remote_memif.admin_down() |
| 335 | memif.admin_up() |
| 336 | remote_memif.admin_up() |
| 337 | |
| 338 | self._connect_test_one_interface(memif) |
| 339 | self._connect_test_one_interface(remote_memif) |
| 340 | |
| 341 | memif.remove_vpp_config() |
| 342 | remote_memif.remove_vpp_config() |
| 343 | remote_socket.remove_vpp_config() |
| 344 | |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 345 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 346 | if __name__ == "__main__": |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 347 | unittest.main(testRunner=VppTestRunner) |