Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 3 | import unittest |
| 4 | |
| 5 | from scapy.contrib.lacp import LACP, SlowProtocol, MarkerProtocol |
| 6 | from scapy.layers.l2 import Ether |
| 7 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 8 | from framework import VppTestCase |
| 9 | from asfframework import VppTestRunner |
| 10 | from vpp_memif import VppSocketFilename, VppMemif |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 11 | from vpp_bond_interface import VppBondInterface |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 12 | from vpp_papi import VppEnum |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 13 | from config import config |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 14 | |
| 15 | bond_mac = "02:02:02:02:02:02" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 16 | lacp_dst_mac = "01:80:c2:00:00:02" |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 17 | LACP_COLLECTION_AND_DISTRIBUTION_STATE = 63 |
| 18 | |
| 19 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 20 | @unittest.skipIf("lacp" in config.excluded_plugins, "Exclude LACP plugin tests") |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 21 | class TestMarker(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 22 | """LACP Marker Protocol Test Case""" |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 23 | |
| 24 | @classmethod |
| 25 | def setUpClass(cls): |
| 26 | super().setUpClass() |
| 27 | # Test variables |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 28 | cls.pkts_per_burst = 257 # Number of packets per burst |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 29 | # create 3 pg interfaces |
| 30 | cls.create_pg_interfaces(range(1)) |
| 31 | |
| 32 | # packet sizes |
| 33 | cls.pg_if_packet_sizes = [64, 512, 1518] # , 9018] |
| 34 | |
| 35 | # setup all interfaces |
| 36 | for i in cls.pg_interfaces: |
| 37 | i.admin_up() |
| 38 | |
| 39 | @classmethod |
| 40 | def tearDownClass(cls): |
| 41 | super().tearDownClass() |
| 42 | |
| 43 | def setUp(self): |
| 44 | super().setUp() |
| 45 | |
| 46 | def tearDown(self): |
| 47 | super().tearDown() |
| 48 | |
| 49 | def show_commands_at_teardown(self): |
| 50 | self.logger.info(self.vapi.ppcli("show interface")) |
| 51 | |
| 52 | def test_marker_request(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 53 | """Marker Request test""" |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 54 | |
| 55 | # topology |
| 56 | # |
| 57 | # +-+ +-+ |
| 58 | # memif1 -----|B| |B|---- memif11 |
| 59 | # |o| |o| |
| 60 | # |n|------|n| |
| 61 | # |d| |d| |
| 62 | # pg0 -----|0| |1| |
| 63 | # +-+ +-+ |
| 64 | |
| 65 | socket1 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 66 | self, socket_id=1, socket_filename="%s/memif.sock1" % self.tempdir |
| 67 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 68 | socket1.add_vpp_config() |
| 69 | |
| 70 | socket11 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 71 | self, socket_id=2, socket_filename="%s/memif.sock1" % self.tempdir |
| 72 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 73 | socket11.add_vpp_config() |
| 74 | |
| 75 | memif1 = VppMemif( |
| 76 | self, |
| 77 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 78 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 79 | socket_id=1, |
| 80 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 81 | memif1.add_vpp_config() |
| 82 | memif1.admin_up() |
| 83 | |
| 84 | memif11 = VppMemif( |
| 85 | self, |
| 86 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
| 87 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 88 | socket_id=2, |
| 89 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 90 | memif11.add_vpp_config() |
| 91 | memif11.admin_up() |
| 92 | |
| 93 | bond0 = VppBondInterface( |
| 94 | self, |
| 95 | mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP, |
| 96 | use_custom_mac=1, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 97 | mac_address=bond_mac, |
| 98 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 99 | |
| 100 | bond0.add_vpp_config() |
| 101 | bond0.admin_up() |
| 102 | |
| 103 | bond1 = VppBondInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 104 | self, mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP |
| 105 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 106 | bond1.add_vpp_config() |
| 107 | bond1.admin_up() |
| 108 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 109 | bond0.add_member_vpp_bond_interface(sw_if_index=memif1.sw_if_index) |
| 110 | bond1.add_member_vpp_bond_interface(sw_if_index=memif11.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 111 | |
| 112 | # wait for memif protocol exchange and hardware carrier to come up |
| 113 | self.assertEqual(memif1.wait_for_link_up(10), True) |
| 114 | self.assertEqual(memif11.wait_for_link_up(10), True) |
| 115 | |
| 116 | # verify memif1 in bond0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 117 | intfs = self.vapi.sw_member_interface_dump(sw_if_index=bond0.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 118 | for intf in intfs: |
| 119 | self.assertEqual(intf.sw_if_index, memif1.sw_if_index) |
| 120 | |
| 121 | # verify memif11 in bond1 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 122 | intfs = self.vapi.sw_member_interface_dump(sw_if_index=bond1.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 123 | for intf in intfs: |
| 124 | self.assertEqual(intf.sw_if_index, memif11.sw_if_index) |
| 125 | |
| 126 | self.vapi.ppcli("trace add memif-input 100") |
| 127 | |
| 128 | # create marker request |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 129 | marker = ( |
| 130 | Ether(src=bond_mac, dst=lacp_dst_mac) |
| 131 | / SlowProtocol() |
| 132 | / MarkerProtocol( |
| 133 | marker_type=1, |
| 134 | requester_port=1, |
| 135 | requester_system=bond_mac, |
| 136 | requester_transaction_id=1, |
| 137 | ) |
| 138 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 139 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 140 | bond1.add_member_vpp_bond_interface(sw_if_index=self.pg0.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 141 | self.pg0.add_stream(marker) |
| 142 | self.pg_enable_capture(self.pg_interfaces) |
| 143 | self.pg_start() |
| 144 | |
| 145 | show_trace = self.vapi.ppcli("show trace max 100") |
| 146 | self.assertIn("Marker Information TLV:", show_trace) |
| 147 | |
| 148 | bond0.remove_vpp_config() |
| 149 | bond1.remove_vpp_config() |
| 150 | |
| 151 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 152 | @unittest.skipIf("lacp" in config.excluded_plugins, "Exclude LACP plugin tests") |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 153 | class TestLACP(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 154 | """LACP Test Case""" |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 155 | |
| 156 | @classmethod |
| 157 | def setUpClass(cls): |
| 158 | super().setUpClass() |
| 159 | |
| 160 | @classmethod |
| 161 | def tearDownClass(cls): |
| 162 | super().tearDownClass() |
| 163 | |
| 164 | def setUp(self): |
| 165 | super().setUp() |
| 166 | |
| 167 | def tearDown(self): |
| 168 | super().tearDown() |
| 169 | |
| 170 | def show_commands_at_teardown(self): |
| 171 | self.logger.info(self.vapi.ppcli("show interface")) |
| 172 | |
| 173 | def wait_for_lacp_connect(self, timeout, step=1): |
| 174 | while 1: |
| 175 | intfs = self.vapi.sw_interface_lacp_dump() |
| 176 | all_good = 1 |
| 177 | for intf in intfs: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 178 | if (intf.actor_state != LACP_COLLECTION_AND_DISTRIBUTION_STATE) or ( |
| 179 | intf.partner_state != LACP_COLLECTION_AND_DISTRIBUTION_STATE |
| 180 | ): |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 181 | all_good = 0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 182 | if all_good == 1: |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 183 | return 1 |
| 184 | self.sleep(step) |
| 185 | timeout -= step |
| 186 | if timeout <= 0: |
| 187 | return 0 |
| 188 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 189 | def wait_for_member_detach(self, bond, timeout, count, step=1): |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 190 | while 1: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 191 | intfs = self.vapi.sw_bond_interface_dump(sw_if_index=bond.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 192 | for intf in intfs: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 193 | if (intf.members == count) and (intf.active_members == count): |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 194 | return 1 |
| 195 | else: |
| 196 | self.sleep(1) |
| 197 | timeout -= step |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 198 | if timeouut <= 0: |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 199 | return 0 |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 200 | |
| 201 | def test_lacp_connect(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 202 | """LACP protocol connect test""" |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 203 | |
| 204 | # topology |
| 205 | # |
| 206 | # +-+ +-+ |
| 207 | # memif1 -----|B| |B|---- memif11 |
| 208 | # |o| |o| |
| 209 | # |n|------|n| |
| 210 | # |d| |d| |
| 211 | # memif2 -----|0| |1|---- memif12 |
| 212 | # +-+ +-+ |
| 213 | |
| 214 | socket1 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 215 | self, socket_id=1, socket_filename="%s/memif.sock1" % self.tempdir |
| 216 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 217 | socket1.add_vpp_config() |
| 218 | |
| 219 | socket11 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 220 | self, socket_id=2, socket_filename="%s/memif.sock1" % self.tempdir |
| 221 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 222 | socket11.add_vpp_config() |
| 223 | |
| 224 | socket2 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 225 | self, socket_id=3, socket_filename="%s/memif.sock2" % self.tempdir |
| 226 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 227 | socket2.add_vpp_config() |
| 228 | |
| 229 | socket22 = VppSocketFilename( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 230 | self, socket_id=4, socket_filename="%s/memif.sock2" % self.tempdir |
| 231 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 232 | socket22.add_vpp_config() |
| 233 | |
| 234 | memif1 = VppMemif( |
| 235 | self, |
| 236 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 237 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 238 | socket_id=1, |
| 239 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 240 | memif1.add_vpp_config() |
| 241 | memif1.admin_up() |
| 242 | |
| 243 | memif11 = VppMemif( |
| 244 | self, |
| 245 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
| 246 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 247 | socket_id=2, |
| 248 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 249 | memif11.add_vpp_config() |
| 250 | memif11.admin_up() |
| 251 | |
| 252 | memif2 = VppMemif( |
| 253 | self, |
| 254 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, |
| 255 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 256 | socket_id=3, |
| 257 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 258 | memif2.add_vpp_config() |
| 259 | memif2.admin_up() |
| 260 | |
| 261 | memif12 = VppMemif( |
| 262 | self, |
| 263 | role=VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, |
| 264 | mode=VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 265 | socket_id=4, |
| 266 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 267 | memif12.add_vpp_config() |
| 268 | memif12.admin_up() |
| 269 | |
| 270 | self.logger.info(self.vapi.ppcli("debug lacp on")) |
| 271 | bond0 = VppBondInterface( |
| 272 | self, |
| 273 | mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP, |
| 274 | use_custom_mac=1, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 275 | mac_address=bond_mac, |
| 276 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 277 | |
| 278 | bond0.add_vpp_config() |
| 279 | bond0.admin_up() |
| 280 | |
| 281 | bond1 = VppBondInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 282 | self, mode=VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP |
| 283 | ) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 284 | bond1.add_vpp_config() |
| 285 | bond1.admin_up() |
| 286 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 287 | # add member memif1 and memif2 to bond0 |
| 288 | bond0.add_member_vpp_bond_interface(sw_if_index=memif1.sw_if_index) |
| 289 | bond0.add_member_vpp_bond_interface(sw_if_index=memif2.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 290 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 291 | # add member memif11 and memif12 to bond1 |
| 292 | bond1.add_member_vpp_bond_interface(sw_if_index=memif11.sw_if_index) |
| 293 | bond1.add_member_vpp_bond_interface(sw_if_index=memif12.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 294 | |
| 295 | # wait for memif protocol exchange and hardware carrier to come up |
| 296 | self.assertEqual(memif1.wait_for_link_up(10), True) |
| 297 | self.assertEqual(memif2.wait_for_link_up(10), True) |
| 298 | self.assertEqual(memif11.wait_for_link_up(10), True) |
| 299 | self.assertEqual(memif12.wait_for_link_up(10), True) |
| 300 | |
| 301 | # verify memif1 and memif2 in bond0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 302 | intfs = self.vapi.sw_member_interface_dump(sw_if_index=bond0.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 303 | for intf in intfs: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 304 | self.assertIn(intf.sw_if_index, (memif1.sw_if_index, memif2.sw_if_index)) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 305 | |
| 306 | # verify memif11 and memif12 in bond1 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 307 | intfs = self.vapi.sw_member_interface_dump(sw_if_index=bond1.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 308 | for intf in intfs: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 309 | self.assertIn(intf.sw_if_index, (memif11.sw_if_index, memif12.sw_if_index)) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 310 | self.assertEqual(intf.is_long_timeout, 0) |
| 311 | self.assertEqual(intf.is_passive, 0) |
| 312 | |
| 313 | # Let LACP create the bundle |
| 314 | self.wait_for_lacp_connect(30) |
| 315 | |
| 316 | intfs = self.vapi.sw_interface_lacp_dump() |
| 317 | for intf in intfs: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 318 | self.assertEqual(intf.actor_state, LACP_COLLECTION_AND_DISTRIBUTION_STATE) |
| 319 | self.assertEqual(intf.partner_state, LACP_COLLECTION_AND_DISTRIBUTION_STATE) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 320 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 321 | intfs = self.vapi.sw_bond_interface_dump(sw_if_index=0xFFFFFFFF) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 322 | for intf in intfs: |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 323 | self.assertEqual(intf.members, 2) |
| 324 | self.assertEqual(intf.active_members, 2) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 325 | self.assertEqual(intf.mode, VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 326 | |
| 327 | self.logger.info(self.vapi.ppcli("show lacp")) |
| 328 | self.logger.info(self.vapi.ppcli("show lacp details")) |
| 329 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 330 | # detach member memif1 |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 331 | bond0.detach_vpp_bond_interface(sw_if_index=memif1.sw_if_index) |
| 332 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 333 | self.wait_for_member_detach(bond0, timeout=10, count=1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 334 | intfs = self.vapi.sw_bond_interface_dump(sw_if_index=bond0.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 335 | for intf in intfs: |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 336 | self.assertEqual(intf.members, 1) |
| 337 | self.assertEqual(intf.active_members, 1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 338 | self.assertEqual(intf.mode, VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 339 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 340 | # detach member memif2 |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 341 | bond0.detach_vpp_bond_interface(sw_if_index=memif2.sw_if_index) |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 342 | self.wait_for_member_detach(bond0, timeout=10, count=0) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 343 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 344 | intfs = self.vapi.sw_bond_interface_dump(sw_if_index=bond0.sw_if_index) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 345 | for intf in intfs: |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 346 | self.assertEqual(intf.members, 0) |
| 347 | self.assertEqual(intf.active_members, 0) |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 348 | |
| 349 | bond0.remove_vpp_config() |
| 350 | bond1.remove_vpp_config() |
| 351 | |
| 352 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 353 | if __name__ == "__main__": |
Steven Luong | a4611b8 | 2020-05-15 12:21:50 -0700 | [diff] [blame] | 354 | unittest.main(testRunner=VppTestRunner) |