Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | import socket |
| 5 | |
| 6 | from framework import VppTestCase, VppTestRunner |
| 7 | from vpp_ip_route import VppIpRoute, VppRoutePath |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 8 | from vpp_l2 import L2_PORT_TYPE, BRIDGE_FLAGS |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 9 | |
| 10 | from scapy.packet import Raw |
| 11 | from scapy.layers.l2 import Ether |
| 12 | from scapy.layers.inet import IP, UDP |
| 13 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 14 | NUM_PKTS = 67 |
| 15 | |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 16 | |
| 17 | class TestL2Flood(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 18 | """L2-flood""" |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 19 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 20 | @classmethod |
| 21 | def setUpClass(cls): |
| 22 | super(TestL2Flood, cls).setUpClass() |
| 23 | |
| 24 | @classmethod |
| 25 | def tearDownClass(cls): |
| 26 | super(TestL2Flood, cls).tearDownClass() |
| 27 | |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 28 | def setUp(self): |
| 29 | super(TestL2Flood, self).setUp() |
| 30 | |
| 31 | # 12 l2 interface and one l3 |
| 32 | self.create_pg_interfaces(range(13)) |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 33 | self.create_bvi_interfaces(1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 34 | |
| 35 | for i in self.pg_interfaces: |
| 36 | i.admin_up() |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 37 | for i in self.bvi_interfaces: |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 38 | i.admin_up() |
| 39 | |
| 40 | self.pg12.config_ip4() |
| 41 | self.pg12.resolve_arp() |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 42 | self.bvi0.config_ip4() |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 43 | |
| 44 | def tearDown(self): |
| 45 | self.pg12.unconfig_ip4() |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 46 | self.bvi0.unconfig_ip4() |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 47 | |
| 48 | for i in self.pg_interfaces: |
| 49 | i.admin_down() |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 50 | for i in self.bvi_interfaces: |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 51 | i.admin_down() |
| 52 | super(TestL2Flood, self).tearDown() |
| 53 | |
| 54 | def test_flood(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 55 | """L2 Flood Tests""" |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 56 | |
| 57 | # |
| 58 | # Create a single bridge Domain |
| 59 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 60 | self.vapi.bridge_domain_add_del(bd_id=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 61 | |
| 62 | # |
| 63 | # add each interface to the BD. 3 interfaces per split horizon group |
| 64 | # |
| 65 | for i in self.pg_interfaces[0:4]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 66 | self.vapi.sw_interface_set_l2_bridge( |
| 67 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0 |
| 68 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 69 | for i in self.pg_interfaces[4:8]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 70 | self.vapi.sw_interface_set_l2_bridge( |
| 71 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=1 |
| 72 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 73 | for i in self.pg_interfaces[8:12]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 74 | self.vapi.sw_interface_set_l2_bridge( |
| 75 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=2 |
| 76 | ) |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 77 | for i in self.bvi_interfaces: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 78 | self.vapi.sw_interface_set_l2_bridge( |
| 79 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=2, port_type=L2_PORT_TYPE.BVI |
| 80 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 81 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 82 | p = ( |
| 83 | Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef") |
| 84 | / IP(src="10.10.10.10", dst="1.1.1.1") |
| 85 | / UDP(sport=1234, dport=1234) |
| 86 | / Raw(b"\xa5" * 100) |
| 87 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 88 | |
| 89 | # |
| 90 | # input on pg0 expect copies on pg1->11 |
| 91 | # this is in SHG=0 so its flooded to all, expect the pg0 since that's |
| 92 | # the ingress link |
| 93 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 94 | self.pg0.add_stream(p * NUM_PKTS) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 95 | self.pg_enable_capture(self.pg_interfaces) |
| 96 | self.pg_start() |
| 97 | |
| 98 | for i in self.pg_interfaces[1:12]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 99 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 100 | |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 101 | # |
| 102 | # input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0) |
| 103 | # and pg8->11 (SHG=2) |
| 104 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 105 | self.pg4.add_stream(p * NUM_PKTS) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 106 | self.pg_enable_capture(self.pg_interfaces) |
| 107 | self.pg_start() |
| 108 | |
| 109 | for i in self.pg_interfaces[:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 110 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 111 | for i in self.pg_interfaces[8:12]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 112 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 113 | for i in self.pg_interfaces[4:8]: |
| 114 | i.assert_nothing_captured(remark="Different SH group") |
| 115 | |
| 116 | # |
| 117 | # An IP route so the packet that hits the BVI is sent out of pg12 |
| 118 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 119 | ip_route = VppIpRoute( |
| 120 | self, |
| 121 | "1.1.1.1", |
| 122 | 32, |
| 123 | [VppRoutePath(self.pg12.remote_ip4, self.pg12.sw_if_index)], |
| 124 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 125 | ip_route.add_vpp_config() |
| 126 | |
| 127 | self.logger.info(self.vapi.cli("sh bridge 1 detail")) |
| 128 | |
| 129 | # |
| 130 | # input on pg0 expect copies on pg1->12 |
| 131 | # this is in SHG=0 so its flooded to all, expect the pg0 since that's |
| 132 | # the ingress link |
| 133 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 134 | self.pg0.add_stream(p * NUM_PKTS) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 135 | self.pg_enable_capture(self.pg_interfaces) |
| 136 | self.pg_start() |
| 137 | |
| 138 | for i in self.pg_interfaces[1:]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 139 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 140 | |
| 141 | # |
| 142 | # input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0) |
| 143 | # and pg8->12 (SHG=2) |
| 144 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 145 | self.pg4.add_stream(p * NUM_PKTS) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 146 | self.pg_enable_capture(self.pg_interfaces) |
| 147 | self.pg_start() |
| 148 | |
| 149 | for i in self.pg_interfaces[:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 150 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 151 | for i in self.pg_interfaces[8:13]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 152 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 153 | for i in self.pg_interfaces[4:8]: |
| 154 | i.assert_nothing_captured(remark="Different SH group") |
| 155 | |
| 156 | # |
| 157 | # cleanup |
| 158 | # |
| 159 | for i in self.pg_interfaces[:12]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 160 | self.vapi.sw_interface_set_l2_bridge( |
| 161 | rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0 |
| 162 | ) |
Neale Ranns | 192b13f | 2019-03-15 02:16:20 -0700 | [diff] [blame] | 163 | for i in self.bvi_interfaces: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 164 | self.vapi.sw_interface_set_l2_bridge( |
| 165 | rx_sw_if_index=i.sw_if_index, |
| 166 | bd_id=1, |
| 167 | shg=2, |
| 168 | port_type=L2_PORT_TYPE.BVI, |
| 169 | enable=0, |
| 170 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 171 | |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 172 | self.vapi.bridge_domain_add_del(bd_id=1, is_add=0) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 173 | |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 174 | def test_flood_one(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 175 | """L2 no-Flood Test""" |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 176 | |
| 177 | # |
| 178 | # Create a single bridge Domain |
| 179 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 180 | self.vapi.bridge_domain_add_del(bd_id=1) |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 181 | |
| 182 | # |
| 183 | # add 2 interfaces to the BD. this means a flood goes to only |
| 184 | # one member |
| 185 | # |
| 186 | for i in self.pg_interfaces[:2]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 187 | self.vapi.sw_interface_set_l2_bridge( |
| 188 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0 |
| 189 | ) |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 190 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 191 | p = ( |
| 192 | Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef") |
| 193 | / IP(src="10.10.10.10", dst="1.1.1.1") |
| 194 | / UDP(sport=1234, dport=1234) |
| 195 | / Raw(b"\xa5" * 100) |
| 196 | ) |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 197 | |
| 198 | # |
| 199 | # input on pg0 expect copies on pg1 |
| 200 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 201 | self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 202 | |
| 203 | # |
| 204 | # cleanup |
| 205 | # |
| 206 | for i in self.pg_interfaces[:2]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 207 | self.vapi.sw_interface_set_l2_bridge( |
| 208 | rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0 |
| 209 | ) |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 210 | self.vapi.bridge_domain_add_del(bd_id=1, is_add=0) |
Neale Ranns | b9fa29d | 2018-10-02 07:27:02 -0700 | [diff] [blame] | 211 | |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 212 | def test_uu_fwd(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 213 | """UU Flood""" |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 214 | |
| 215 | # |
| 216 | # Create a single bridge Domain |
| 217 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 218 | self.vapi.bridge_domain_add_del(bd_id=1, uu_flood=1) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 219 | |
| 220 | # |
| 221 | # add each interface to the BD. 3 interfaces per split horizon group |
| 222 | # |
| 223 | for i in self.pg_interfaces[0:4]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 224 | self.vapi.sw_interface_set_l2_bridge( |
| 225 | rx_sw_if_index=i.sw_if_index, bd_id=1, shg=0 |
| 226 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 227 | |
| 228 | # |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 229 | # an unknown unicast and broadcast packets |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 230 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 231 | p_uu = ( |
| 232 | Ether(dst="00:00:00:c1:5c:00", src="00:00:de:ad:be:ef") |
| 233 | / IP(src="10.10.10.10", dst="1.1.1.1") |
| 234 | / UDP(sport=1234, dport=1234) |
| 235 | / Raw(b"\xa5" * 100) |
| 236 | ) |
| 237 | p_bm = ( |
| 238 | Ether(dst="ff:ff:ff:ff:ff:ff", src="00:00:de:ad:be:ef") |
| 239 | / IP(src="10.10.10.10", dst="1.1.1.1") |
| 240 | / UDP(sport=1234, dport=1234) |
| 241 | / Raw(b"\xa5" * 100) |
| 242 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 243 | |
| 244 | # |
| 245 | # input on pg0, expected copies on pg1->4 |
| 246 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 247 | self.pg0.add_stream(p_uu * NUM_PKTS) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 248 | self.pg_enable_capture(self.pg_interfaces) |
| 249 | self.pg_start() |
| 250 | |
| 251 | for i in self.pg_interfaces[1:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 252 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 253 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 254 | self.pg0.add_stream(p_bm * NUM_PKTS) |
Neale Ranns | d29cc88 | 2018-10-10 15:55:01 +0000 | [diff] [blame] | 255 | self.pg_enable_capture(self.pg_interfaces) |
| 256 | self.pg_start() |
| 257 | |
| 258 | for i in self.pg_interfaces[1:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 259 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | d29cc88 | 2018-10-10 15:55:01 +0000 | [diff] [blame] | 260 | |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 261 | # |
| 262 | # use pg8 as the uu-fwd interface |
| 263 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 264 | self.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 265 | rx_sw_if_index=self.pg8.sw_if_index, |
| 266 | bd_id=1, |
| 267 | shg=0, |
| 268 | port_type=L2_PORT_TYPE.UU_FWD, |
| 269 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 270 | |
| 271 | # |
| 272 | # expect the UU packet on the uu-fwd interface and not be flooded |
| 273 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 274 | self.pg0.add_stream(p_uu * NUM_PKTS) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 275 | self.pg_enable_capture(self.pg_interfaces) |
| 276 | self.pg_start() |
| 277 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 278 | rx0 = self.pg8.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 279 | |
| 280 | for i in self.pg_interfaces[0:4]: |
| 281 | i.assert_nothing_captured(remark="UU not flooded") |
| 282 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 283 | self.pg0.add_stream(p_bm * NUM_PKTS) |
Neale Ranns | d29cc88 | 2018-10-10 15:55:01 +0000 | [diff] [blame] | 284 | self.pg_enable_capture(self.pg_interfaces) |
| 285 | self.pg_start() |
| 286 | |
| 287 | for i in self.pg_interfaces[1:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 288 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | d29cc88 | 2018-10-10 15:55:01 +0000 | [diff] [blame] | 289 | |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 290 | # |
| 291 | # remove the uu-fwd interface and expect UU to be flooded again |
| 292 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 293 | self.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 294 | rx_sw_if_index=self.pg8.sw_if_index, |
| 295 | bd_id=1, |
| 296 | shg=0, |
| 297 | port_type=L2_PORT_TYPE.UU_FWD, |
| 298 | enable=0, |
| 299 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 300 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 301 | self.pg0.add_stream(p_uu * NUM_PKTS) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 302 | self.pg_enable_capture(self.pg_interfaces) |
| 303 | self.pg_start() |
| 304 | |
| 305 | for i in self.pg_interfaces[1:4]: |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 306 | rx0 = i.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 307 | |
| 308 | # |
| 309 | # change the BD config to not support UU-flood |
| 310 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 311 | self.vapi.bridge_flags(bd_id=1, is_set=0, flags=BRIDGE_FLAGS.UU_FLOOD) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 312 | |
| 313 | self.send_and_assert_no_replies(self.pg0, p_uu) |
| 314 | |
| 315 | # |
| 316 | # re-add the uu-fwd interface |
| 317 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 318 | self.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 319 | rx_sw_if_index=self.pg8.sw_if_index, |
| 320 | bd_id=1, |
| 321 | shg=0, |
| 322 | port_type=L2_PORT_TYPE.UU_FWD, |
| 323 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 324 | self.logger.info(self.vapi.cli("sh bridge 1 detail")) |
| 325 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 326 | self.pg0.add_stream(p_uu * NUM_PKTS) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 327 | self.pg_enable_capture(self.pg_interfaces) |
| 328 | self.pg_start() |
| 329 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 330 | rx0 = self.pg8.get_capture(NUM_PKTS, timeout=1) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 331 | |
| 332 | for i in self.pg_interfaces[0:4]: |
| 333 | i.assert_nothing_captured(remark="UU not flooded") |
| 334 | |
| 335 | # |
| 336 | # remove the uu-fwd interface |
| 337 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 338 | self.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 339 | rx_sw_if_index=self.pg8.sw_if_index, |
| 340 | bd_id=1, |
| 341 | shg=0, |
| 342 | port_type=L2_PORT_TYPE.UU_FWD, |
| 343 | enable=0, |
| 344 | ) |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 345 | self.send_and_assert_no_replies(self.pg0, p_uu) |
| 346 | |
| 347 | # |
| 348 | # cleanup |
| 349 | # |
| 350 | for i in self.pg_interfaces[:4]: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 351 | self.vapi.sw_interface_set_l2_bridge( |
| 352 | rx_sw_if_index=i.sw_if_index, bd_id=1, enable=0 |
| 353 | ) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 354 | |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 355 | self.vapi.bridge_domain_add_del(bd_id=1, is_add=0) |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 356 | |
| 357 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 358 | if __name__ == "__main__": |
Neale Ranns | 055b231 | 2018-07-20 01:16:04 -0700 | [diff] [blame] | 359 | unittest.main(testRunner=VppTestRunner) |