Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 5 | from framework import VppTestCase |
| 6 | from asfframework import VppTestRunner, tag_fixme_vpp_workers |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 7 | from vpp_ip_route import ( |
| 8 | VppIpMRoute, |
| 9 | VppMRoutePath, |
| 10 | VppMFibSignal, |
| 11 | VppIpTable, |
| 12 | FibPathProto, |
| 13 | FibPathType, |
| 14 | ) |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 15 | from vpp_gre_interface import VppGreInterface |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 16 | from vpp_papi import VppEnum |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 17 | from config import config |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 18 | |
| 19 | from scapy.packet import Raw |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 20 | from scapy.layers.l2 import Ether, GRE |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 21 | from scapy.layers.inet import IP, UDP, getmacbyip, ICMP |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 22 | from scapy.layers.inet6 import IPv6, getmacbyip6 |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 23 | |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 24 | # |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 25 | # The number of packets sent is set to 91 so that when we replicate more than 3 |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 26 | # times, which we do for some entries, we will generate more than 256 packets |
Neale Ranns | aaa396a | 2017-02-05 09:12:02 -0800 | [diff] [blame] | 27 | # to the next node in the VLIB graph. Thus we are testing the code's |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 28 | # correctness handling this over-flow. |
| 29 | # It's also an odd number so we hit any single loops. |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 30 | # |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 31 | N_PKTS_IN_STREAM = 91 |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 32 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 33 | |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 34 | class TestMFIB(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 35 | """MFIB Test Case""" |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 36 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 37 | @classmethod |
| 38 | def setUpClass(cls): |
| 39 | super(TestMFIB, cls).setUpClass() |
| 40 | |
| 41 | @classmethod |
| 42 | def tearDownClass(cls): |
| 43 | super(TestMFIB, cls).tearDownClass() |
| 44 | |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 45 | def setUp(self): |
| 46 | super(TestMFIB, self).setUp() |
| 47 | |
| 48 | def test_mfib(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 49 | """MFIB Unit Tests""" |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 50 | error = self.vapi.cli("test mfib") |
| 51 | |
| 52 | if error: |
| 53 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 54 | self.assertNotIn("Failed", error) |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 55 | |
| 56 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 57 | @tag_fixme_vpp_workers |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 58 | class TestIPMcast(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 59 | """IP Multicast Test Case""" |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 60 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 61 | @classmethod |
| 62 | def setUpClass(cls): |
| 63 | super(TestIPMcast, cls).setUpClass() |
| 64 | |
| 65 | @classmethod |
| 66 | def tearDownClass(cls): |
| 67 | super(TestIPMcast, cls).tearDownClass() |
| 68 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 69 | def setUp(self): |
| 70 | super(TestIPMcast, self).setUp() |
| 71 | |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 72 | # create 8 pg interfaces |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 73 | self.create_pg_interfaces(range(9)) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 74 | |
| 75 | # setup interfaces |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 76 | for i in self.pg_interfaces[:8]: |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 77 | i.admin_up() |
| 78 | i.config_ip4() |
| 79 | i.config_ip6() |
| 80 | i.resolve_arp() |
| 81 | i.resolve_ndp() |
| 82 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 83 | # one more in a vrf |
| 84 | tbl4 = VppIpTable(self, 10) |
| 85 | tbl4.add_vpp_config() |
| 86 | self.pg8.set_table_ip4(10) |
| 87 | self.pg8.config_ip4() |
| 88 | |
| 89 | tbl6 = VppIpTable(self, 10, is_ip6=1) |
| 90 | tbl6.add_vpp_config() |
| 91 | self.pg8.set_table_ip6(10) |
| 92 | self.pg8.config_ip6() |
| 93 | |
| 94 | def tearDown(self): |
| 95 | for i in self.pg_interfaces: |
| 96 | i.unconfig_ip4() |
| 97 | i.unconfig_ip6() |
| 98 | i.admin_down() |
| 99 | |
| 100 | self.pg8.set_table_ip4(0) |
| 101 | self.pg8.set_table_ip6(0) |
| 102 | super(TestIPMcast, self).tearDown() |
| 103 | |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 104 | def create_stream_ip4(self, src_if, src_ip, dst_ip, payload_size=0): |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 105 | pkts = [] |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 106 | # default to small packet sizes |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 107 | p = ( |
| 108 | Ether(dst=getmacbyip(dst_ip), src=src_if.remote_mac) |
| 109 | / IP(src=src_ip, dst=dst_ip) |
| 110 | / UDP(sport=1234, dport=1234) |
| 111 | ) |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 112 | if not payload_size: |
| 113 | payload_size = 64 - len(p) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 114 | p = p / Raw(b"\xa5" * payload_size) |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 115 | |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 116 | for i in range(0, N_PKTS_IN_STREAM): |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 117 | pkts.append(p) |
| 118 | return pkts |
| 119 | |
| 120 | def create_stream_ip6(self, src_if, src_ip, dst_ip): |
| 121 | pkts = [] |
Neale Ranns | 9bea8fb | 2017-02-03 04:34:01 -0800 | [diff] [blame] | 122 | for i in range(0, N_PKTS_IN_STREAM): |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 123 | info = self.create_packet_info(src_if, src_if) |
| 124 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 125 | p = ( |
| 126 | Ether(dst=getmacbyip6(dst_ip), src=src_if.remote_mac) |
| 127 | / IPv6(src=src_ip, dst=dst_ip) |
| 128 | / UDP(sport=1234, dport=1234) |
| 129 | / Raw(payload) |
| 130 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 131 | info.data = p.copy() |
| 132 | pkts.append(p) |
| 133 | return pkts |
| 134 | |
| 135 | def verify_filter(self, capture, sent): |
| 136 | if not len(capture) == len(sent): |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 137 | # filter out any IPv6 RAs from the capture |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 138 | for p in capture: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 139 | if p.haslayer(IPv6): |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 140 | capture.remove(p) |
| 141 | return capture |
| 142 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 143 | def verify_capture_ip4(self, rx_if, sent, dst_mac=None): |
Neale Ranns | c2aad53 | 2017-05-30 09:53:52 -0700 | [diff] [blame] | 144 | rxd = rx_if.get_capture(len(sent)) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 145 | |
| 146 | try: |
| 147 | capture = self.verify_filter(rxd, sent) |
| 148 | |
| 149 | self.assertEqual(len(capture), len(sent)) |
| 150 | |
| 151 | for i in range(len(capture)): |
| 152 | tx = sent[i] |
| 153 | rx = capture[i] |
| 154 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 155 | eth = rx[Ether] |
| 156 | self.assertEqual(eth.type, 0x800) |
| 157 | |
| 158 | tx_ip = tx[IP] |
| 159 | rx_ip = rx[IP] |
| 160 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 161 | if dst_mac is None: |
| 162 | dst_mac = getmacbyip(rx_ip.dst) |
| 163 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 164 | # check the MAC address on the RX'd packet is correctly formed |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 165 | self.assertEqual(eth.dst, dst_mac) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 166 | |
| 167 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 168 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 169 | # IP processing post pop has decremented the TTL |
| 170 | self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl) |
| 171 | |
| 172 | except: |
| 173 | raise |
| 174 | |
Neale Ranns | c2aad53 | 2017-05-30 09:53:52 -0700 | [diff] [blame] | 175 | def verify_capture_ip6(self, rx_if, sent): |
| 176 | capture = rx_if.get_capture(len(sent)) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 177 | |
| 178 | self.assertEqual(len(capture), len(sent)) |
| 179 | |
| 180 | for i in range(len(capture)): |
| 181 | tx = sent[i] |
| 182 | rx = capture[i] |
| 183 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 184 | eth = rx[Ether] |
| 185 | self.assertEqual(eth.type, 0x86DD) |
| 186 | |
| 187 | tx_ip = tx[IPv6] |
| 188 | rx_ip = rx[IPv6] |
| 189 | |
| 190 | # check the MAC address on the RX'd packet is correctly formed |
| 191 | self.assertEqual(eth.dst, getmacbyip6(rx_ip.dst)) |
| 192 | |
| 193 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 194 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 195 | # IP processing post pop has decremented the TTL |
| 196 | self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim) |
| 197 | |
| 198 | def test_ip_mcast(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 199 | """IP Multicast Replication""" |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 200 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 201 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 202 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 203 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 204 | # |
| 205 | # a stream that matches the default route. gets dropped. |
| 206 | # |
| 207 | self.vapi.cli("clear trace") |
Neale Ranns | 21fb4f7 | 2020-10-05 12:26:47 +0000 | [diff] [blame] | 208 | self.vapi.cli("packet mac-filter pg0 on") |
| 209 | self.vapi.cli("packet mac-filter pg1 on") |
| 210 | self.vapi.cli("packet mac-filter pg2 on") |
| 211 | self.vapi.cli("packet mac-filter pg4 on") |
| 212 | self.vapi.cli("packet mac-filter pg5 on") |
| 213 | self.vapi.cli("packet mac-filter pg6 on") |
| 214 | self.vapi.cli("packet mac-filter pg7 on") |
| 215 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 216 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1") |
| 217 | self.pg0.add_stream(tx) |
| 218 | |
| 219 | self.pg_enable_capture(self.pg_interfaces) |
| 220 | self.pg_start() |
| 221 | |
| 222 | self.pg0.assert_nothing_captured( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 223 | remark="IP multicast packets forwarded on default route" |
| 224 | ) |
Neale Ranns | e22a704 | 2022-08-09 03:03:29 +0000 | [diff] [blame] | 225 | count = self.statistics.get_err_counter("/err/ip4-input/rpf_failure") |
Neale Ranns | e8f57d5 | 2021-10-12 07:49:37 +0000 | [diff] [blame] | 226 | self.assertEqual(count, len(tx)) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 227 | |
| 228 | # |
| 229 | # A (*,G). |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 230 | # one accepting interface, pg0, 7 forwarding interfaces |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 231 | # many forwarding interfaces test the case where the replicate DPO |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 232 | # needs to use extra cache lines for the buckets. |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 233 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 234 | route_232_1_1_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 235 | self, |
| 236 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 237 | "232.1.1.1", |
| 238 | 32, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 239 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 240 | [ |
| 241 | VppMRoutePath( |
| 242 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 243 | ), |
| 244 | VppMRoutePath( |
| 245 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 246 | ), |
| 247 | VppMRoutePath( |
| 248 | self.pg2.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 249 | ), |
| 250 | VppMRoutePath( |
| 251 | self.pg3.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 252 | ), |
| 253 | VppMRoutePath( |
| 254 | self.pg4.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 255 | ), |
| 256 | VppMRoutePath( |
| 257 | self.pg5.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 258 | ), |
| 259 | VppMRoutePath( |
| 260 | self.pg6.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 261 | ), |
| 262 | VppMRoutePath( |
| 263 | self.pg7.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 264 | ), |
| 265 | ], |
| 266 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 267 | route_232_1_1_1.add_vpp_config() |
| 268 | |
| 269 | # |
| 270 | # An (S,G). |
| 271 | # one accepting interface, pg0, 2 forwarding interfaces |
| 272 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 273 | route_1_1_1_1_232_1_1_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 274 | self, |
| 275 | "1.1.1.1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 276 | "232.1.1.1", |
| 277 | 27, # any grp-len is ok when src is set |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 278 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 279 | [ |
| 280 | VppMRoutePath( |
| 281 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 282 | ), |
| 283 | VppMRoutePath( |
| 284 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 285 | ), |
| 286 | VppMRoutePath( |
| 287 | self.pg2.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 288 | ), |
| 289 | ], |
| 290 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 291 | route_1_1_1_1_232_1_1_1.add_vpp_config() |
| 292 | |
| 293 | # |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 294 | # An (S,G). |
| 295 | # one accepting interface, pg0, 2 forwarding interfaces |
| 296 | # that use unicast next-hops |
| 297 | # |
| 298 | route_1_1_1_1_232_1_1_2 = VppIpMRoute( |
| 299 | self, |
| 300 | "1.1.1.1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 301 | "232.1.1.2", |
| 302 | 64, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 303 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 304 | [ |
| 305 | VppMRoutePath( |
| 306 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 307 | ), |
| 308 | VppMRoutePath( |
| 309 | self.pg1.sw_if_index, |
| 310 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 311 | nh=self.pg1.remote_ip4, |
| 312 | ), |
| 313 | VppMRoutePath( |
| 314 | self.pg2.sw_if_index, |
| 315 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 316 | nh=self.pg2.remote_ip4, |
| 317 | ), |
| 318 | ], |
| 319 | ) |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 320 | route_1_1_1_1_232_1_1_2.add_vpp_config() |
| 321 | |
| 322 | # |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 323 | # An (*,G/m). |
| 324 | # one accepting interface, pg0, 1 forwarding interfaces |
| 325 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 326 | route_232 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 327 | self, |
| 328 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 329 | "232.0.0.0", |
| 330 | 8, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 331 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 332 | [ |
| 333 | VppMRoutePath( |
| 334 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 335 | ), |
| 336 | VppMRoutePath( |
| 337 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 338 | ), |
| 339 | ], |
| 340 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 341 | route_232.add_vpp_config() |
| 342 | |
| 343 | # |
| 344 | # a stream that matches the route for (1.1.1.1,232.1.1.1) |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 345 | # small packets |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 346 | # |
| 347 | self.vapi.cli("clear trace") |
| 348 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1") |
| 349 | self.pg0.add_stream(tx) |
| 350 | |
| 351 | self.pg_enable_capture(self.pg_interfaces) |
| 352 | self.pg_start() |
| 353 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 354 | self.assertEqual(route_1_1_1_1_232_1_1_1.get_stats()["packets"], len(tx)) |
Neale Ranns | 28c142e | 2018-09-07 09:37:07 -0700 | [diff] [blame] | 355 | |
Neale Ranns | 37be736 | 2017-02-21 17:30:26 -0800 | [diff] [blame] | 356 | # We expect replications on Pg1->7 |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 357 | self.verify_capture_ip4(self.pg1, tx) |
| 358 | self.verify_capture_ip4(self.pg2, tx) |
| 359 | |
| 360 | # no replications on Pg0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 361 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 362 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 363 | |
| 364 | # |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 365 | # a stream that matches the route for (1.1.1.1,232.1.1.1) |
| 366 | # large packets |
| 367 | # |
| 368 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 369 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1", payload_size=1024) |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 370 | self.pg0.add_stream(tx) |
| 371 | |
| 372 | self.pg_enable_capture(self.pg_interfaces) |
| 373 | self.pg_start() |
| 374 | |
| 375 | # We expect replications on Pg1->7 |
| 376 | self.verify_capture_ip4(self.pg1, tx) |
| 377 | self.verify_capture_ip4(self.pg2, tx) |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 378 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 379 | self.assertEqual(route_1_1_1_1_232_1_1_1.get_stats()["packets"], 2 * len(tx)) |
Neale Ranns | 28c142e | 2018-09-07 09:37:07 -0700 | [diff] [blame] | 380 | |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 381 | # no replications on Pg0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 382 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 383 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | 9d676af | 2017-03-15 01:28:31 -0700 | [diff] [blame] | 384 | |
| 385 | # |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 386 | # a stream to the unicast next-hops |
| 387 | # |
| 388 | self.vapi.cli("clear trace") |
| 389 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.2") |
| 390 | self.pg0.add_stream(tx) |
| 391 | |
| 392 | self.pg_enable_capture(self.pg_interfaces) |
| 393 | self.pg_start() |
| 394 | |
| 395 | # We expect replications on Pg1->7 |
| 396 | self.verify_capture_ip4(self.pg1, tx, dst_mac=self.pg1.remote_mac) |
| 397 | self.verify_capture_ip4(self.pg2, tx, dst_mac=self.pg2.remote_mac) |
| 398 | |
| 399 | # no replications on Pg0 nor pg3 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 400 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 401 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 402 | |
| 403 | # |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 404 | # a stream that matches the route for (*,232.0.0.0/8) |
| 405 | # Send packets with the 9th bit set so we test the correct clearing |
| 406 | # of that bit in the mac rewrite |
| 407 | # |
| 408 | self.vapi.cli("clear trace") |
| 409 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.255.255.255") |
| 410 | self.pg0.add_stream(tx) |
| 411 | |
| 412 | self.pg_enable_capture(self.pg_interfaces) |
| 413 | self.pg_start() |
| 414 | |
| 415 | # We expect replications on Pg1 only |
| 416 | self.verify_capture_ip4(self.pg1, tx) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 417 | self.assertEqual(route_232.get_stats()["packets"], len(tx)) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 418 | |
| 419 | # no replications on Pg0, Pg2 not Pg3 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 420 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 421 | self.pg2.assert_nothing_captured(remark="IP multicast packets forwarded on PG2") |
| 422 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 423 | |
| 424 | # |
| 425 | # a stream that matches the route for (*,232.1.1.1) |
| 426 | # |
| 427 | self.vapi.cli("clear trace") |
| 428 | tx = self.create_stream_ip4(self.pg0, "1.1.1.2", "232.1.1.1") |
| 429 | self.pg0.add_stream(tx) |
| 430 | |
| 431 | self.pg_enable_capture(self.pg_interfaces) |
| 432 | self.pg_start() |
| 433 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 434 | # We expect replications on Pg1->7 |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 435 | self.verify_capture_ip4(self.pg1, tx) |
| 436 | self.verify_capture_ip4(self.pg2, tx) |
| 437 | self.verify_capture_ip4(self.pg3, tx) |
Neale Ranns | c2aad53 | 2017-05-30 09:53:52 -0700 | [diff] [blame] | 438 | self.verify_capture_ip4(self.pg4, tx) |
| 439 | self.verify_capture_ip4(self.pg5, tx) |
| 440 | self.verify_capture_ip4(self.pg6, tx) |
| 441 | self.verify_capture_ip4(self.pg7, tx) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 442 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 443 | # no replications on Pg0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 444 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 445 | |
Neale Ranns | 21fb4f7 | 2020-10-05 12:26:47 +0000 | [diff] [blame] | 446 | self.vapi.cli("packet mac-filter pg0 off") |
| 447 | self.vapi.cli("packet mac-filter pg1 off") |
| 448 | self.vapi.cli("packet mac-filter pg2 off") |
| 449 | self.vapi.cli("packet mac-filter pg4 off") |
| 450 | self.vapi.cli("packet mac-filter pg5 off") |
| 451 | self.vapi.cli("packet mac-filter pg6 off") |
| 452 | self.vapi.cli("packet mac-filter pg7 off") |
| 453 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 454 | def test_ip6_mcast(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 455 | """IPv6 Multicast Replication""" |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 456 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 457 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 458 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 459 | |
Neale Ranns | 21fb4f7 | 2020-10-05 12:26:47 +0000 | [diff] [blame] | 460 | self.vapi.cli("packet mac-filter pg0 on") |
| 461 | self.vapi.cli("packet mac-filter pg1 on") |
| 462 | self.vapi.cli("packet mac-filter pg2 on") |
| 463 | self.vapi.cli("packet mac-filter pg4 on") |
| 464 | self.vapi.cli("packet mac-filter pg5 on") |
| 465 | self.vapi.cli("packet mac-filter pg6 on") |
| 466 | self.vapi.cli("packet mac-filter pg7 on") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 467 | # |
| 468 | # a stream that matches the default route. gets dropped. |
| 469 | # |
| 470 | self.vapi.cli("clear trace") |
| 471 | tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1") |
| 472 | self.pg0.add_stream(tx) |
| 473 | |
| 474 | self.pg_enable_capture(self.pg_interfaces) |
| 475 | self.pg_start() |
| 476 | |
| 477 | self.pg0.assert_nothing_captured( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 478 | remark="IPv6 multicast packets forwarded on default route" |
| 479 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 480 | |
| 481 | # |
| 482 | # A (*,G). |
| 483 | # one accepting interface, pg0, 3 forwarding interfaces |
| 484 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 485 | route_ff01_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 486 | self, |
| 487 | "::", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 488 | "ff01::1", |
| 489 | 128, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 490 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 491 | [ |
| 492 | VppMRoutePath( |
| 493 | self.pg0.sw_if_index, |
| 494 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT, |
| 495 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 496 | ), |
| 497 | VppMRoutePath( |
| 498 | self.pg1.sw_if_index, |
| 499 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 500 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 501 | ), |
| 502 | VppMRoutePath( |
| 503 | self.pg2.sw_if_index, |
| 504 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 505 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 506 | ), |
| 507 | VppMRoutePath( |
| 508 | self.pg3.sw_if_index, |
| 509 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 510 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 511 | ), |
| 512 | ], |
| 513 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 514 | route_ff01_1.add_vpp_config() |
| 515 | |
| 516 | # |
| 517 | # An (S,G). |
| 518 | # one accepting interface, pg0, 2 forwarding interfaces |
| 519 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 520 | route_2001_ff01_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 521 | self, |
| 522 | "2001::1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 523 | "ff01::1", |
| 524 | 0, # any grp-len is ok when src is set |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 525 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 526 | [ |
| 527 | VppMRoutePath( |
| 528 | self.pg0.sw_if_index, |
| 529 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT, |
| 530 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 531 | ), |
| 532 | VppMRoutePath( |
| 533 | self.pg1.sw_if_index, |
| 534 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 535 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 536 | ), |
| 537 | VppMRoutePath( |
| 538 | self.pg2.sw_if_index, |
| 539 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 540 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 541 | ), |
| 542 | ], |
| 543 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 544 | route_2001_ff01_1.add_vpp_config() |
| 545 | |
| 546 | # |
| 547 | # An (*,G/m). |
| 548 | # one accepting interface, pg0, 1 forwarding interface |
| 549 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 550 | route_ff01 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 551 | self, |
| 552 | "::", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 553 | "ff01::", |
| 554 | 16, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 555 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 556 | [ |
| 557 | VppMRoutePath( |
| 558 | self.pg0.sw_if_index, |
| 559 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT, |
| 560 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 561 | ), |
| 562 | VppMRoutePath( |
| 563 | self.pg1.sw_if_index, |
| 564 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 565 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 566 | ), |
| 567 | ], |
| 568 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 569 | route_ff01.add_vpp_config() |
| 570 | |
| 571 | # |
| 572 | # a stream that matches the route for (*, ff01::/16) |
Neale Ranns | ce111d2 | 2018-01-23 08:38:50 -0800 | [diff] [blame] | 573 | # sent on the non-accepting interface |
| 574 | # |
| 575 | self.vapi.cli("clear trace") |
| 576 | tx = self.create_stream_ip6(self.pg1, "2002::1", "ff01:2::255") |
| 577 | self.send_and_assert_no_replies(self.pg1, tx, "RPF miss") |
Neale Ranns | e22a704 | 2022-08-09 03:03:29 +0000 | [diff] [blame] | 578 | count = self.statistics.get_err_counter("/err/ip6-input/rpf_failure") |
Neale Ranns | e8f57d5 | 2021-10-12 07:49:37 +0000 | [diff] [blame] | 579 | self.assertEqual(count, 2 * len(tx)) |
Neale Ranns | ce111d2 | 2018-01-23 08:38:50 -0800 | [diff] [blame] | 580 | |
| 581 | # |
| 582 | # a stream that matches the route for (*, ff01::/16) |
| 583 | # sent on the accepting interface |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 584 | # |
| 585 | self.vapi.cli("clear trace") |
| 586 | tx = self.create_stream_ip6(self.pg0, "2002::1", "ff01:2::255") |
| 587 | self.pg0.add_stream(tx) |
| 588 | |
| 589 | self.pg_enable_capture(self.pg_interfaces) |
| 590 | self.pg_start() |
| 591 | |
| 592 | # We expect replications on Pg1 |
| 593 | self.verify_capture_ip6(self.pg1, tx) |
| 594 | |
| 595 | # no replications on Pg0, Pg3 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 596 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 597 | self.pg2.assert_nothing_captured(remark="IP multicast packets forwarded on PG2") |
| 598 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 599 | |
| 600 | # |
Neale Ranns | c2aad53 | 2017-05-30 09:53:52 -0700 | [diff] [blame] | 601 | # Bounce the interface and it should still work |
| 602 | # |
| 603 | self.pg1.admin_down() |
| 604 | self.pg0.add_stream(tx) |
| 605 | self.pg_enable_capture(self.pg_interfaces) |
| 606 | self.pg_start() |
| 607 | self.pg1.assert_nothing_captured( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 608 | remark="IP multicast packets forwarded on down PG1" |
| 609 | ) |
Neale Ranns | c2aad53 | 2017-05-30 09:53:52 -0700 | [diff] [blame] | 610 | |
| 611 | self.pg1.admin_up() |
| 612 | self.pg0.add_stream(tx) |
| 613 | self.pg_enable_capture(self.pg_interfaces) |
| 614 | self.pg_start() |
| 615 | self.verify_capture_ip6(self.pg1, tx) |
| 616 | |
| 617 | # |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 618 | # a stream that matches the route for (*,ff01::1) |
| 619 | # |
| 620 | self.vapi.cli("clear trace") |
| 621 | tx = self.create_stream_ip6(self.pg0, "2002::2", "ff01::1") |
| 622 | self.pg0.add_stream(tx) |
| 623 | |
| 624 | self.pg_enable_capture(self.pg_interfaces) |
| 625 | self.pg_start() |
| 626 | |
| 627 | # We expect replications on Pg1, 2, 3. |
| 628 | self.verify_capture_ip6(self.pg1, tx) |
| 629 | self.verify_capture_ip6(self.pg2, tx) |
| 630 | self.verify_capture_ip6(self.pg3, tx) |
| 631 | |
| 632 | # no replications on Pg0 |
| 633 | self.pg0.assert_nothing_captured( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 634 | remark="IPv6 multicast packets forwarded on PG0" |
| 635 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 636 | |
| 637 | # |
| 638 | # a stream that matches the route for (2001::1, ff00::1) |
| 639 | # |
| 640 | self.vapi.cli("clear trace") |
| 641 | tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1") |
| 642 | self.pg0.add_stream(tx) |
| 643 | |
| 644 | self.pg_enable_capture(self.pg_interfaces) |
| 645 | self.pg_start() |
| 646 | |
| 647 | # We expect replications on Pg1, 2, |
| 648 | self.verify_capture_ip6(self.pg1, tx) |
| 649 | self.verify_capture_ip6(self.pg2, tx) |
| 650 | |
| 651 | # no replications on Pg0, Pg3 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 652 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
| 653 | self.pg3.assert_nothing_captured(remark="IP multicast packets forwarded on PG3") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 654 | |
Neale Ranns | 21fb4f7 | 2020-10-05 12:26:47 +0000 | [diff] [blame] | 655 | self.vapi.cli("packet mac-filter pg0 off") |
| 656 | self.vapi.cli("packet mac-filter pg1 off") |
| 657 | self.vapi.cli("packet mac-filter pg2 off") |
| 658 | self.vapi.cli("packet mac-filter pg4 off") |
| 659 | self.vapi.cli("packet mac-filter pg5 off") |
| 660 | self.vapi.cli("packet mac-filter pg6 off") |
| 661 | self.vapi.cli("packet mac-filter pg7 off") |
| 662 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 663 | def _mcast_connected_send_stream(self, dst_ip): |
| 664 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 665 | tx = self.create_stream_ip4(self.pg0, self.pg0.remote_ip4, dst_ip) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 666 | self.pg0.add_stream(tx) |
| 667 | |
| 668 | self.pg_enable_capture(self.pg_interfaces) |
| 669 | self.pg_start() |
| 670 | |
| 671 | # We expect replications on Pg1. |
| 672 | self.verify_capture_ip4(self.pg1, tx) |
| 673 | |
| 674 | return tx |
| 675 | |
| 676 | def test_ip_mcast_connected(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 677 | """IP Multicast Connected Source check""" |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 678 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 679 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 680 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 681 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 682 | # |
| 683 | # A (*,G). |
| 684 | # one accepting interface, pg0, 1 forwarding interfaces |
| 685 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 686 | route_232_1_1_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 687 | self, |
| 688 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 689 | "232.1.1.1", |
| 690 | 32, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 691 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 692 | [ |
| 693 | VppMRoutePath( |
| 694 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 695 | ), |
| 696 | VppMRoutePath( |
| 697 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 698 | ), |
| 699 | ], |
| 700 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 701 | |
| 702 | route_232_1_1_1.add_vpp_config() |
| 703 | route_232_1_1_1.update_entry_flags( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 704 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_CONNECTED |
| 705 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 706 | |
| 707 | # |
| 708 | # Now the (*,G) is present, send from connected source |
| 709 | # |
| 710 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 711 | |
| 712 | # |
| 713 | # Constrct a representation of the signal we expect on pg0 |
| 714 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 715 | signal_232_1_1_1_itf_0 = VppMFibSignal( |
| 716 | self, route_232_1_1_1, self.pg0.sw_if_index, tx[0] |
| 717 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 718 | |
| 719 | # |
| 720 | # read the only expected signal |
| 721 | # |
| 722 | signals = self.vapi.mfib_signal_dump() |
| 723 | |
| 724 | self.assertEqual(1, len(signals)) |
| 725 | |
| 726 | signal_232_1_1_1_itf_0.compare(signals[0]) |
| 727 | |
| 728 | # |
| 729 | # reading the signal allows for the generation of another |
| 730 | # so send more packets and expect the next signal |
| 731 | # |
| 732 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 733 | |
| 734 | signals = self.vapi.mfib_signal_dump() |
| 735 | self.assertEqual(1, len(signals)) |
| 736 | signal_232_1_1_1_itf_0.compare(signals[0]) |
| 737 | |
| 738 | # |
| 739 | # A Second entry with connected check |
| 740 | # one accepting interface, pg0, 1 forwarding interfaces |
| 741 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 742 | route_232_1_1_2 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 743 | self, |
| 744 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 745 | "232.1.1.2", |
| 746 | 32, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 747 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 748 | [ |
| 749 | VppMRoutePath( |
| 750 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 751 | ), |
| 752 | VppMRoutePath( |
| 753 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 754 | ), |
| 755 | ], |
| 756 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 757 | |
| 758 | route_232_1_1_2.add_vpp_config() |
| 759 | route_232_1_1_2.update_entry_flags( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 760 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_CONNECTED |
| 761 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 762 | |
| 763 | # |
| 764 | # Send traffic to both entries. One read should net us two signals |
| 765 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 766 | signal_232_1_1_2_itf_0 = VppMFibSignal( |
| 767 | self, route_232_1_1_2, self.pg0.sw_if_index, tx[0] |
| 768 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 769 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 770 | tx2 = self._mcast_connected_send_stream("232.1.1.2") |
| 771 | |
| 772 | # |
| 773 | # read the only expected signal |
| 774 | # |
| 775 | signals = self.vapi.mfib_signal_dump() |
| 776 | |
| 777 | self.assertEqual(2, len(signals)) |
| 778 | |
| 779 | signal_232_1_1_1_itf_0.compare(signals[1]) |
| 780 | signal_232_1_1_2_itf_0.compare(signals[0]) |
| 781 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 782 | route_232_1_1_1.update_entry_flags(MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE) |
| 783 | route_232_1_1_2.update_entry_flags(MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 784 | |
| 785 | def test_ip_mcast_signal(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 786 | """IP Multicast Signal""" |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 787 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 788 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 789 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 790 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 791 | # |
| 792 | # A (*,G). |
| 793 | # one accepting interface, pg0, 1 forwarding interfaces |
| 794 | # |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 795 | route_232_1_1_1 = VppIpMRoute( |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 796 | self, |
| 797 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 798 | "232.1.1.1", |
| 799 | 32, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 800 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 801 | [ |
| 802 | VppMRoutePath( |
| 803 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 804 | ), |
| 805 | VppMRoutePath( |
| 806 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 807 | ), |
| 808 | ], |
| 809 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 810 | |
| 811 | route_232_1_1_1.add_vpp_config() |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 812 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 813 | route_232_1_1_1.update_entry_flags(MRouteEntryFlags.MFIB_API_ENTRY_FLAG_SIGNAL) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 814 | |
| 815 | # |
| 816 | # Now the (*,G) is present, send from connected source |
| 817 | # |
| 818 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 819 | |
| 820 | # |
| 821 | # Constrct a representation of the signal we expect on pg0 |
| 822 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 823 | signal_232_1_1_1_itf_0 = VppMFibSignal( |
| 824 | self, route_232_1_1_1, self.pg0.sw_if_index, tx[0] |
| 825 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 826 | |
| 827 | # |
| 828 | # read the only expected signal |
| 829 | # |
| 830 | signals = self.vapi.mfib_signal_dump() |
| 831 | |
| 832 | self.assertEqual(1, len(signals)) |
| 833 | |
| 834 | signal_232_1_1_1_itf_0.compare(signals[0]) |
| 835 | |
| 836 | # |
| 837 | # reading the signal allows for the generation of another |
| 838 | # so send more packets and expect the next signal |
| 839 | # |
| 840 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 841 | |
| 842 | signals = self.vapi.mfib_signal_dump() |
| 843 | self.assertEqual(1, len(signals)) |
| 844 | signal_232_1_1_1_itf_0.compare(signals[0]) |
| 845 | |
| 846 | # |
| 847 | # Set the negate-signal on the accepting interval - the signals |
| 848 | # should stop |
| 849 | # |
| 850 | route_232_1_1_1.update_path_flags( |
| 851 | self.pg0.sw_if_index, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 852 | ( |
| 853 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 854 | | MRouteItfFlags.MFIB_API_ITF_FLAG_NEGATE_SIGNAL |
| 855 | ), |
| 856 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 857 | |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 858 | self.vapi.cli("clear trace") |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 859 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 860 | |
| 861 | signals = self.vapi.mfib_signal_dump() |
| 862 | self.assertEqual(0, len(signals)) |
| 863 | |
| 864 | # |
| 865 | # Clear the SIGNAL flag on the entry and the signals should |
| 866 | # come back since the interface is still NEGATE-SIGNAL |
| 867 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 868 | route_232_1_1_1.update_entry_flags(MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 869 | |
| 870 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 871 | |
| 872 | signals = self.vapi.mfib_signal_dump() |
| 873 | self.assertEqual(1, len(signals)) |
| 874 | signal_232_1_1_1_itf_0.compare(signals[0]) |
| 875 | |
| 876 | # |
| 877 | # Lastly remove the NEGATE-SIGNAL from the interface and the |
| 878 | # signals should stop |
| 879 | # |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 880 | route_232_1_1_1.update_path_flags( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 881 | self.pg0.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 882 | ) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 883 | |
| 884 | tx = self._mcast_connected_send_stream("232.1.1.1") |
| 885 | signals = self.vapi.mfib_signal_dump() |
| 886 | self.assertEqual(0, len(signals)) |
| 887 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 888 | @unittest.skipIf( |
| 889 | "ping" in config.excluded_plugins, "Exclude tests requiring Ping plugin" |
| 890 | ) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 891 | def test_ip_mcast_vrf(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 892 | """IP Multicast Replication in non-default table""" |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 893 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 894 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 895 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 896 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 897 | # |
| 898 | # An (S,G). |
| 899 | # one accepting interface, pg0, 2 forwarding interfaces |
| 900 | # |
| 901 | route_1_1_1_1_232_1_1_1 = VppIpMRoute( |
| 902 | self, |
| 903 | "1.1.1.1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 904 | "232.1.1.1", |
| 905 | 64, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 906 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 907 | [ |
| 908 | VppMRoutePath( |
| 909 | self.pg8.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 910 | ), |
| 911 | VppMRoutePath( |
| 912 | self.pg1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 913 | ), |
| 914 | VppMRoutePath( |
| 915 | self.pg2.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 916 | ), |
| 917 | ], |
| 918 | table_id=10, |
| 919 | ) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 920 | route_1_1_1_1_232_1_1_1.add_vpp_config() |
| 921 | |
| 922 | # |
| 923 | # a stream that matches the route for (1.1.1.1,232.1.1.1) |
| 924 | # small packets |
| 925 | # |
| 926 | self.vapi.cli("clear trace") |
| 927 | tx = self.create_stream_ip4(self.pg8, "1.1.1.1", "232.1.1.1") |
| 928 | self.pg8.add_stream(tx) |
| 929 | |
| 930 | self.pg_enable_capture(self.pg_interfaces) |
| 931 | self.pg_start() |
| 932 | |
| 933 | # We expect replications on Pg1 & 2 |
| 934 | self.verify_capture_ip4(self.pg1, tx) |
| 935 | self.verify_capture_ip4(self.pg2, tx) |
| 936 | |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 937 | # |
| 938 | # An (S,G). for for-us |
| 939 | # |
| 940 | route_0_0_0_0_224_0_0_5 = VppIpMRoute( |
| 941 | self, |
| 942 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 943 | "224.0.0.5", |
| 944 | 32, |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 945 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 946 | [ |
| 947 | VppMRoutePath( |
| 948 | self.pg8.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 949 | ), |
| 950 | VppMRoutePath( |
| 951 | 0xFFFFFFFF, |
| 952 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 953 | type=FibPathType.FIB_PATH_TYPE_LOCAL, |
| 954 | ), |
| 955 | ], |
| 956 | table_id=10, |
| 957 | ) |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 958 | route_0_0_0_0_224_0_0_5.add_vpp_config() |
| 959 | |
| 960 | # |
| 961 | # a stream that matches the route for (0.0.0.0, 224.0.0.5) |
| 962 | # small packets |
| 963 | # |
| 964 | self.vapi.cli("clear trace") |
| 965 | self.pg8.resolve_arp() |
| 966 | |
| 967 | # |
| 968 | # send a ping to mcast address from peer on pg8 |
| 969 | # expect a response |
| 970 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 971 | icmp_id = 0xB |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 972 | icmp_seq = 5 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 973 | icmp_load = b"\x0a" * 18 |
| 974 | tx = ( |
| 975 | Ether(dst=getmacbyip("224.0.0.5"), src=self.pg8.remote_mac) |
| 976 | / IP(src=self.pg8.remote_ip4, dst="224.0.0.5") |
| 977 | / ICMP(id=icmp_id, seq=icmp_seq) |
| 978 | / Raw(load=icmp_load) |
| 979 | ) * 2 |
Neale Ranns | 1372178 | 2021-05-13 15:28:27 +0000 | [diff] [blame] | 980 | |
| 981 | self.send_and_expect(self.pg8, tx, self.pg8) |
| 982 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 983 | @unittest.skipIf( |
| 984 | "gre" in config.excluded_plugins, "Exclude tests requiring GRE plugin" |
| 985 | ) |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 986 | def test_ip_mcast_gre(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 987 | """IP Multicast Replication over GRE""" |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 988 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 989 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 990 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 991 | |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 992 | gre_if_1 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 993 | self, self.pg1.local_ip4, self.pg1.remote_ip4 |
| 994 | ).add_vpp_config() |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 995 | gre_if_2 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 996 | self, self.pg2.local_ip4, self.pg2.remote_ip4 |
| 997 | ).add_vpp_config() |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 998 | gre_if_3 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 999 | self, self.pg3.local_ip4, self.pg3.remote_ip4 |
| 1000 | ).add_vpp_config() |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 1001 | |
| 1002 | gre_if_1.admin_up() |
| 1003 | gre_if_1.config_ip4() |
| 1004 | gre_if_2.admin_up() |
| 1005 | gre_if_2.config_ip4() |
| 1006 | gre_if_3.admin_up() |
| 1007 | gre_if_3.config_ip4() |
| 1008 | |
| 1009 | # |
| 1010 | # An (S,G). |
| 1011 | # one accepting interface, pg0, 2 forwarding interfaces |
| 1012 | # |
| 1013 | route_1_1_1_1_232_1_1_1 = VppIpMRoute( |
| 1014 | self, |
| 1015 | "1.1.1.1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1016 | "232.2.2.2", |
| 1017 | 64, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 1018 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1019 | [ |
| 1020 | VppMRoutePath( |
| 1021 | gre_if_1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1022 | ), |
| 1023 | VppMRoutePath( |
| 1024 | gre_if_2.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 1025 | ), |
| 1026 | VppMRoutePath( |
| 1027 | gre_if_3.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 1028 | ), |
| 1029 | ], |
| 1030 | ) |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 1031 | route_1_1_1_1_232_1_1_1.add_vpp_config() |
| 1032 | |
| 1033 | # |
| 1034 | # a stream that matches the route for (1.1.1.1,232.2.2.2) |
| 1035 | # small packets |
| 1036 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1037 | tx = ( |
| 1038 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 1039 | / IP(src=self.pg1.remote_ip4, dst=self.pg1.local_ip4) |
| 1040 | / GRE() |
| 1041 | / IP(src="1.1.1.1", dst="232.2.2.2") |
| 1042 | / UDP(sport=1234, dport=1234) |
| 1043 | / Raw(b"\a5" * 64) |
| 1044 | ) * 63 |
Neale Ranns | adb17a8 | 2019-08-04 02:41:57 -0700 | [diff] [blame] | 1045 | |
| 1046 | self.vapi.cli("clear trace") |
| 1047 | self.pg1.add_stream(tx) |
| 1048 | |
| 1049 | self.pg_enable_capture(self.pg_interfaces) |
| 1050 | self.pg_start() |
| 1051 | |
| 1052 | # We expect replications on Pg2 & 3 |
| 1053 | # check the encap headers are as expected based on the egress tunnel |
| 1054 | rxs = self.pg2.get_capture(len(tx)) |
| 1055 | for rx in rxs: |
| 1056 | self.assertEqual(rx[IP].src, gre_if_2.t_src) |
| 1057 | self.assertEqual(rx[IP].dst, gre_if_2.t_dst) |
| 1058 | self.assert_packet_checksums_valid(rx) |
| 1059 | |
| 1060 | rxs = self.pg3.get_capture(len(tx)) |
| 1061 | for rx in rxs: |
| 1062 | self.assertEqual(rx[IP].src, gre_if_3.t_src) |
| 1063 | self.assertEqual(rx[IP].dst, gre_if_3.t_dst) |
| 1064 | self.assert_packet_checksums_valid(rx) |
| 1065 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 1066 | @unittest.skipIf( |
| 1067 | "gre" in config.excluded_plugins, "Exclude tests requiring GRE plugin" |
| 1068 | ) |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1069 | def test_ip6_mcast_gre(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1070 | """IP6 Multicast Replication over GRE""" |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1071 | |
| 1072 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 1073 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 1074 | |
| 1075 | gre_if_1 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1076 | self, self.pg1.local_ip4, self.pg1.remote_ip4 |
| 1077 | ).add_vpp_config() |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1078 | gre_if_2 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1079 | self, self.pg2.local_ip4, self.pg2.remote_ip4 |
| 1080 | ).add_vpp_config() |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1081 | gre_if_3 = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1082 | self, self.pg3.local_ip4, self.pg3.remote_ip4 |
| 1083 | ).add_vpp_config() |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1084 | |
| 1085 | gre_if_1.admin_up() |
| 1086 | gre_if_1.config_ip6() |
| 1087 | gre_if_2.admin_up() |
| 1088 | gre_if_2.config_ip6() |
| 1089 | gre_if_3.admin_up() |
| 1090 | gre_if_3.config_ip6() |
| 1091 | |
| 1092 | # |
| 1093 | # An (S,G). |
| 1094 | # one accepting interface, pg0, 2 forwarding interfaces |
| 1095 | # |
| 1096 | route_1_1_FF_1 = VppIpMRoute( |
| 1097 | self, |
| 1098 | "1::1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1099 | "FF00::1", |
| 1100 | 256, |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1101 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1102 | [ |
| 1103 | VppMRoutePath( |
| 1104 | gre_if_1.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1105 | ), |
| 1106 | VppMRoutePath( |
| 1107 | gre_if_2.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 1108 | ), |
| 1109 | VppMRoutePath( |
| 1110 | gre_if_3.sw_if_index, MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD |
| 1111 | ), |
| 1112 | ], |
| 1113 | ) |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1114 | route_1_1_FF_1.add_vpp_config() |
| 1115 | |
| 1116 | # |
| 1117 | # a stream that matches the route for (1::1, FF::1) |
| 1118 | # small packets |
| 1119 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1120 | tx = ( |
| 1121 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 1122 | / IP(src=self.pg1.remote_ip4, dst=self.pg1.local_ip4) |
| 1123 | / GRE() |
| 1124 | / IPv6(src="1::1", dst="FF00::1") |
| 1125 | / UDP(sport=1234, dport=1234) |
| 1126 | / Raw(b"\a5" * 64) |
| 1127 | ) * 63 |
Neale Ranns | 7d8a956 | 2020-11-20 14:32:56 +0000 | [diff] [blame] | 1128 | |
| 1129 | self.vapi.cli("clear trace") |
| 1130 | self.pg1.add_stream(tx) |
| 1131 | |
| 1132 | self.pg_enable_capture(self.pg_interfaces) |
| 1133 | self.pg_start() |
| 1134 | |
| 1135 | # We expect replications on Pg2 & 3 |
| 1136 | # check the encap headers are as expected based on the egress tunnel |
| 1137 | rxs = self.pg2.get_capture(len(tx)) |
| 1138 | for rx in rxs: |
| 1139 | self.assertEqual(rx[IP].src, gre_if_2.t_src) |
| 1140 | self.assertEqual(rx[IP].dst, gre_if_2.t_dst) |
| 1141 | self.assert_packet_checksums_valid(rx) |
| 1142 | |
| 1143 | rxs = self.pg3.get_capture(len(tx)) |
| 1144 | for rx in rxs: |
| 1145 | self.assertEqual(rx[IP].src, gre_if_3.t_src) |
| 1146 | self.assertEqual(rx[IP].dst, gre_if_3.t_dst) |
| 1147 | self.assert_packet_checksums_valid(rx) |
| 1148 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1149 | def test_ip6_mcast_vrf(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1150 | """IPv6 Multicast Replication in non-default table""" |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1151 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 1152 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 1153 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 1154 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1155 | # |
| 1156 | # An (S,G). |
| 1157 | # one accepting interface, pg0, 2 forwarding interfaces |
| 1158 | # |
| 1159 | route_2001_ff01_1 = VppIpMRoute( |
| 1160 | self, |
| 1161 | "2001::1", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1162 | "ff01::1", |
| 1163 | 256, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 1164 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1165 | [ |
| 1166 | VppMRoutePath( |
| 1167 | self.pg8.sw_if_index, |
| 1168 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT, |
| 1169 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 1170 | ), |
| 1171 | VppMRoutePath( |
| 1172 | self.pg1.sw_if_index, |
| 1173 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1174 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 1175 | ), |
| 1176 | VppMRoutePath( |
| 1177 | self.pg2.sw_if_index, |
| 1178 | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1179 | proto=FibPathProto.FIB_PATH_NH_PROTO_IP6, |
| 1180 | ), |
| 1181 | ], |
| 1182 | table_id=10, |
| 1183 | ) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1184 | route_2001_ff01_1.add_vpp_config() |
| 1185 | |
| 1186 | # |
| 1187 | # a stream that matches the route for (2001::1, ff00::1) |
| 1188 | # |
| 1189 | self.vapi.cli("clear trace") |
| 1190 | tx = self.create_stream_ip6(self.pg8, "2001::1", "ff01::1") |
| 1191 | self.pg8.add_stream(tx) |
| 1192 | |
| 1193 | self.pg_enable_capture(self.pg_interfaces) |
| 1194 | self.pg_start() |
| 1195 | |
| 1196 | # We expect replications on Pg1, 2, |
| 1197 | self.verify_capture_ip6(self.pg1, tx) |
| 1198 | self.verify_capture_ip6(self.pg2, tx) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 1199 | |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 1200 | def test_bidir(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1201 | """IP Multicast Bi-directional""" |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 1202 | |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 1203 | MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t |
| 1204 | MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t |
| 1205 | |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 1206 | # |
| 1207 | # A (*,G). The set of accepting interfaces matching the forwarding |
| 1208 | # |
| 1209 | route_232_1_1_1 = VppIpMRoute( |
| 1210 | self, |
| 1211 | "0.0.0.0", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1212 | "232.1.1.1", |
| 1213 | 32, |
Neale Ranns | 990f694 | 2020-10-20 07:20:17 +0000 | [diff] [blame] | 1214 | MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1215 | [ |
| 1216 | VppMRoutePath( |
| 1217 | self.pg0.sw_if_index, |
| 1218 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1219 | | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1220 | ), |
| 1221 | VppMRoutePath( |
| 1222 | self.pg1.sw_if_index, |
| 1223 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1224 | | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1225 | ), |
| 1226 | VppMRoutePath( |
| 1227 | self.pg2.sw_if_index, |
| 1228 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1229 | | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1230 | ), |
| 1231 | VppMRoutePath( |
| 1232 | self.pg3.sw_if_index, |
| 1233 | MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT |
| 1234 | | MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD, |
| 1235 | ), |
| 1236 | ], |
| 1237 | ) |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 1238 | route_232_1_1_1.add_vpp_config() |
| 1239 | |
| 1240 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1") |
| 1241 | self.pg0.add_stream(tx) |
| 1242 | |
| 1243 | self.pg_enable_capture(self.pg_interfaces) |
| 1244 | self.pg_start() |
| 1245 | |
| 1246 | # We expect replications on Pg1, 2, 3, but not on pg0 |
| 1247 | self.verify_capture_ip4(self.pg1, tx) |
| 1248 | self.verify_capture_ip4(self.pg2, tx) |
| 1249 | self.verify_capture_ip4(self.pg3, tx) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1250 | self.pg0.assert_nothing_captured(remark="IP multicast packets forwarded on PG0") |
Neale Ranns | cf3561b | 2017-12-13 01:44:25 -0800 | [diff] [blame] | 1251 | |
| 1252 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1253 | if __name__ == "__main__": |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 1254 | unittest.main(testRunner=VppTestRunner) |