6 from scapy.packet import Raw
7 from scapy.layers.l2 import Ether, Dot1Q, GRE
8 from scapy.layers.inet import IP, UDP
9 from scapy.layers.inet6 import IPv6
10 from scapy.volatile import RandMAC, RandIP
12 from framework import VppTestCase, VppTestRunner
13 from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
14 from vpp_gre_interface import VppGreInterface
15 from vpp_ip import DpoProto
16 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
17 from util import ppp, ppc
18 from vpp_papi import VppEnum
21 class TestGREInputNodes(VppTestCase):
22 """ GRE Input Nodes Test Case """
25 super(TestGREInputNodes, self).setUp()
27 # create 3 pg interfaces - set one in a non-default table.
28 self.create_pg_interfaces(range(1))
30 for i in self.pg_interfaces:
35 for i in self.pg_interfaces:
38 super(TestGREInputNodes, self).tearDown()
40 def test_gre_input_node(self):
41 """ GRE gre input nodes not registerd unless configured """
42 pkt = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
43 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
46 self.pg0.add_stream(pkt)
48 # no tunnel created, gre-input not registered
49 err = self.statistics.get_counter(
50 '/err/ip4-input/unknown ip protocol')[0]
51 self.assertEqual(err, 1)
55 gre_if = VppGreInterface(self, self.pg0.local_ip4, "1.1.1.2")
56 gre_if.add_vpp_config()
58 self.pg0.add_stream(pkt)
60 # tunnel created, gre-input registered
61 err = self.statistics.get_counter(
62 '/err/ip4-input/unknown ip protocol')[0]
63 # expect no new errors
64 self.assertEqual(err, err_count)
67 class TestGRE(VppTestCase):
72 super(TestGRE, cls).setUpClass()
75 def tearDownClass(cls):
76 super(TestGRE, cls).tearDownClass()
79 super(TestGRE, self).setUp()
81 # create 3 pg interfaces - set one in a non-default table.
82 self.create_pg_interfaces(range(3))
84 self.tbl = VppIpTable(self, 1)
85 self.tbl.add_vpp_config()
86 self.pg1.set_table_ip4(1)
88 for i in self.pg_interfaces:
92 self.pg0.resolve_arp()
94 self.pg1.resolve_arp()
96 self.pg2.resolve_ndp()
99 for i in self.pg_interfaces:
103 self.pg1.set_table_ip4(0)
104 super(TestGRE, self).tearDown()
106 def create_stream_ip4(self, src_if, src_ip, dst_ip):
108 for i in range(0, 257):
109 info = self.create_packet_info(src_if, src_if)
110 payload = self.info_to_payload(info)
111 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
112 IP(src=src_ip, dst=dst_ip) /
113 UDP(sport=1234, dport=1234) /
119 def create_stream_ip6(self, src_if, src_ip, dst_ip):
121 for i in range(0, 257):
122 info = self.create_packet_info(src_if, src_if)
123 payload = self.info_to_payload(info)
124 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
125 IPv6(src=src_ip, dst=dst_ip) /
126 UDP(sport=1234, dport=1234) /
132 def create_tunnel_stream_4o4(self, src_if,
133 tunnel_src, tunnel_dst,
136 for i in range(0, 257):
137 info = self.create_packet_info(src_if, src_if)
138 payload = self.info_to_payload(info)
139 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
140 IP(src=tunnel_src, dst=tunnel_dst) /
142 IP(src=src_ip, dst=dst_ip) /
143 UDP(sport=1234, dport=1234) /
149 def create_tunnel_stream_6o4(self, src_if,
150 tunnel_src, tunnel_dst,
153 for i in range(0, 257):
154 info = self.create_packet_info(src_if, src_if)
155 payload = self.info_to_payload(info)
156 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
157 IP(src=tunnel_src, dst=tunnel_dst) /
159 IPv6(src=src_ip, dst=dst_ip) /
160 UDP(sport=1234, dport=1234) /
166 def create_tunnel_stream_6o6(self, src_if,
167 tunnel_src, tunnel_dst,
170 for i in range(0, 257):
171 info = self.create_packet_info(src_if, src_if)
172 payload = self.info_to_payload(info)
173 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
174 IPv6(src=tunnel_src, dst=tunnel_dst) /
176 IPv6(src=src_ip, dst=dst_ip) /
177 UDP(sport=1234, dport=1234) /
183 def create_tunnel_stream_l2o4(self, src_if,
184 tunnel_src, tunnel_dst):
186 for i in range(0, 257):
187 info = self.create_packet_info(src_if, src_if)
188 payload = self.info_to_payload(info)
189 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
190 IP(src=tunnel_src, dst=tunnel_dst) /
192 Ether(dst=RandMAC('*:*:*:*:*:*'),
193 src=RandMAC('*:*:*:*:*:*')) /
194 IP(src=scapy.compat.raw(RandIP()),
195 dst=scapy.compat.raw(RandIP())) /
196 UDP(sport=1234, dport=1234) /
202 def create_tunnel_stream_vlano4(self, src_if,
203 tunnel_src, tunnel_dst, vlan):
205 for i in range(0, 257):
206 info = self.create_packet_info(src_if, src_if)
207 payload = self.info_to_payload(info)
208 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
209 IP(src=tunnel_src, dst=tunnel_dst) /
211 Ether(dst=RandMAC('*:*:*:*:*:*'),
212 src=RandMAC('*:*:*:*:*:*')) /
214 IP(src=scapy.compat.raw(RandIP()),
215 dst=scapy.compat.raw(RandIP())) /
216 UDP(sport=1234, dport=1234) /
222 def verify_tunneled_4o4(self, src_if, capture, sent,
223 tunnel_src, tunnel_dst):
225 self.assertEqual(len(capture), len(sent))
227 for i in range(len(capture)):
235 self.assertEqual(rx_ip.src, tunnel_src)
236 self.assertEqual(rx_ip.dst, tunnel_dst)
241 self.assertEqual(rx_ip.src, tx_ip.src)
242 self.assertEqual(rx_ip.dst, tx_ip.dst)
243 # IP processing post pop has decremented the TTL
244 self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
247 self.logger.error(ppp("Rx:", rx))
248 self.logger.error(ppp("Tx:", tx))
251 def verify_tunneled_6o6(self, src_if, capture, sent,
252 tunnel_src, tunnel_dst):
254 self.assertEqual(len(capture), len(sent))
256 for i in range(len(capture)):
264 self.assertEqual(rx_ip.src, tunnel_src)
265 self.assertEqual(rx_ip.dst, tunnel_dst)
267 rx_gre = GRE(scapy.compat.raw(rx_ip[IPv6].payload))
270 self.assertEqual(rx_ip.src, tx_ip.src)
271 self.assertEqual(rx_ip.dst, tx_ip.dst)
274 self.logger.error(ppp("Rx:", rx))
275 self.logger.error(ppp("Tx:", tx))
278 def verify_tunneled_4o6(self, src_if, capture, sent,
279 tunnel_src, tunnel_dst):
281 self.assertEqual(len(capture), len(sent))
283 for i in range(len(capture)):
290 self.assertEqual(rx_ip.src, tunnel_src)
291 self.assertEqual(rx_ip.dst, tunnel_dst)
293 rx_gre = GRE(scapy.compat.raw(rx_ip[IPv6].payload))
297 self.assertEqual(rx_ip.src, tx_ip.src)
298 self.assertEqual(rx_ip.dst, tx_ip.dst)
301 self.logger.error(ppp("Rx:", rx))
302 self.logger.error(ppp("Tx:", tx))
305 def verify_tunneled_6o4(self, src_if, capture, sent,
306 tunnel_src, tunnel_dst):
308 self.assertEqual(len(capture), len(sent))
310 for i in range(len(capture)):
317 self.assertEqual(rx_ip.src, tunnel_src)
318 self.assertEqual(rx_ip.dst, tunnel_dst)
320 rx_gre = GRE(scapy.compat.raw(rx_ip[IP].payload))
324 self.assertEqual(rx_ip.src, tx_ip.src)
325 self.assertEqual(rx_ip.dst, tx_ip.dst)
328 self.logger.error(ppp("Rx:", rx))
329 self.logger.error(ppp("Tx:", tx))
332 def verify_tunneled_l2o4(self, src_if, capture, sent,
333 tunnel_src, tunnel_dst):
334 self.assertEqual(len(capture), len(sent))
336 for i in range(len(capture)):
344 self.assertEqual(rx_ip.src, tunnel_src)
345 self.assertEqual(rx_ip.dst, tunnel_dst)
348 rx_l2 = rx_gre[Ether]
351 tx_l2 = tx_gre[Ether]
354 self.assertEqual(rx_ip.src, tx_ip.src)
355 self.assertEqual(rx_ip.dst, tx_ip.dst)
356 # bridged, not L3 forwarded, so no TTL decrement
357 self.assertEqual(rx_ip.ttl, tx_ip.ttl)
360 self.logger.error(ppp("Rx:", rx))
361 self.logger.error(ppp("Tx:", tx))
364 def verify_tunneled_vlano4(self, src_if, capture, sent,
365 tunnel_src, tunnel_dst, vlan):
367 self.assertEqual(len(capture), len(sent))
369 ppc("Unexpected packets captured:", capture)
372 for i in range(len(capture)):
380 self.assertEqual(rx_ip.src, tunnel_src)
381 self.assertEqual(rx_ip.dst, tunnel_dst)
384 rx_l2 = rx_gre[Ether]
385 rx_vlan = rx_l2[Dot1Q]
388 self.assertEqual(rx_vlan.vlan, vlan)
391 tx_l2 = tx_gre[Ether]
394 self.assertEqual(rx_ip.src, tx_ip.src)
395 self.assertEqual(rx_ip.dst, tx_ip.dst)
396 # bridged, not L3 forwarded, so no TTL decrement
397 self.assertEqual(rx_ip.ttl, tx_ip.ttl)
400 self.logger.error(ppp("Rx:", rx))
401 self.logger.error(ppp("Tx:", tx))
404 def verify_decapped_4o4(self, src_if, capture, sent):
405 self.assertEqual(len(capture), len(sent))
407 for i in range(len(capture)):
417 self.assertEqual(rx_ip.src, tx_ip.src)
418 self.assertEqual(rx_ip.dst, tx_ip.dst)
419 # IP processing post pop has decremented the TTL
420 self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
423 self.logger.error(ppp("Rx:", rx))
424 self.logger.error(ppp("Tx:", tx))
427 def verify_decapped_6o4(self, src_if, capture, sent):
428 self.assertEqual(len(capture), len(sent))
430 for i in range(len(capture)):
440 self.assertEqual(rx_ip.src, tx_ip.src)
441 self.assertEqual(rx_ip.dst, tx_ip.dst)
442 self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim)
445 self.logger.error(ppp("Rx:", rx))
446 self.logger.error(ppp("Tx:", tx))
450 """ GRE IPv4 tunnel Tests """
453 # Create an L3 GRE tunnel.
455 # - assign an IP Addres
456 # - Add a route via the tunnel
458 gre_if = VppGreInterface(self,
461 gre_if.add_vpp_config()
464 # The double create (create the same tunnel twice) should fail,
465 # and we should still be able to use the original
468 gre_if.add_vpp_config()
472 self.fail("Double GRE tunnel add does not fail")
477 route_via_tun = VppIpRoute(self, "4.4.4.4", 32,
478 [VppRoutePath("0.0.0.0",
479 gre_if.sw_if_index)])
481 route_via_tun.add_vpp_config()
484 # Send a packet stream that is routed into the tunnel
485 # - they are all dropped since the tunnel's destintation IP
486 # is unresolved - or resolves via the default route - which
489 tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "4.4.4.4")
491 self.send_and_assert_no_replies(self.pg0, tx)
494 # Add a route that resolves the tunnel's destination
496 route_tun_dst = VppIpRoute(self, "1.1.1.2", 32,
497 [VppRoutePath(self.pg0.remote_ip4,
498 self.pg0.sw_if_index)])
499 route_tun_dst.add_vpp_config()
502 # Send a packet stream that is routed into the tunnel
503 # - packets are GRE encapped
505 tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "4.4.4.4")
506 rx = self.send_and_expect(self.pg0, tx, self.pg0)
507 self.verify_tunneled_4o4(self.pg0, rx, tx,
508 self.pg0.local_ip4, "1.1.1.2")
511 # Send tunneled packets that match the created tunnel and
512 # are decapped and forwarded
514 tx = self.create_tunnel_stream_4o4(self.pg0,
519 rx = self.send_and_expect(self.pg0, tx, self.pg0)
520 self.verify_decapped_4o4(self.pg0, rx, tx)
523 # Send tunneled packets that do not match the tunnel's src
525 self.vapi.cli("clear trace")
526 tx = self.create_tunnel_stream_4o4(self.pg0,
531 self.send_and_assert_no_replies(
533 remark="GRE packets forwarded despite no SRC address match")
536 # Configure IPv6 on the PG interface so we can route IPv6
539 self.pg0.config_ip6()
540 self.pg0.resolve_ndp()
543 # Send IPv6 tunnel encapslated packets
544 # - dropped since IPv6 is not enabled on the tunnel
546 tx = self.create_tunnel_stream_6o4(self.pg0,
551 self.send_and_assert_no_replies(self.pg0, tx,
552 "IPv6 GRE packets forwarded "
553 "despite IPv6 not enabled on tunnel")
556 # Enable IPv6 on the tunnel
561 # Send IPv6 tunnel encapslated packets
562 # - forwarded since IPv6 is enabled on the tunnel
564 tx = self.create_tunnel_stream_6o4(self.pg0,
569 rx = self.send_and_expect(self.pg0, tx, self.pg0)
570 self.verify_decapped_6o4(self.pg0, rx, tx)
573 # Send v6 packets for v4 encap
575 route6_via_tun = VppIpRoute(
576 self, "2001::1", 128,
579 proto=DpoProto.DPO_PROTO_IP6)],
581 route6_via_tun.add_vpp_config()
583 tx = self.create_stream_ip6(self.pg0, "2001::2", "2001::1")
584 rx = self.send_and_expect(self.pg0, tx, self.pg0)
586 self.verify_tunneled_6o4(self.pg0, rx, tx,
587 self.pg0.local_ip4, "1.1.1.2")
592 route_tun_dst.remove_vpp_config()
593 route_via_tun.remove_vpp_config()
594 route6_via_tun.remove_vpp_config()
595 gre_if.remove_vpp_config()
597 self.pg0.unconfig_ip6()
600 """ GRE IPv6 tunnel Tests """
602 self.pg1.config_ip6()
603 self.pg1.resolve_ndp()
606 # Create an L3 GRE tunnel.
608 # - assign an IP Address
609 # - Add a route via the tunnel
611 gre_if = VppGreInterface(self,
614 gre_if.add_vpp_config()
618 route_via_tun = VppIpRoute(
619 self, "4004::1", 128,
620 [VppRoutePath("0::0",
622 proto=DpoProto.DPO_PROTO_IP6)],
625 route_via_tun.add_vpp_config()
628 # Send a packet stream that is routed into the tunnel
629 # - they are all dropped since the tunnel's destintation IP
630 # is unresolved - or resolves via the default route - which
633 tx = self.create_stream_ip6(self.pg2, "5005::1", "4004::1")
634 self.send_and_assert_no_replies(
636 "GRE packets forwarded without DIP resolved")
639 # Add a route that resolves the tunnel's destination
641 route_tun_dst = VppIpRoute(
642 self, "1002::1", 128,
643 [VppRoutePath(self.pg2.remote_ip6,
644 self.pg2.sw_if_index,
645 proto=DpoProto.DPO_PROTO_IP6)],
647 route_tun_dst.add_vpp_config()
650 # Send a packet stream that is routed into the tunnel
651 # - packets are GRE encapped
653 tx = self.create_stream_ip6(self.pg2, "5005::1", "4004::1")
654 rx = self.send_and_expect(self.pg2, tx, self.pg2)
655 self.verify_tunneled_6o6(self.pg2, rx, tx,
656 self.pg2.local_ip6, "1002::1")
659 # Test decap. decapped packets go out pg1
661 tx = self.create_tunnel_stream_6o6(self.pg2,
666 rx = self.send_and_expect(self.pg2, tx, self.pg1)
669 # RX'd packet is UDP over IPv6, test the GRE header is gone.
671 self.assertFalse(rx[0].haslayer(GRE))
672 self.assertEqual(rx[0][IPv6].dst, self.pg1.remote_ip6)
677 route4_via_tun = VppIpRoute(self, "1.1.1.1", 32,
678 [VppRoutePath("0.0.0.0",
679 gre_if.sw_if_index)])
680 route4_via_tun.add_vpp_config()
682 tx = self.create_stream_ip4(self.pg0, "1.1.1.2", "1.1.1.1")
683 rx = self.send_and_expect(self.pg0, tx, self.pg2)
685 self.verify_tunneled_4o6(self.pg0, rx, tx,
686 self.pg2.local_ip6, "1002::1")
691 route_tun_dst.remove_vpp_config()
692 route_via_tun.remove_vpp_config()
693 route4_via_tun.remove_vpp_config()
694 gre_if.remove_vpp_config()
696 self.pg2.unconfig_ip6()
697 self.pg1.unconfig_ip6()
699 def test_gre_vrf(self):
700 """ GRE tunnel VRF Tests """
703 # Create an L3 GRE tunnel whose destination is in the non-default
704 # table. The underlay is thus non-default - the overlay is still
707 # - assign an IP Addres
709 gre_if = VppGreInterface(self, self.pg1.local_ip4,
712 gre_if.add_vpp_config()
717 # Add a route via the tunnel - in the overlay
719 route_via_tun = VppIpRoute(self, "9.9.9.9", 32,
720 [VppRoutePath("0.0.0.0",
721 gre_if.sw_if_index)])
722 route_via_tun.add_vpp_config()
725 # Add a route that resolves the tunnel's destination - in the
728 route_tun_dst = VppIpRoute(self, "2.2.2.2", 32, table_id=1,
729 paths=[VppRoutePath(self.pg1.remote_ip4,
730 self.pg1.sw_if_index)])
731 route_tun_dst.add_vpp_config()
734 # Send a packet stream that is routed into the tunnel
735 # packets are sent in on pg0 which is in the default table
736 # - packets are GRE encapped
738 self.vapi.cli("clear trace")
739 tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "9.9.9.9")
740 rx = self.send_and_expect(self.pg0, tx, self.pg1)
741 self.verify_tunneled_4o4(self.pg1, rx, tx,
742 self.pg1.local_ip4, "2.2.2.2")
745 # Send tunneled packets that match the created tunnel and
746 # are decapped and forwarded. This tests the decap lookup
747 # does not happen in the encap table
749 self.vapi.cli("clear trace")
750 tx = self.create_tunnel_stream_4o4(self.pg1,
755 rx = self.send_and_expect(self.pg1, tx, self.pg0)
756 self.verify_decapped_4o4(self.pg0, rx, tx)
759 # Send tunneled packets that match the created tunnel
760 # but arrive on an interface that is not in the tunnel's
761 # encap VRF, these are dropped.
762 # IP enable the interface so they aren't dropped due to
763 # IP not being enabled.
765 self.pg2.config_ip4()
766 self.vapi.cli("clear trace")
767 tx = self.create_tunnel_stream_4o4(self.pg2,
772 rx = self.send_and_assert_no_replies(
774 "GRE decap packets in wrong VRF")
776 self.pg2.unconfig_ip4()
781 route_tun_dst.remove_vpp_config()
782 route_via_tun.remove_vpp_config()
783 gre_if.remove_vpp_config()
785 def test_gre_l2(self):
786 """ GRE tunnel L2 Tests """
789 # Add routes to resolve the tunnel destinations
791 route_tun1_dst = VppIpRoute(self, "2.2.2.2", 32,
792 [VppRoutePath(self.pg0.remote_ip4,
793 self.pg0.sw_if_index)])
794 route_tun2_dst = VppIpRoute(self, "2.2.2.3", 32,
795 [VppRoutePath(self.pg0.remote_ip4,
796 self.pg0.sw_if_index)])
798 route_tun1_dst.add_vpp_config()
799 route_tun2_dst.add_vpp_config()
802 # Create 2 L2 GRE tunnels and x-connect them
804 gre_if1 = VppGreInterface(self, self.pg0.local_ip4,
806 type=(VppEnum.vl_api_gre_tunnel_type_t.
807 GRE_API_TUNNEL_TYPE_TEB))
808 gre_if2 = VppGreInterface(self, self.pg0.local_ip4,
810 type=(VppEnum.vl_api_gre_tunnel_type_t.
811 GRE_API_TUNNEL_TYPE_TEB))
812 gre_if1.add_vpp_config()
813 gre_if2.add_vpp_config()
818 self.vapi.sw_interface_set_l2_xconnect(gre_if1.sw_if_index,
821 self.vapi.sw_interface_set_l2_xconnect(gre_if2.sw_if_index,
826 # Send in tunnel encapped L2. expect out tunnel encapped L2
829 tx = self.create_tunnel_stream_l2o4(self.pg0,
832 rx = self.send_and_expect(self.pg0, tx, self.pg0)
833 self.verify_tunneled_l2o4(self.pg0, rx, tx,
837 tx = self.create_tunnel_stream_l2o4(self.pg0,
840 rx = self.send_and_expect(self.pg0, tx, self.pg0)
841 self.verify_tunneled_l2o4(self.pg0, rx, tx,
845 self.vapi.sw_interface_set_l2_xconnect(gre_if1.sw_if_index,
848 self.vapi.sw_interface_set_l2_xconnect(gre_if2.sw_if_index,
853 # Create a VLAN sub-interfaces on the GRE TEB interfaces
854 # then x-connect them
856 gre_if_11 = VppDot1QSubint(self, gre_if1, 11)
857 gre_if_12 = VppDot1QSubint(self, gre_if2, 12)
859 # gre_if_11.add_vpp_config()
860 # gre_if_12.add_vpp_config()
865 self.vapi.sw_interface_set_l2_xconnect(gre_if_11.sw_if_index,
866 gre_if_12.sw_if_index,
868 self.vapi.sw_interface_set_l2_xconnect(gre_if_12.sw_if_index,
869 gre_if_11.sw_if_index,
873 # Configure both to pop thier respective VLAN tags,
874 # so that during the x-coonect they will subsequently push
876 self.vapi.l2_interface_vlan_tag_rewrite(
877 sw_if_index=gre_if_12.sw_if_index, vtr_op=L2_VTR_OP.L2_POP_1,
879 self.vapi.l2_interface_vlan_tag_rewrite(
880 sw_if_index=gre_if_11.sw_if_index, vtr_op=L2_VTR_OP.L2_POP_1,
884 # Send traffic in both directiond - expect the VLAN tags to
887 tx = self.create_tunnel_stream_vlano4(self.pg0,
891 rx = self.send_and_expect(self.pg0, tx, self.pg0)
892 self.verify_tunneled_vlano4(self.pg0, rx, tx,
897 tx = self.create_tunnel_stream_vlano4(self.pg0,
901 rx = self.send_and_expect(self.pg0, tx, self.pg0)
902 self.verify_tunneled_vlano4(self.pg0, rx, tx,
908 # Cleanup Test resources
910 gre_if_11.remove_vpp_config()
911 gre_if_12.remove_vpp_config()
912 gre_if1.remove_vpp_config()
913 gre_if2.remove_vpp_config()
914 route_tun1_dst.add_vpp_config()
915 route_tun2_dst.add_vpp_config()
917 def test_gre_loop(self):
918 """ GRE tunnel loop Tests """
921 # Create an L3 GRE tunnel.
923 # - assign an IP Addres
925 gre_if = VppGreInterface(self,
928 gre_if.add_vpp_config()
933 # add a route to the tunnel's destination that points
934 # through the tunnel, hence forming a loop in the forwarding
937 route_dst = VppIpRoute(self, "1.1.1.2", 32,
938 [VppRoutePath("0.0.0.0",
939 gre_if.sw_if_index)])
940 route_dst.add_vpp_config()
943 # packets to the tunnels destination should be dropped
945 tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "1.1.1.2")
946 self.send_and_assert_no_replies(self.pg2, tx)
948 self.logger.info(self.vapi.ppcli("sh adj 7"))
953 route_dst.modify([VppRoutePath(self.pg1.remote_ip4,
954 self.pg1.sw_if_index)])
955 route_dst.add_vpp_config()
957 rx = self.send_and_expect(self.pg0, tx, self.pg1)
960 # a good route throught the tunnel to check it restacked
962 route_via_tun_2 = VppIpRoute(self, "2.2.2.2", 32,
963 [VppRoutePath("0.0.0.0",
964 gre_if.sw_if_index)])
965 route_via_tun_2.add_vpp_config()
967 tx = self.create_stream_ip4(self.pg0, "2.2.2.3", "2.2.2.2")
968 rx = self.send_and_expect(self.pg0, tx, self.pg1)
969 self.verify_tunneled_4o4(self.pg1, rx, tx,
970 self.pg0.local_ip4, "1.1.1.2")
975 route_via_tun_2.remove_vpp_config()
976 gre_if.remove_vpp_config()
979 if __name__ == '__main__':
980 unittest.main(testRunner=VppTestRunner)