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