blob: 64d37060d438e8a3f41054fa4e82ee11083800d0 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Neale Ranns32e1c012016-11-22 17:07:28 +00002
3import unittest
4
5from framework import VppTestCase, VppTestRunner
Neale Rannsc0a93142018-09-05 15:42:26 -07006from vpp_ip import DpoProto
Neale Ranns180279b2017-03-16 15:49:09 -04007from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal, \
Neale Ranns097fa662018-05-01 05:17:55 -07008 MRouteItfFlags, MRouteEntryFlags, VppIpTable, FibPathProto
Neale Rannsadb17a82019-08-04 02:41:57 -07009from vpp_gre_interface import VppGreInterface
Neale Ranns32e1c012016-11-22 17:07:28 +000010
11from scapy.packet import Raw
Neale Rannsadb17a82019-08-04 02:41:57 -070012from scapy.layers.l2 import Ether, GRE
Klement Sekerab9ef2732018-06-24 22:49:33 +020013from scapy.layers.inet import IP, UDP, getmacbyip
Neale Ranns32e1c012016-11-22 17:07:28 +000014from scapy.layers.inet6 import IPv6, getmacbyip6
Neale Ranns32e1c012016-11-22 17:07:28 +000015
Neale Ranns9bea8fb2017-02-03 04:34:01 -080016#
Neale Rannscf3561b2017-12-13 01:44:25 -080017# The number of packets sent is set to 91 so that when we replicate more than 3
Neale Ranns9bea8fb2017-02-03 04:34:01 -080018# times, which we do for some entries, we will generate more than 256 packets
Neale Rannsaaa396a2017-02-05 09:12:02 -080019# to the next node in the VLIB graph. Thus we are testing the code's
Neale Rannscf3561b2017-12-13 01:44:25 -080020# correctness handling this over-flow.
21# It's also an odd number so we hit any single loops.
Neale Ranns9bea8fb2017-02-03 04:34:01 -080022#
Neale Rannscf3561b2017-12-13 01:44:25 -080023N_PKTS_IN_STREAM = 91
Neale Ranns9bea8fb2017-02-03 04:34:01 -080024
Neale Ranns32e1c012016-11-22 17:07:28 +000025
Neale Ranns5a8123b2017-01-26 01:18:23 -080026class TestMFIB(VppTestCase):
27 """ MFIB Test Case """
28
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070029 @classmethod
30 def setUpClass(cls):
31 super(TestMFIB, cls).setUpClass()
32
33 @classmethod
34 def tearDownClass(cls):
35 super(TestMFIB, cls).tearDownClass()
36
Neale Ranns5a8123b2017-01-26 01:18:23 -080037 def setUp(self):
38 super(TestMFIB, self).setUp()
39
40 def test_mfib(self):
41 """ MFIB Unit Tests """
42 error = self.vapi.cli("test mfib")
43
44 if error:
45 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080046 self.assertNotIn("Failed", error)
Neale Ranns5a8123b2017-01-26 01:18:23 -080047
48
Neale Ranns32e1c012016-11-22 17:07:28 +000049class TestIPMcast(VppTestCase):
50 """ IP Multicast Test Case """
51
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070052 @classmethod
53 def setUpClass(cls):
54 super(TestIPMcast, cls).setUpClass()
55
56 @classmethod
57 def tearDownClass(cls):
58 super(TestIPMcast, cls).tearDownClass()
59
Neale Ranns32e1c012016-11-22 17:07:28 +000060 def setUp(self):
61 super(TestIPMcast, self).setUp()
62
Neale Ranns37be7362017-02-21 17:30:26 -080063 # create 8 pg interfaces
Neale Ranns15002542017-09-10 04:39:11 -070064 self.create_pg_interfaces(range(9))
Neale Ranns32e1c012016-11-22 17:07:28 +000065
66 # setup interfaces
Neale Ranns15002542017-09-10 04:39:11 -070067 for i in self.pg_interfaces[:8]:
Neale Ranns32e1c012016-11-22 17:07:28 +000068 i.admin_up()
69 i.config_ip4()
70 i.config_ip6()
71 i.resolve_arp()
72 i.resolve_ndp()
73
Neale Ranns15002542017-09-10 04:39:11 -070074 # one more in a vrf
75 tbl4 = VppIpTable(self, 10)
76 tbl4.add_vpp_config()
77 self.pg8.set_table_ip4(10)
78 self.pg8.config_ip4()
79
80 tbl6 = VppIpTable(self, 10, is_ip6=1)
81 tbl6.add_vpp_config()
82 self.pg8.set_table_ip6(10)
83 self.pg8.config_ip6()
84
85 def tearDown(self):
86 for i in self.pg_interfaces:
87 i.unconfig_ip4()
88 i.unconfig_ip6()
89 i.admin_down()
90
91 self.pg8.set_table_ip4(0)
92 self.pg8.set_table_ip6(0)
93 super(TestIPMcast, self).tearDown()
94
Neale Ranns9d676af2017-03-15 01:28:31 -070095 def create_stream_ip4(self, src_if, src_ip, dst_ip, payload_size=0):
Neale Ranns32e1c012016-11-22 17:07:28 +000096 pkts = []
Neale Ranns9d676af2017-03-15 01:28:31 -070097 # default to small packet sizes
Neale Ranns21fb4f72020-10-05 12:26:47 +000098 p = (Ether(dst=getmacbyip(dst_ip), src=src_if.remote_mac) /
Neale Ranns9d676af2017-03-15 01:28:31 -070099 IP(src=src_ip, dst=dst_ip) /
100 UDP(sport=1234, dport=1234))
101 if not payload_size:
102 payload_size = 64 - len(p)
Ole Troan770a0de2019-11-07 13:52:21 +0100103 p = p / Raw(b'\xa5' * payload_size)
Neale Ranns9d676af2017-03-15 01:28:31 -0700104
Neale Ranns9bea8fb2017-02-03 04:34:01 -0800105 for i in range(0, N_PKTS_IN_STREAM):
Neale Ranns32e1c012016-11-22 17:07:28 +0000106 pkts.append(p)
107 return pkts
108
109 def create_stream_ip6(self, src_if, src_ip, dst_ip):
110 pkts = []
Neale Ranns9bea8fb2017-02-03 04:34:01 -0800111 for i in range(0, N_PKTS_IN_STREAM):
Neale Ranns32e1c012016-11-22 17:07:28 +0000112 info = self.create_packet_info(src_if, src_if)
113 payload = self.info_to_payload(info)
Neale Ranns21fb4f72020-10-05 12:26:47 +0000114 p = (Ether(dst=getmacbyip6(dst_ip), src=src_if.remote_mac) /
Neale Ranns32e1c012016-11-22 17:07:28 +0000115 IPv6(src=src_ip, dst=dst_ip) /
116 UDP(sport=1234, dport=1234) /
117 Raw(payload))
118 info.data = p.copy()
119 pkts.append(p)
120 return pkts
121
122 def verify_filter(self, capture, sent):
123 if not len(capture) == len(sent):
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700124 # filter out any IPv6 RAs from the capture
Neale Ranns32e1c012016-11-22 17:07:28 +0000125 for p in capture:
126 if (p.haslayer(IPv6)):
127 capture.remove(p)
128 return capture
129
Neale Rannse821ab12017-06-01 07:45:05 -0700130 def verify_capture_ip4(self, rx_if, sent, dst_mac=None):
Neale Rannsc2aad532017-05-30 09:53:52 -0700131 rxd = rx_if.get_capture(len(sent))
Neale Ranns32e1c012016-11-22 17:07:28 +0000132
133 try:
134 capture = self.verify_filter(rxd, sent)
135
136 self.assertEqual(len(capture), len(sent))
137
138 for i in range(len(capture)):
139 tx = sent[i]
140 rx = capture[i]
141
Neale Ranns32e1c012016-11-22 17:07:28 +0000142 eth = rx[Ether]
143 self.assertEqual(eth.type, 0x800)
144
145 tx_ip = tx[IP]
146 rx_ip = rx[IP]
147
Neale Rannse821ab12017-06-01 07:45:05 -0700148 if dst_mac is None:
149 dst_mac = getmacbyip(rx_ip.dst)
150
Neale Ranns32e1c012016-11-22 17:07:28 +0000151 # check the MAC address on the RX'd packet is correctly formed
Neale Rannse821ab12017-06-01 07:45:05 -0700152 self.assertEqual(eth.dst, dst_mac)
Neale Ranns32e1c012016-11-22 17:07:28 +0000153
154 self.assertEqual(rx_ip.src, tx_ip.src)
155 self.assertEqual(rx_ip.dst, tx_ip.dst)
156 # IP processing post pop has decremented the TTL
157 self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
158
159 except:
160 raise
161
Neale Rannsc2aad532017-05-30 09:53:52 -0700162 def verify_capture_ip6(self, rx_if, sent):
163 capture = rx_if.get_capture(len(sent))
Neale Ranns32e1c012016-11-22 17:07:28 +0000164
165 self.assertEqual(len(capture), len(sent))
166
167 for i in range(len(capture)):
168 tx = sent[i]
169 rx = capture[i]
170
Neale Ranns32e1c012016-11-22 17:07:28 +0000171 eth = rx[Ether]
172 self.assertEqual(eth.type, 0x86DD)
173
174 tx_ip = tx[IPv6]
175 rx_ip = rx[IPv6]
176
177 # check the MAC address on the RX'd packet is correctly formed
178 self.assertEqual(eth.dst, getmacbyip6(rx_ip.dst))
179
180 self.assertEqual(rx_ip.src, tx_ip.src)
181 self.assertEqual(rx_ip.dst, tx_ip.dst)
182 # IP processing post pop has decremented the TTL
183 self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim)
184
185 def test_ip_mcast(self):
186 """ IP Multicast Replication """
187
188 #
189 # a stream that matches the default route. gets dropped.
190 #
191 self.vapi.cli("clear trace")
Neale Ranns21fb4f72020-10-05 12:26:47 +0000192 self.vapi.cli("packet mac-filter pg0 on")
193 self.vapi.cli("packet mac-filter pg1 on")
194 self.vapi.cli("packet mac-filter pg2 on")
195 self.vapi.cli("packet mac-filter pg4 on")
196 self.vapi.cli("packet mac-filter pg5 on")
197 self.vapi.cli("packet mac-filter pg6 on")
198 self.vapi.cli("packet mac-filter pg7 on")
199
Neale Ranns32e1c012016-11-22 17:07:28 +0000200 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
201 self.pg0.add_stream(tx)
202
203 self.pg_enable_capture(self.pg_interfaces)
204 self.pg_start()
205
206 self.pg0.assert_nothing_captured(
207 remark="IP multicast packets forwarded on default route")
208
209 #
210 # A (*,G).
Neale Ranns37be7362017-02-21 17:30:26 -0800211 # one accepting interface, pg0, 7 forwarding interfaces
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700212 # many forwarding interfaces test the case where the replicate DPO
Neale Ranns37be7362017-02-21 17:30:26 -0800213 # needs to use extra cache lines for the buckets.
Neale Ranns32e1c012016-11-22 17:07:28 +0000214 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800215 route_232_1_1_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000216 self,
217 "0.0.0.0",
218 "232.1.1.1", 32,
219 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800220 [VppMRoutePath(self.pg0.sw_if_index,
221 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
222 VppMRoutePath(self.pg1.sw_if_index,
223 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
224 VppMRoutePath(self.pg2.sw_if_index,
225 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
226 VppMRoutePath(self.pg3.sw_if_index,
Neale Ranns37be7362017-02-21 17:30:26 -0800227 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
228 VppMRoutePath(self.pg4.sw_if_index,
229 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
230 VppMRoutePath(self.pg5.sw_if_index,
231 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
232 VppMRoutePath(self.pg6.sw_if_index,
233 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
234 VppMRoutePath(self.pg7.sw_if_index,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800235 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000236 route_232_1_1_1.add_vpp_config()
237
238 #
239 # An (S,G).
240 # one accepting interface, pg0, 2 forwarding interfaces
241 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800242 route_1_1_1_1_232_1_1_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000243 self,
244 "1.1.1.1",
Neale Ranns3e42ebe2018-10-04 08:36:56 -0700245 "232.1.1.1", 27, # any grp-len is ok when src is set
Neale Ranns32e1c012016-11-22 17:07:28 +0000246 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800247 [VppMRoutePath(self.pg0.sw_if_index,
248 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
249 VppMRoutePath(self.pg1.sw_if_index,
250 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
251 VppMRoutePath(self.pg2.sw_if_index,
252 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000253 route_1_1_1_1_232_1_1_1.add_vpp_config()
254
255 #
Neale Rannse821ab12017-06-01 07:45:05 -0700256 # An (S,G).
257 # one accepting interface, pg0, 2 forwarding interfaces
258 # that use unicast next-hops
259 #
260 route_1_1_1_1_232_1_1_2 = VppIpMRoute(
261 self,
262 "1.1.1.1",
263 "232.1.1.2", 64,
264 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
265 [VppMRoutePath(self.pg0.sw_if_index,
266 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
267 VppMRoutePath(self.pg1.sw_if_index,
268 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
269 nh=self.pg1.remote_ip4),
270 VppMRoutePath(self.pg2.sw_if_index,
271 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
272 nh=self.pg2.remote_ip4)])
273 route_1_1_1_1_232_1_1_2.add_vpp_config()
274
275 #
Neale Ranns32e1c012016-11-22 17:07:28 +0000276 # An (*,G/m).
277 # one accepting interface, pg0, 1 forwarding interfaces
278 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800279 route_232 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000280 self,
281 "0.0.0.0",
282 "232.0.0.0", 8,
283 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800284 [VppMRoutePath(self.pg0.sw_if_index,
285 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
286 VppMRoutePath(self.pg1.sw_if_index,
287 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000288 route_232.add_vpp_config()
289
290 #
291 # a stream that matches the route for (1.1.1.1,232.1.1.1)
Neale Ranns9d676af2017-03-15 01:28:31 -0700292 # small packets
Neale Ranns32e1c012016-11-22 17:07:28 +0000293 #
294 self.vapi.cli("clear trace")
295 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
296 self.pg0.add_stream(tx)
297
298 self.pg_enable_capture(self.pg_interfaces)
299 self.pg_start()
300
Neale Ranns28c142e2018-09-07 09:37:07 -0700301 self.assertEqual(route_1_1_1_1_232_1_1_1.get_stats()['packets'],
302 len(tx))
303
Neale Ranns37be7362017-02-21 17:30:26 -0800304 # We expect replications on Pg1->7
Neale Ranns32e1c012016-11-22 17:07:28 +0000305 self.verify_capture_ip4(self.pg1, tx)
306 self.verify_capture_ip4(self.pg2, tx)
307
308 # no replications on Pg0
309 self.pg0.assert_nothing_captured(
310 remark="IP multicast packets forwarded on PG0")
311 self.pg3.assert_nothing_captured(
312 remark="IP multicast packets forwarded on PG3")
313
314 #
Neale Ranns9d676af2017-03-15 01:28:31 -0700315 # a stream that matches the route for (1.1.1.1,232.1.1.1)
316 # large packets
317 #
318 self.vapi.cli("clear trace")
319 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1",
320 payload_size=1024)
321 self.pg0.add_stream(tx)
322
323 self.pg_enable_capture(self.pg_interfaces)
324 self.pg_start()
325
326 # We expect replications on Pg1->7
327 self.verify_capture_ip4(self.pg1, tx)
328 self.verify_capture_ip4(self.pg2, tx)
Neale Ranns9d676af2017-03-15 01:28:31 -0700329
Neale Ranns28c142e2018-09-07 09:37:07 -0700330 self.assertEqual(route_1_1_1_1_232_1_1_1.get_stats()['packets'],
331 2*len(tx))
332
Neale Ranns9d676af2017-03-15 01:28:31 -0700333 # no replications on Pg0
334 self.pg0.assert_nothing_captured(
335 remark="IP multicast packets forwarded on PG0")
336 self.pg3.assert_nothing_captured(
337 remark="IP multicast packets forwarded on PG3")
338
339 #
Neale Rannse821ab12017-06-01 07:45:05 -0700340 # a stream to the unicast next-hops
341 #
342 self.vapi.cli("clear trace")
343 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.2")
344 self.pg0.add_stream(tx)
345
346 self.pg_enable_capture(self.pg_interfaces)
347 self.pg_start()
348
349 # We expect replications on Pg1->7
350 self.verify_capture_ip4(self.pg1, tx, dst_mac=self.pg1.remote_mac)
351 self.verify_capture_ip4(self.pg2, tx, dst_mac=self.pg2.remote_mac)
352
353 # no replications on Pg0 nor pg3
354 self.pg0.assert_nothing_captured(
355 remark="IP multicast packets forwarded on PG0")
356 self.pg3.assert_nothing_captured(
357 remark="IP multicast packets forwarded on PG3")
358
359 #
Neale Ranns32e1c012016-11-22 17:07:28 +0000360 # a stream that matches the route for (*,232.0.0.0/8)
361 # Send packets with the 9th bit set so we test the correct clearing
362 # of that bit in the mac rewrite
363 #
364 self.vapi.cli("clear trace")
365 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.255.255.255")
366 self.pg0.add_stream(tx)
367
368 self.pg_enable_capture(self.pg_interfaces)
369 self.pg_start()
370
371 # We expect replications on Pg1 only
372 self.verify_capture_ip4(self.pg1, tx)
Neale Ranns28c142e2018-09-07 09:37:07 -0700373 self.assertEqual(route_232.get_stats()['packets'], len(tx))
Neale Ranns32e1c012016-11-22 17:07:28 +0000374
375 # no replications on Pg0, Pg2 not Pg3
376 self.pg0.assert_nothing_captured(
377 remark="IP multicast packets forwarded on PG0")
378 self.pg2.assert_nothing_captured(
379 remark="IP multicast packets forwarded on PG2")
380 self.pg3.assert_nothing_captured(
381 remark="IP multicast packets forwarded on PG3")
382
383 #
384 # a stream that matches the route for (*,232.1.1.1)
385 #
386 self.vapi.cli("clear trace")
387 tx = self.create_stream_ip4(self.pg0, "1.1.1.2", "232.1.1.1")
388 self.pg0.add_stream(tx)
389
390 self.pg_enable_capture(self.pg_interfaces)
391 self.pg_start()
392
Neale Rannse821ab12017-06-01 07:45:05 -0700393 # We expect replications on Pg1->7
Neale Ranns32e1c012016-11-22 17:07:28 +0000394 self.verify_capture_ip4(self.pg1, tx)
395 self.verify_capture_ip4(self.pg2, tx)
396 self.verify_capture_ip4(self.pg3, tx)
Neale Rannsc2aad532017-05-30 09:53:52 -0700397 self.verify_capture_ip4(self.pg4, tx)
398 self.verify_capture_ip4(self.pg5, tx)
399 self.verify_capture_ip4(self.pg6, tx)
400 self.verify_capture_ip4(self.pg7, tx)
Neale Ranns32e1c012016-11-22 17:07:28 +0000401
Neale Rannse821ab12017-06-01 07:45:05 -0700402 # no replications on Pg0
403 self.pg0.assert_nothing_captured(
404 remark="IP multicast packets forwarded on PG0")
405
Neale Ranns21fb4f72020-10-05 12:26:47 +0000406 self.vapi.cli("packet mac-filter pg0 off")
407 self.vapi.cli("packet mac-filter pg1 off")
408 self.vapi.cli("packet mac-filter pg2 off")
409 self.vapi.cli("packet mac-filter pg4 off")
410 self.vapi.cli("packet mac-filter pg5 off")
411 self.vapi.cli("packet mac-filter pg6 off")
412 self.vapi.cli("packet mac-filter pg7 off")
413
Neale Ranns32e1c012016-11-22 17:07:28 +0000414 def test_ip6_mcast(self):
415 """ IPv6 Multicast Replication """
416
Neale Ranns21fb4f72020-10-05 12:26:47 +0000417 self.vapi.cli("packet mac-filter pg0 on")
418 self.vapi.cli("packet mac-filter pg1 on")
419 self.vapi.cli("packet mac-filter pg2 on")
420 self.vapi.cli("packet mac-filter pg4 on")
421 self.vapi.cli("packet mac-filter pg5 on")
422 self.vapi.cli("packet mac-filter pg6 on")
423 self.vapi.cli("packet mac-filter pg7 on")
Neale Ranns32e1c012016-11-22 17:07:28 +0000424 #
425 # a stream that matches the default route. gets dropped.
426 #
427 self.vapi.cli("clear trace")
428 tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1")
429 self.pg0.add_stream(tx)
430
431 self.pg_enable_capture(self.pg_interfaces)
432 self.pg_start()
433
434 self.pg0.assert_nothing_captured(
435 remark="IPv6 multicast packets forwarded on default route")
436
437 #
438 # A (*,G).
439 # one accepting interface, pg0, 3 forwarding interfaces
440 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800441 route_ff01_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000442 self,
443 "::",
444 "ff01::1", 128,
445 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800446 [VppMRoutePath(self.pg0.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700447 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
Neale Ranns097fa662018-05-01 05:17:55 -0700448 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800449 VppMRoutePath(self.pg1.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700450 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700451 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800452 VppMRoutePath(self.pg2.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700453 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700454 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800455 VppMRoutePath(self.pg3.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700456 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700457 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000458 route_ff01_1.add_vpp_config()
459
460 #
461 # An (S,G).
462 # one accepting interface, pg0, 2 forwarding interfaces
463 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800464 route_2001_ff01_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000465 self,
466 "2001::1",
Neale Ranns3e42ebe2018-10-04 08:36:56 -0700467 "ff01::1", 0, # any grp-len is ok when src is set
Neale Ranns32e1c012016-11-22 17:07:28 +0000468 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800469 [VppMRoutePath(self.pg0.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700470 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
Neale Ranns097fa662018-05-01 05:17:55 -0700471 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800472 VppMRoutePath(self.pg1.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700473 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700474 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800475 VppMRoutePath(self.pg2.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700476 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700477 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000478 route_2001_ff01_1.add_vpp_config()
479
480 #
481 # An (*,G/m).
482 # one accepting interface, pg0, 1 forwarding interface
483 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800484 route_ff01 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000485 self,
486 "::",
487 "ff01::", 16,
488 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800489 [VppMRoutePath(self.pg0.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700490 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
Neale Ranns097fa662018-05-01 05:17:55 -0700491 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns5a8123b2017-01-26 01:18:23 -0800492 VppMRoutePath(self.pg1.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700493 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700494 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000495 route_ff01.add_vpp_config()
496
497 #
498 # a stream that matches the route for (*, ff01::/16)
Neale Rannsce111d22018-01-23 08:38:50 -0800499 # sent on the non-accepting interface
500 #
501 self.vapi.cli("clear trace")
502 tx = self.create_stream_ip6(self.pg1, "2002::1", "ff01:2::255")
503 self.send_and_assert_no_replies(self.pg1, tx, "RPF miss")
504
505 #
506 # a stream that matches the route for (*, ff01::/16)
507 # sent on the accepting interface
Neale Ranns32e1c012016-11-22 17:07:28 +0000508 #
509 self.vapi.cli("clear trace")
510 tx = self.create_stream_ip6(self.pg0, "2002::1", "ff01:2::255")
511 self.pg0.add_stream(tx)
512
513 self.pg_enable_capture(self.pg_interfaces)
514 self.pg_start()
515
516 # We expect replications on Pg1
517 self.verify_capture_ip6(self.pg1, tx)
518
519 # no replications on Pg0, Pg3
520 self.pg0.assert_nothing_captured(
521 remark="IP multicast packets forwarded on PG0")
522 self.pg2.assert_nothing_captured(
523 remark="IP multicast packets forwarded on PG2")
524 self.pg3.assert_nothing_captured(
525 remark="IP multicast packets forwarded on PG3")
526
527 #
Neale Rannsc2aad532017-05-30 09:53:52 -0700528 # Bounce the interface and it should still work
529 #
530 self.pg1.admin_down()
531 self.pg0.add_stream(tx)
532 self.pg_enable_capture(self.pg_interfaces)
533 self.pg_start()
534 self.pg1.assert_nothing_captured(
535 remark="IP multicast packets forwarded on down PG1")
536
537 self.pg1.admin_up()
538 self.pg0.add_stream(tx)
539 self.pg_enable_capture(self.pg_interfaces)
540 self.pg_start()
541 self.verify_capture_ip6(self.pg1, tx)
542
543 #
Neale Ranns32e1c012016-11-22 17:07:28 +0000544 # a stream that matches the route for (*,ff01::1)
545 #
546 self.vapi.cli("clear trace")
547 tx = self.create_stream_ip6(self.pg0, "2002::2", "ff01::1")
548 self.pg0.add_stream(tx)
549
550 self.pg_enable_capture(self.pg_interfaces)
551 self.pg_start()
552
553 # We expect replications on Pg1, 2, 3.
554 self.verify_capture_ip6(self.pg1, tx)
555 self.verify_capture_ip6(self.pg2, tx)
556 self.verify_capture_ip6(self.pg3, tx)
557
558 # no replications on Pg0
559 self.pg0.assert_nothing_captured(
560 remark="IPv6 multicast packets forwarded on PG0")
561
562 #
563 # a stream that matches the route for (2001::1, ff00::1)
564 #
565 self.vapi.cli("clear trace")
566 tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1")
567 self.pg0.add_stream(tx)
568
569 self.pg_enable_capture(self.pg_interfaces)
570 self.pg_start()
571
572 # We expect replications on Pg1, 2,
573 self.verify_capture_ip6(self.pg1, tx)
574 self.verify_capture_ip6(self.pg2, tx)
575
576 # no replications on Pg0, Pg3
577 self.pg0.assert_nothing_captured(
578 remark="IP multicast packets forwarded on PG0")
579 self.pg3.assert_nothing_captured(
580 remark="IP multicast packets forwarded on PG3")
581
Neale Ranns21fb4f72020-10-05 12:26:47 +0000582 self.vapi.cli("packet mac-filter pg0 off")
583 self.vapi.cli("packet mac-filter pg1 off")
584 self.vapi.cli("packet mac-filter pg2 off")
585 self.vapi.cli("packet mac-filter pg4 off")
586 self.vapi.cli("packet mac-filter pg5 off")
587 self.vapi.cli("packet mac-filter pg6 off")
588 self.vapi.cli("packet mac-filter pg7 off")
589
Neale Ranns32e1c012016-11-22 17:07:28 +0000590 def _mcast_connected_send_stream(self, dst_ip):
591 self.vapi.cli("clear trace")
592 tx = self.create_stream_ip4(self.pg0,
593 self.pg0.remote_ip4,
594 dst_ip)
595 self.pg0.add_stream(tx)
596
597 self.pg_enable_capture(self.pg_interfaces)
598 self.pg_start()
599
600 # We expect replications on Pg1.
601 self.verify_capture_ip4(self.pg1, tx)
602
603 return tx
604
605 def test_ip_mcast_connected(self):
606 """ IP Multicast Connected Source check """
607
608 #
609 # A (*,G).
610 # one accepting interface, pg0, 1 forwarding interfaces
611 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800612 route_232_1_1_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000613 self,
614 "0.0.0.0",
615 "232.1.1.1", 32,
616 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800617 [VppMRoutePath(self.pg0.sw_if_index,
618 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
619 VppMRoutePath(self.pg1.sw_if_index,
620 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000621
622 route_232_1_1_1.add_vpp_config()
623 route_232_1_1_1.update_entry_flags(
624 MRouteEntryFlags.MFIB_ENTRY_FLAG_CONNECTED)
625
626 #
627 # Now the (*,G) is present, send from connected source
628 #
629 tx = self._mcast_connected_send_stream("232.1.1.1")
630
631 #
632 # Constrct a representation of the signal we expect on pg0
633 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800634 signal_232_1_1_1_itf_0 = VppMFibSignal(self,
635 route_232_1_1_1,
636 self.pg0.sw_if_index,
637 tx[0])
Neale Ranns32e1c012016-11-22 17:07:28 +0000638
639 #
640 # read the only expected signal
641 #
642 signals = self.vapi.mfib_signal_dump()
643
644 self.assertEqual(1, len(signals))
645
646 signal_232_1_1_1_itf_0.compare(signals[0])
647
648 #
649 # reading the signal allows for the generation of another
650 # so send more packets and expect the next signal
651 #
652 tx = self._mcast_connected_send_stream("232.1.1.1")
653
654 signals = self.vapi.mfib_signal_dump()
655 self.assertEqual(1, len(signals))
656 signal_232_1_1_1_itf_0.compare(signals[0])
657
658 #
659 # A Second entry with connected check
660 # one accepting interface, pg0, 1 forwarding interfaces
661 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800662 route_232_1_1_2 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000663 self,
664 "0.0.0.0",
665 "232.1.1.2", 32,
666 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800667 [VppMRoutePath(self.pg0.sw_if_index,
668 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
669 VppMRoutePath(self.pg1.sw_if_index,
670 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000671
672 route_232_1_1_2.add_vpp_config()
673 route_232_1_1_2.update_entry_flags(
674 MRouteEntryFlags.MFIB_ENTRY_FLAG_CONNECTED)
675
676 #
677 # Send traffic to both entries. One read should net us two signals
678 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800679 signal_232_1_1_2_itf_0 = VppMFibSignal(self,
680 route_232_1_1_2,
681 self.pg0.sw_if_index,
682 tx[0])
Neale Ranns32e1c012016-11-22 17:07:28 +0000683 tx = self._mcast_connected_send_stream("232.1.1.1")
684 tx2 = self._mcast_connected_send_stream("232.1.1.2")
685
686 #
687 # read the only expected signal
688 #
689 signals = self.vapi.mfib_signal_dump()
690
691 self.assertEqual(2, len(signals))
692
693 signal_232_1_1_1_itf_0.compare(signals[1])
694 signal_232_1_1_2_itf_0.compare(signals[0])
695
Neale Rannsd792d9c2017-10-21 10:53:20 -0700696 route_232_1_1_1.update_entry_flags(
697 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
698 route_232_1_1_2.update_entry_flags(
699 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
Neale Ranns32e1c012016-11-22 17:07:28 +0000700
701 def test_ip_mcast_signal(self):
702 """ IP Multicast Signal """
703
704 #
705 # A (*,G).
706 # one accepting interface, pg0, 1 forwarding interfaces
707 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800708 route_232_1_1_1 = VppIpMRoute(
Neale Ranns32e1c012016-11-22 17:07:28 +0000709 self,
710 "0.0.0.0",
711 "232.1.1.1", 32,
712 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
Neale Ranns5a8123b2017-01-26 01:18:23 -0800713 [VppMRoutePath(self.pg0.sw_if_index,
714 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
715 VppMRoutePath(self.pg1.sw_if_index,
716 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
Neale Ranns32e1c012016-11-22 17:07:28 +0000717
718 route_232_1_1_1.add_vpp_config()
Neale Ranns097fa662018-05-01 05:17:55 -0700719
Neale Ranns32e1c012016-11-22 17:07:28 +0000720 route_232_1_1_1.update_entry_flags(
721 MRouteEntryFlags.MFIB_ENTRY_FLAG_SIGNAL)
722
723 #
724 # Now the (*,G) is present, send from connected source
725 #
726 tx = self._mcast_connected_send_stream("232.1.1.1")
727
728 #
729 # Constrct a representation of the signal we expect on pg0
730 #
Neale Ranns5a8123b2017-01-26 01:18:23 -0800731 signal_232_1_1_1_itf_0 = VppMFibSignal(self,
732 route_232_1_1_1,
733 self.pg0.sw_if_index,
734 tx[0])
Neale Ranns32e1c012016-11-22 17:07:28 +0000735
736 #
737 # read the only expected signal
738 #
739 signals = self.vapi.mfib_signal_dump()
740
741 self.assertEqual(1, len(signals))
742
743 signal_232_1_1_1_itf_0.compare(signals[0])
744
745 #
746 # reading the signal allows for the generation of another
747 # so send more packets and expect the next signal
748 #
749 tx = self._mcast_connected_send_stream("232.1.1.1")
750
751 signals = self.vapi.mfib_signal_dump()
752 self.assertEqual(1, len(signals))
753 signal_232_1_1_1_itf_0.compare(signals[0])
754
755 #
756 # Set the negate-signal on the accepting interval - the signals
757 # should stop
758 #
759 route_232_1_1_1.update_path_flags(
760 self.pg0.sw_if_index,
761 (MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
762 MRouteItfFlags.MFIB_ITF_FLAG_NEGATE_SIGNAL))
763
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800764 self.vapi.cli("clear trace")
Neale Ranns32e1c012016-11-22 17:07:28 +0000765 tx = self._mcast_connected_send_stream("232.1.1.1")
766
767 signals = self.vapi.mfib_signal_dump()
768 self.assertEqual(0, len(signals))
769
770 #
771 # Clear the SIGNAL flag on the entry and the signals should
772 # come back since the interface is still NEGATE-SIGNAL
773 #
774 route_232_1_1_1.update_entry_flags(
775 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
776
777 tx = self._mcast_connected_send_stream("232.1.1.1")
778
779 signals = self.vapi.mfib_signal_dump()
780 self.assertEqual(1, len(signals))
781 signal_232_1_1_1_itf_0.compare(signals[0])
782
783 #
784 # Lastly remove the NEGATE-SIGNAL from the interface and the
785 # signals should stop
786 #
787 route_232_1_1_1.update_path_flags(self.pg0.sw_if_index,
788 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT)
789
790 tx = self._mcast_connected_send_stream("232.1.1.1")
791 signals = self.vapi.mfib_signal_dump()
792 self.assertEqual(0, len(signals))
793
Neale Ranns15002542017-09-10 04:39:11 -0700794 def test_ip_mcast_vrf(self):
795 """ IP Multicast Replication in non-default table"""
796
797 #
798 # An (S,G).
799 # one accepting interface, pg0, 2 forwarding interfaces
800 #
801 route_1_1_1_1_232_1_1_1 = VppIpMRoute(
802 self,
803 "1.1.1.1",
804 "232.1.1.1", 64,
805 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
806 [VppMRoutePath(self.pg8.sw_if_index,
807 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
808 VppMRoutePath(self.pg1.sw_if_index,
809 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
810 VppMRoutePath(self.pg2.sw_if_index,
811 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)],
812 table_id=10)
813 route_1_1_1_1_232_1_1_1.add_vpp_config()
814
815 #
816 # a stream that matches the route for (1.1.1.1,232.1.1.1)
817 # small packets
818 #
819 self.vapi.cli("clear trace")
820 tx = self.create_stream_ip4(self.pg8, "1.1.1.1", "232.1.1.1")
821 self.pg8.add_stream(tx)
822
823 self.pg_enable_capture(self.pg_interfaces)
824 self.pg_start()
825
826 # We expect replications on Pg1 & 2
827 self.verify_capture_ip4(self.pg1, tx)
828 self.verify_capture_ip4(self.pg2, tx)
829
Neale Rannsadb17a82019-08-04 02:41:57 -0700830 def test_ip_mcast_gre(self):
831 """ IP Multicast Replication over GRE"""
832
833 gre_if_1 = VppGreInterface(
834 self,
835 self.pg1.local_ip4,
836 self.pg1.remote_ip4).add_vpp_config()
837 gre_if_2 = VppGreInterface(
838 self,
839 self.pg2.local_ip4,
840 self.pg2.remote_ip4).add_vpp_config()
841 gre_if_3 = VppGreInterface(
842 self,
843 self.pg3.local_ip4,
844 self.pg3.remote_ip4).add_vpp_config()
845
846 gre_if_1.admin_up()
847 gre_if_1.config_ip4()
848 gre_if_2.admin_up()
849 gre_if_2.config_ip4()
850 gre_if_3.admin_up()
851 gre_if_3.config_ip4()
852
853 #
854 # An (S,G).
855 # one accepting interface, pg0, 2 forwarding interfaces
856 #
857 route_1_1_1_1_232_1_1_1 = VppIpMRoute(
858 self,
859 "1.1.1.1",
860 "232.2.2.2", 64,
861 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
862 [VppMRoutePath(gre_if_1.sw_if_index,
863 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
864 VppMRoutePath(gre_if_2.sw_if_index,
865 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
866 VppMRoutePath(gre_if_3.sw_if_index,
867 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
868 route_1_1_1_1_232_1_1_1.add_vpp_config()
869
870 #
871 # a stream that matches the route for (1.1.1.1,232.2.2.2)
872 # small packets
873 #
874 tx = (Ether(dst=self.pg1.local_mac,
875 src=self.pg1.remote_mac) /
876 IP(src=self.pg1.remote_ip4,
877 dst=self.pg1.local_ip4) /
878 GRE() /
879 IP(src="1.1.1.1", dst="232.2.2.2") /
880 UDP(sport=1234, dport=1234) /
Ole Troan770a0de2019-11-07 13:52:21 +0100881 Raw(b'\a5' * 64)) * 63
Neale Rannsadb17a82019-08-04 02:41:57 -0700882
883 self.vapi.cli("clear trace")
884 self.pg1.add_stream(tx)
885
886 self.pg_enable_capture(self.pg_interfaces)
887 self.pg_start()
888
889 # We expect replications on Pg2 & 3
890 # check the encap headers are as expected based on the egress tunnel
891 rxs = self.pg2.get_capture(len(tx))
892 for rx in rxs:
893 self.assertEqual(rx[IP].src, gre_if_2.t_src)
894 self.assertEqual(rx[IP].dst, gre_if_2.t_dst)
895 self.assert_packet_checksums_valid(rx)
896
897 rxs = self.pg3.get_capture(len(tx))
898 for rx in rxs:
899 self.assertEqual(rx[IP].src, gre_if_3.t_src)
900 self.assertEqual(rx[IP].dst, gre_if_3.t_dst)
901 self.assert_packet_checksums_valid(rx)
902
Neale Ranns15002542017-09-10 04:39:11 -0700903 def test_ip6_mcast_vrf(self):
904 """ IPv6 Multicast Replication in non-default table"""
905
906 #
907 # An (S,G).
908 # one accepting interface, pg0, 2 forwarding interfaces
909 #
910 route_2001_ff01_1 = VppIpMRoute(
911 self,
912 "2001::1",
913 "ff01::1", 256,
914 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
915 [VppMRoutePath(self.pg8.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700916 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
Neale Ranns097fa662018-05-01 05:17:55 -0700917 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns15002542017-09-10 04:39:11 -0700918 VppMRoutePath(self.pg1.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700919 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700920 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
Neale Ranns15002542017-09-10 04:39:11 -0700921 VppMRoutePath(self.pg2.sw_if_index,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700922 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700923 proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)],
924 table_id=10)
Neale Ranns15002542017-09-10 04:39:11 -0700925 route_2001_ff01_1.add_vpp_config()
926
927 #
928 # a stream that matches the route for (2001::1, ff00::1)
929 #
930 self.vapi.cli("clear trace")
931 tx = self.create_stream_ip6(self.pg8, "2001::1", "ff01::1")
932 self.pg8.add_stream(tx)
933
934 self.pg_enable_capture(self.pg_interfaces)
935 self.pg_start()
936
937 # We expect replications on Pg1, 2,
938 self.verify_capture_ip6(self.pg1, tx)
939 self.verify_capture_ip6(self.pg2, tx)
Neale Ranns32e1c012016-11-22 17:07:28 +0000940
Neale Rannscf3561b2017-12-13 01:44:25 -0800941 def test_bidir(self):
942 """ IP Multicast Bi-directional """
943
944 #
945 # A (*,G). The set of accepting interfaces matching the forwarding
946 #
947 route_232_1_1_1 = VppIpMRoute(
948 self,
949 "0.0.0.0",
950 "232.1.1.1", 32,
951 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
952 [VppMRoutePath(self.pg0.sw_if_index,
953 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
954 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
955 VppMRoutePath(self.pg1.sw_if_index,
956 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
957 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
958 VppMRoutePath(self.pg2.sw_if_index,
959 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
960 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
961 VppMRoutePath(self.pg3.sw_if_index,
962 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
963 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
964 route_232_1_1_1.add_vpp_config()
965
966 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
967 self.pg0.add_stream(tx)
968
969 self.pg_enable_capture(self.pg_interfaces)
970 self.pg_start()
971
972 # We expect replications on Pg1, 2, 3, but not on pg0
973 self.verify_capture_ip4(self.pg1, tx)
974 self.verify_capture_ip4(self.pg2, tx)
975 self.verify_capture_ip4(self.pg3, tx)
976 self.pg0.assert_nothing_captured(
977 remark="IP multicast packets forwarded on PG0")
978
979
Neale Ranns32e1c012016-11-22 17:07:28 +0000980if __name__ == '__main__':
981 unittest.main(testRunner=VppTestRunner)