5 from framework import VppTestCase, VppTestRunner
6 from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal, \
7 MRouteItfFlags, MRouteEntryFlags, VppIpTable, DpoProto
9 from scapy.packet import Raw
10 from scapy.layers.l2 import Ether
11 from scapy.layers.inet import IP, UDP, getmacbyip
12 from scapy.layers.inet6 import IPv6, getmacbyip6
15 # The number of packets sent is set to 91 so that when we replicate more than 3
16 # times, which we do for some entries, we will generate more than 256 packets
17 # to the next node in the VLIB graph. Thus we are testing the code's
18 # correctness handling this over-flow.
19 # It's also an odd number so we hit any single loops.
24 class TestMFIB(VppTestCase):
25 """ MFIB Test Case """
28 super(TestMFIB, self).setUp()
31 """ MFIB Unit Tests """
32 error = self.vapi.cli("test mfib")
35 self.logger.critical(error)
36 self.assertEqual(error.find("Failed"), -1)
39 class TestIPMcast(VppTestCase):
40 """ IP Multicast Test Case """
43 super(TestIPMcast, self).setUp()
45 # create 8 pg interfaces
46 self.create_pg_interfaces(range(9))
49 for i in self.pg_interfaces[:8]:
57 tbl4 = VppIpTable(self, 10)
59 self.pg8.set_table_ip4(10)
62 tbl6 = VppIpTable(self, 10, is_ip6=1)
64 self.pg8.set_table_ip6(10)
68 for i in self.pg_interfaces:
73 self.pg8.set_table_ip4(0)
74 self.pg8.set_table_ip6(0)
75 super(TestIPMcast, self).tearDown()
77 def create_stream_ip4(self, src_if, src_ip, dst_ip, payload_size=0):
79 # default to small packet sizes
80 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
81 IP(src=src_ip, dst=dst_ip) /
82 UDP(sport=1234, dport=1234))
84 payload_size = 64 - len(p)
85 p = p / Raw('\xa5' * payload_size)
87 for i in range(0, N_PKTS_IN_STREAM):
91 def create_stream_ip6(self, src_if, src_ip, dst_ip):
93 for i in range(0, N_PKTS_IN_STREAM):
94 info = self.create_packet_info(src_if, src_if)
95 payload = self.info_to_payload(info)
96 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
97 IPv6(src=src_ip, dst=dst_ip) /
98 UDP(sport=1234, dport=1234) /
104 def verify_filter(self, capture, sent):
105 if not len(capture) == len(sent):
106 # filter out any IPv6 RAs from the captur
108 if (p.haslayer(IPv6)):
112 def verify_capture_ip4(self, rx_if, sent, dst_mac=None):
113 rxd = rx_if.get_capture(len(sent))
116 capture = self.verify_filter(rxd, sent)
118 self.assertEqual(len(capture), len(sent))
120 for i in range(len(capture)):
125 self.assertEqual(eth.type, 0x800)
131 dst_mac = getmacbyip(rx_ip.dst)
133 # check the MAC address on the RX'd packet is correctly formed
134 self.assertEqual(eth.dst, dst_mac)
136 self.assertEqual(rx_ip.src, tx_ip.src)
137 self.assertEqual(rx_ip.dst, tx_ip.dst)
138 # IP processing post pop has decremented the TTL
139 self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
144 def verify_capture_ip6(self, rx_if, sent):
145 capture = rx_if.get_capture(len(sent))
147 self.assertEqual(len(capture), len(sent))
149 for i in range(len(capture)):
154 self.assertEqual(eth.type, 0x86DD)
159 # check the MAC address on the RX'd packet is correctly formed
160 self.assertEqual(eth.dst, getmacbyip6(rx_ip.dst))
162 self.assertEqual(rx_ip.src, tx_ip.src)
163 self.assertEqual(rx_ip.dst, tx_ip.dst)
164 # IP processing post pop has decremented the TTL
165 self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim)
167 def test_ip_mcast(self):
168 """ IP Multicast Replication """
171 # a stream that matches the default route. gets dropped.
173 self.vapi.cli("clear trace")
174 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
175 self.pg0.add_stream(tx)
177 self.pg_enable_capture(self.pg_interfaces)
180 self.pg0.assert_nothing_captured(
181 remark="IP multicast packets forwarded on default route")
185 # one accepting interface, pg0, 7 forwarding interfaces
186 # many forwarding interfaces test the case where the replicare DPO
187 # needs to use extra cache lines for the buckets.
189 route_232_1_1_1 = VppIpMRoute(
193 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
194 [VppMRoutePath(self.pg0.sw_if_index,
195 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
196 VppMRoutePath(self.pg1.sw_if_index,
197 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
198 VppMRoutePath(self.pg2.sw_if_index,
199 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
200 VppMRoutePath(self.pg3.sw_if_index,
201 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
202 VppMRoutePath(self.pg4.sw_if_index,
203 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
204 VppMRoutePath(self.pg5.sw_if_index,
205 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
206 VppMRoutePath(self.pg6.sw_if_index,
207 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
208 VppMRoutePath(self.pg7.sw_if_index,
209 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
210 route_232_1_1_1.add_vpp_config()
214 # one accepting interface, pg0, 2 forwarding interfaces
216 route_1_1_1_1_232_1_1_1 = VppIpMRoute(
220 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
221 [VppMRoutePath(self.pg0.sw_if_index,
222 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
223 VppMRoutePath(self.pg1.sw_if_index,
224 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
225 VppMRoutePath(self.pg2.sw_if_index,
226 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
227 route_1_1_1_1_232_1_1_1.add_vpp_config()
231 # one accepting interface, pg0, 2 forwarding interfaces
232 # that use unicast next-hops
234 route_1_1_1_1_232_1_1_2 = VppIpMRoute(
238 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
239 [VppMRoutePath(self.pg0.sw_if_index,
240 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
241 VppMRoutePath(self.pg1.sw_if_index,
242 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
243 nh=self.pg1.remote_ip4),
244 VppMRoutePath(self.pg2.sw_if_index,
245 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
246 nh=self.pg2.remote_ip4)])
247 route_1_1_1_1_232_1_1_2.add_vpp_config()
251 # one accepting interface, pg0, 1 forwarding interfaces
253 route_232 = VppIpMRoute(
257 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
258 [VppMRoutePath(self.pg0.sw_if_index,
259 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
260 VppMRoutePath(self.pg1.sw_if_index,
261 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
262 route_232.add_vpp_config()
265 # a stream that matches the route for (1.1.1.1,232.1.1.1)
268 self.vapi.cli("clear trace")
269 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
270 self.pg0.add_stream(tx)
272 self.pg_enable_capture(self.pg_interfaces)
275 # We expect replications on Pg1->7
276 self.verify_capture_ip4(self.pg1, tx)
277 self.verify_capture_ip4(self.pg2, tx)
279 # no replications on Pg0
280 self.pg0.assert_nothing_captured(
281 remark="IP multicast packets forwarded on PG0")
282 self.pg3.assert_nothing_captured(
283 remark="IP multicast packets forwarded on PG3")
286 # a stream that matches the route for (1.1.1.1,232.1.1.1)
289 self.vapi.cli("clear trace")
290 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1",
292 self.pg0.add_stream(tx)
294 self.pg_enable_capture(self.pg_interfaces)
297 # We expect replications on Pg1->7
298 self.verify_capture_ip4(self.pg1, tx)
299 self.verify_capture_ip4(self.pg2, tx)
301 # no replications on Pg0
302 self.pg0.assert_nothing_captured(
303 remark="IP multicast packets forwarded on PG0")
304 self.pg3.assert_nothing_captured(
305 remark="IP multicast packets forwarded on PG3")
308 # a stream to the unicast next-hops
310 self.vapi.cli("clear trace")
311 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.2")
312 self.pg0.add_stream(tx)
314 self.pg_enable_capture(self.pg_interfaces)
317 # We expect replications on Pg1->7
318 self.verify_capture_ip4(self.pg1, tx, dst_mac=self.pg1.remote_mac)
319 self.verify_capture_ip4(self.pg2, tx, dst_mac=self.pg2.remote_mac)
321 # no replications on Pg0 nor pg3
322 self.pg0.assert_nothing_captured(
323 remark="IP multicast packets forwarded on PG0")
324 self.pg3.assert_nothing_captured(
325 remark="IP multicast packets forwarded on PG3")
328 # a stream that matches the route for (*,232.0.0.0/8)
329 # Send packets with the 9th bit set so we test the correct clearing
330 # of that bit in the mac rewrite
332 self.vapi.cli("clear trace")
333 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.255.255.255")
334 self.pg0.add_stream(tx)
336 self.pg_enable_capture(self.pg_interfaces)
339 # We expect replications on Pg1 only
340 self.verify_capture_ip4(self.pg1, tx)
342 # no replications on Pg0, Pg2 not Pg3
343 self.pg0.assert_nothing_captured(
344 remark="IP multicast packets forwarded on PG0")
345 self.pg2.assert_nothing_captured(
346 remark="IP multicast packets forwarded on PG2")
347 self.pg3.assert_nothing_captured(
348 remark="IP multicast packets forwarded on PG3")
351 # a stream that matches the route for (*,232.1.1.1)
353 self.vapi.cli("clear trace")
354 tx = self.create_stream_ip4(self.pg0, "1.1.1.2", "232.1.1.1")
355 self.pg0.add_stream(tx)
357 self.pg_enable_capture(self.pg_interfaces)
360 # We expect replications on Pg1->7
361 self.verify_capture_ip4(self.pg1, tx)
362 self.verify_capture_ip4(self.pg2, tx)
363 self.verify_capture_ip4(self.pg3, tx)
364 self.verify_capture_ip4(self.pg4, tx)
365 self.verify_capture_ip4(self.pg5, tx)
366 self.verify_capture_ip4(self.pg6, tx)
367 self.verify_capture_ip4(self.pg7, tx)
369 # no replications on Pg0
370 self.pg0.assert_nothing_captured(
371 remark="IP multicast packets forwarded on PG0")
373 def test_ip6_mcast(self):
374 """ IPv6 Multicast Replication """
377 # a stream that matches the default route. gets dropped.
379 self.vapi.cli("clear trace")
380 tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1")
381 self.pg0.add_stream(tx)
383 self.pg_enable_capture(self.pg_interfaces)
386 self.pg0.assert_nothing_captured(
387 remark="IPv6 multicast packets forwarded on default route")
391 # one accepting interface, pg0, 3 forwarding interfaces
393 route_ff01_1 = VppIpMRoute(
397 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
398 [VppMRoutePath(self.pg0.sw_if_index,
399 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
400 proto=DpoProto.DPO_PROTO_IP6),
401 VppMRoutePath(self.pg1.sw_if_index,
402 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
403 proto=DpoProto.DPO_PROTO_IP6),
404 VppMRoutePath(self.pg2.sw_if_index,
405 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
406 proto=DpoProto.DPO_PROTO_IP6),
407 VppMRoutePath(self.pg3.sw_if_index,
408 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
409 proto=DpoProto.DPO_PROTO_IP6)],
411 route_ff01_1.add_vpp_config()
415 # one accepting interface, pg0, 2 forwarding interfaces
417 route_2001_ff01_1 = VppIpMRoute(
421 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
422 [VppMRoutePath(self.pg0.sw_if_index,
423 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
424 proto=DpoProto.DPO_PROTO_IP6),
425 VppMRoutePath(self.pg1.sw_if_index,
426 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
427 proto=DpoProto.DPO_PROTO_IP6),
428 VppMRoutePath(self.pg2.sw_if_index,
429 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
430 proto=DpoProto.DPO_PROTO_IP6)],
432 route_2001_ff01_1.add_vpp_config()
436 # one accepting interface, pg0, 1 forwarding interface
438 route_ff01 = VppIpMRoute(
442 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
443 [VppMRoutePath(self.pg0.sw_if_index,
444 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
445 proto=DpoProto.DPO_PROTO_IP6),
446 VppMRoutePath(self.pg1.sw_if_index,
447 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
448 proto=DpoProto.DPO_PROTO_IP6)],
450 route_ff01.add_vpp_config()
453 # a stream that matches the route for (*, ff01::/16)
454 # sent on the non-accepting interface
456 self.vapi.cli("clear trace")
457 tx = self.create_stream_ip6(self.pg1, "2002::1", "ff01:2::255")
458 self.send_and_assert_no_replies(self.pg1, tx, "RPF miss")
461 # a stream that matches the route for (*, ff01::/16)
462 # sent on the accepting interface
464 self.vapi.cli("clear trace")
465 tx = self.create_stream_ip6(self.pg0, "2002::1", "ff01:2::255")
466 self.pg0.add_stream(tx)
468 self.pg_enable_capture(self.pg_interfaces)
471 # We expect replications on Pg1
472 self.verify_capture_ip6(self.pg1, tx)
474 # no replications on Pg0, Pg3
475 self.pg0.assert_nothing_captured(
476 remark="IP multicast packets forwarded on PG0")
477 self.pg2.assert_nothing_captured(
478 remark="IP multicast packets forwarded on PG2")
479 self.pg3.assert_nothing_captured(
480 remark="IP multicast packets forwarded on PG3")
483 # Bounce the interface and it should still work
485 self.pg1.admin_down()
486 self.pg0.add_stream(tx)
487 self.pg_enable_capture(self.pg_interfaces)
489 self.pg1.assert_nothing_captured(
490 remark="IP multicast packets forwarded on down PG1")
493 self.pg0.add_stream(tx)
494 self.pg_enable_capture(self.pg_interfaces)
496 self.verify_capture_ip6(self.pg1, tx)
499 # a stream that matches the route for (*,ff01::1)
501 self.vapi.cli("clear trace")
502 tx = self.create_stream_ip6(self.pg0, "2002::2", "ff01::1")
503 self.pg0.add_stream(tx)
505 self.pg_enable_capture(self.pg_interfaces)
508 # We expect replications on Pg1, 2, 3.
509 self.verify_capture_ip6(self.pg1, tx)
510 self.verify_capture_ip6(self.pg2, tx)
511 self.verify_capture_ip6(self.pg3, tx)
513 # no replications on Pg0
514 self.pg0.assert_nothing_captured(
515 remark="IPv6 multicast packets forwarded on PG0")
518 # a stream that matches the route for (2001::1, ff00::1)
520 self.vapi.cli("clear trace")
521 tx = self.create_stream_ip6(self.pg0, "2001::1", "ff01::1")
522 self.pg0.add_stream(tx)
524 self.pg_enable_capture(self.pg_interfaces)
527 # We expect replications on Pg1, 2,
528 self.verify_capture_ip6(self.pg1, tx)
529 self.verify_capture_ip6(self.pg2, tx)
531 # no replications on Pg0, Pg3
532 self.pg0.assert_nothing_captured(
533 remark="IP multicast packets forwarded on PG0")
534 self.pg3.assert_nothing_captured(
535 remark="IP multicast packets forwarded on PG3")
537 def _mcast_connected_send_stream(self, dst_ip):
538 self.vapi.cli("clear trace")
539 tx = self.create_stream_ip4(self.pg0,
542 self.pg0.add_stream(tx)
544 self.pg_enable_capture(self.pg_interfaces)
547 # We expect replications on Pg1.
548 self.verify_capture_ip4(self.pg1, tx)
552 def test_ip_mcast_connected(self):
553 """ IP Multicast Connected Source check """
557 # one accepting interface, pg0, 1 forwarding interfaces
559 route_232_1_1_1 = VppIpMRoute(
563 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
564 [VppMRoutePath(self.pg0.sw_if_index,
565 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
566 VppMRoutePath(self.pg1.sw_if_index,
567 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
569 route_232_1_1_1.add_vpp_config()
570 route_232_1_1_1.update_entry_flags(
571 MRouteEntryFlags.MFIB_ENTRY_FLAG_CONNECTED)
574 # Now the (*,G) is present, send from connected source
576 tx = self._mcast_connected_send_stream("232.1.1.1")
579 # Constrct a representation of the signal we expect on pg0
581 signal_232_1_1_1_itf_0 = VppMFibSignal(self,
583 self.pg0.sw_if_index,
587 # read the only expected signal
589 signals = self.vapi.mfib_signal_dump()
591 self.assertEqual(1, len(signals))
593 signal_232_1_1_1_itf_0.compare(signals[0])
596 # reading the signal allows for the generation of another
597 # so send more packets and expect the next signal
599 tx = self._mcast_connected_send_stream("232.1.1.1")
601 signals = self.vapi.mfib_signal_dump()
602 self.assertEqual(1, len(signals))
603 signal_232_1_1_1_itf_0.compare(signals[0])
606 # A Second entry with connected check
607 # one accepting interface, pg0, 1 forwarding interfaces
609 route_232_1_1_2 = VppIpMRoute(
613 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
614 [VppMRoutePath(self.pg0.sw_if_index,
615 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
616 VppMRoutePath(self.pg1.sw_if_index,
617 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
619 route_232_1_1_2.add_vpp_config()
620 route_232_1_1_2.update_entry_flags(
621 MRouteEntryFlags.MFIB_ENTRY_FLAG_CONNECTED)
624 # Send traffic to both entries. One read should net us two signals
626 signal_232_1_1_2_itf_0 = VppMFibSignal(self,
628 self.pg0.sw_if_index,
630 tx = self._mcast_connected_send_stream("232.1.1.1")
631 tx2 = self._mcast_connected_send_stream("232.1.1.2")
634 # read the only expected signal
636 signals = self.vapi.mfib_signal_dump()
638 self.assertEqual(2, len(signals))
640 signal_232_1_1_1_itf_0.compare(signals[1])
641 signal_232_1_1_2_itf_0.compare(signals[0])
643 route_232_1_1_1.update_entry_flags(
644 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
645 route_232_1_1_2.update_entry_flags(
646 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
648 def test_ip_mcast_signal(self):
649 """ IP Multicast Signal """
653 # one accepting interface, pg0, 1 forwarding interfaces
655 route_232_1_1_1 = VppIpMRoute(
659 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
660 [VppMRoutePath(self.pg0.sw_if_index,
661 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
662 VppMRoutePath(self.pg1.sw_if_index,
663 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
665 route_232_1_1_1.add_vpp_config()
666 route_232_1_1_1.update_entry_flags(
667 MRouteEntryFlags.MFIB_ENTRY_FLAG_SIGNAL)
670 # Now the (*,G) is present, send from connected source
672 tx = self._mcast_connected_send_stream("232.1.1.1")
675 # Constrct a representation of the signal we expect on pg0
677 signal_232_1_1_1_itf_0 = VppMFibSignal(self,
679 self.pg0.sw_if_index,
683 # read the only expected signal
685 signals = self.vapi.mfib_signal_dump()
687 self.assertEqual(1, len(signals))
689 signal_232_1_1_1_itf_0.compare(signals[0])
692 # reading the signal allows for the generation of another
693 # so send more packets and expect the next signal
695 tx = self._mcast_connected_send_stream("232.1.1.1")
697 signals = self.vapi.mfib_signal_dump()
698 self.assertEqual(1, len(signals))
699 signal_232_1_1_1_itf_0.compare(signals[0])
702 # Set the negate-signal on the accepting interval - the signals
705 route_232_1_1_1.update_path_flags(
706 self.pg0.sw_if_index,
707 (MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
708 MRouteItfFlags.MFIB_ITF_FLAG_NEGATE_SIGNAL))
710 self.vapi.cli("clear trace")
711 tx = self._mcast_connected_send_stream("232.1.1.1")
713 signals = self.vapi.mfib_signal_dump()
714 self.assertEqual(0, len(signals))
717 # Clear the SIGNAL flag on the entry and the signals should
718 # come back since the interface is still NEGATE-SIGNAL
720 route_232_1_1_1.update_entry_flags(
721 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE)
723 tx = self._mcast_connected_send_stream("232.1.1.1")
725 signals = self.vapi.mfib_signal_dump()
726 self.assertEqual(1, len(signals))
727 signal_232_1_1_1_itf_0.compare(signals[0])
730 # Lastly remove the NEGATE-SIGNAL from the interface and the
731 # signals should stop
733 route_232_1_1_1.update_path_flags(self.pg0.sw_if_index,
734 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT)
736 tx = self._mcast_connected_send_stream("232.1.1.1")
737 signals = self.vapi.mfib_signal_dump()
738 self.assertEqual(0, len(signals))
740 def test_ip_mcast_vrf(self):
741 """ IP Multicast Replication in non-default table"""
745 # one accepting interface, pg0, 2 forwarding interfaces
747 route_1_1_1_1_232_1_1_1 = VppIpMRoute(
751 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
752 [VppMRoutePath(self.pg8.sw_if_index,
753 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
754 VppMRoutePath(self.pg1.sw_if_index,
755 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
756 VppMRoutePath(self.pg2.sw_if_index,
757 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)],
759 route_1_1_1_1_232_1_1_1.add_vpp_config()
762 # a stream that matches the route for (1.1.1.1,232.1.1.1)
765 self.vapi.cli("clear trace")
766 tx = self.create_stream_ip4(self.pg8, "1.1.1.1", "232.1.1.1")
767 self.pg8.add_stream(tx)
769 self.pg_enable_capture(self.pg_interfaces)
772 # We expect replications on Pg1 & 2
773 self.verify_capture_ip4(self.pg1, tx)
774 self.verify_capture_ip4(self.pg2, tx)
776 def test_ip6_mcast_vrf(self):
777 """ IPv6 Multicast Replication in non-default table"""
781 # one accepting interface, pg0, 2 forwarding interfaces
783 route_2001_ff01_1 = VppIpMRoute(
787 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
788 [VppMRoutePath(self.pg8.sw_if_index,
789 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
790 proto=DpoProto.DPO_PROTO_IP6),
791 VppMRoutePath(self.pg1.sw_if_index,
792 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
793 proto=DpoProto.DPO_PROTO_IP6),
794 VppMRoutePath(self.pg2.sw_if_index,
795 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
796 proto=DpoProto.DPO_PROTO_IP6)],
799 route_2001_ff01_1.add_vpp_config()
802 # a stream that matches the route for (2001::1, ff00::1)
804 self.vapi.cli("clear trace")
805 tx = self.create_stream_ip6(self.pg8, "2001::1", "ff01::1")
806 self.pg8.add_stream(tx)
808 self.pg_enable_capture(self.pg_interfaces)
811 # We expect replications on Pg1, 2,
812 self.verify_capture_ip6(self.pg1, tx)
813 self.verify_capture_ip6(self.pg2, tx)
815 def test_bidir(self):
816 """ IP Multicast Bi-directional """
819 # A (*,G). The set of accepting interfaces matching the forwarding
821 route_232_1_1_1 = VppIpMRoute(
825 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
826 [VppMRoutePath(self.pg0.sw_if_index,
827 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
828 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
829 VppMRoutePath(self.pg1.sw_if_index,
830 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
831 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
832 VppMRoutePath(self.pg2.sw_if_index,
833 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
834 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD),
835 VppMRoutePath(self.pg3.sw_if_index,
836 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT |
837 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
838 route_232_1_1_1.add_vpp_config()
840 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
841 self.pg0.add_stream(tx)
843 self.pg_enable_capture(self.pg_interfaces)
846 # We expect replications on Pg1, 2, 3, but not on pg0
847 self.verify_capture_ip4(self.pg1, tx)
848 self.verify_capture_ip4(self.pg2, tx)
849 self.verify_capture_ip4(self.pg3, tx)
850 self.pg0.assert_nothing_captured(
851 remark="IP multicast packets forwarded on PG0")
854 if __name__ == '__main__':
855 unittest.main(testRunner=VppTestRunner)