Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 2 | |
| 3 | import unittest |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 4 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 5 | import scapy.compat |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 6 | from scapy.packet import Raw |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 7 | from scapy.layers.l2 import Ether, Dot1Q, GRE |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 8 | from scapy.layers.inet import IP, UDP |
Klement Sekera | 65cc8c0 | 2016-12-18 15:49:54 +0100 | [diff] [blame] | 9 | from scapy.layers.inet6 import IPv6 |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 10 | from scapy.volatile import RandMAC, RandIP |
| 11 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 12 | from framework import VppTestCase |
| 13 | from asfframework import VppTestRunner, tag_fixme_vpp_workers |
Paul Vinciguerra | 95c0ca4 | 2019-03-28 13:07:00 -0700 | [diff] [blame] | 14 | from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint |
Neale Ranns | 5a8844b | 2019-04-16 07:15:35 +0000 | [diff] [blame] | 15 | from vpp_gre_interface import VppGreInterface |
Neale Ranns | 2828721 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 16 | from vpp_teib import VppTeib |
Paul Vinciguerra | a279d9c | 2019-02-28 09:00:09 -0800 | [diff] [blame] | 17 | from vpp_ip import DpoProto |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 18 | from vpp_ip_route import ( |
| 19 | VppIpRoute, |
| 20 | VppRoutePath, |
| 21 | VppIpTable, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 22 | VppMplsLabel, |
| 23 | ) |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 24 | from vpp_mpls_tunnel_interface import VppMPLSTunnelInterface |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 25 | from util import ppp, ppc |
Neale Ranns | 5a8844b | 2019-04-16 07:15:35 +0000 | [diff] [blame] | 26 | from vpp_papi import VppEnum |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 27 | from config import config |
John Lo | a43ccae | 2018-02-13 17:15:23 -0500 | [diff] [blame] | 28 | |
| 29 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 30 | @tag_fixme_vpp_workers |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 31 | @unittest.skipIf("gre" in config.excluded_plugins, "Exclude GRE plugin tests") |
Jakub Grajciar | f03beca | 2019-05-24 08:25:03 +0200 | [diff] [blame] | 32 | class TestGREInputNodes(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 33 | """GRE Input Nodes Test Case""" |
Jakub Grajciar | f03beca | 2019-05-24 08:25:03 +0200 | [diff] [blame] | 34 | |
| 35 | def setUp(self): |
| 36 | super(TestGREInputNodes, self).setUp() |
| 37 | |
| 38 | # create 3 pg interfaces - set one in a non-default table. |
| 39 | self.create_pg_interfaces(range(1)) |
| 40 | |
| 41 | for i in self.pg_interfaces: |
| 42 | i.admin_up() |
| 43 | i.config_ip4() |
| 44 | |
| 45 | def tearDown(self): |
| 46 | for i in self.pg_interfaces: |
| 47 | i.unconfig_ip4() |
| 48 | i.admin_down() |
| 49 | super(TestGREInputNodes, self).tearDown() |
| 50 | |
| 51 | def test_gre_input_node(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 52 | """GRE gre input nodes not registerd unless configured""" |
| 53 | pkt = ( |
| 54 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 55 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) |
| 56 | / GRE() |
| 57 | ) |
Jakub Grajciar | f03beca | 2019-05-24 08:25:03 +0200 | [diff] [blame] | 58 | |
| 59 | self.pg0.add_stream(pkt) |
| 60 | self.pg_start() |
| 61 | # no tunnel created, gre-input not registered |
Neale Ranns | e22a704 | 2022-08-09 03:03:29 +0000 | [diff] [blame] | 62 | err = self.statistics.get_counter("/err/ip4-local/unknown_protocol")[0] |
Jakub Grajciar | f03beca | 2019-05-24 08:25:03 +0200 | [diff] [blame] | 63 | self.assertEqual(err, 1) |
| 64 | err_count = err |
| 65 | |
| 66 | # create gre tunnel |
| 67 | gre_if = VppGreInterface(self, self.pg0.local_ip4, "1.1.1.2") |
| 68 | gre_if.add_vpp_config() |
| 69 | |
| 70 | self.pg0.add_stream(pkt) |
| 71 | self.pg_start() |
| 72 | # tunnel created, gre-input registered |
Neale Ranns | e22a704 | 2022-08-09 03:03:29 +0000 | [diff] [blame] | 73 | err = self.statistics.get_counter("/err/ip4-local/unknown_protocol")[0] |
Jakub Grajciar | f03beca | 2019-05-24 08:25:03 +0200 | [diff] [blame] | 74 | # expect no new errors |
| 75 | self.assertEqual(err, err_count) |
| 76 | |
| 77 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 78 | @unittest.skipIf("gre" in config.excluded_plugins, "Exclude GRE plugin tests") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 79 | class TestGRE(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 80 | """GRE Test Case""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 81 | |
| 82 | @classmethod |
| 83 | def setUpClass(cls): |
| 84 | super(TestGRE, cls).setUpClass() |
| 85 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 86 | @classmethod |
| 87 | def tearDownClass(cls): |
| 88 | super(TestGRE, cls).tearDownClass() |
| 89 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 90 | def setUp(self): |
| 91 | super(TestGRE, self).setUp() |
| 92 | |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 93 | # create 3 pg interfaces - set one in a non-default table. |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 94 | self.create_pg_interfaces(range(5)) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 95 | |
| 96 | self.tbl = VppIpTable(self, 1) |
| 97 | self.tbl.add_vpp_config() |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 98 | self.pg1.set_table_ip4(1) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 99 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 100 | for i in self.pg_interfaces: |
| 101 | i.admin_up() |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 102 | |
| 103 | self.pg0.config_ip4() |
| 104 | self.pg0.resolve_arp() |
| 105 | self.pg1.config_ip4() |
| 106 | self.pg1.resolve_arp() |
| 107 | self.pg2.config_ip6() |
| 108 | self.pg2.resolve_ndp() |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 109 | self.pg3.config_ip4() |
| 110 | self.pg3.resolve_arp() |
| 111 | self.pg4.config_ip4() |
| 112 | self.pg4.resolve_arp() |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 113 | |
| 114 | def tearDown(self): |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 115 | for i in self.pg_interfaces: |
| 116 | i.unconfig_ip4() |
| 117 | i.unconfig_ip6() |
| 118 | i.admin_down() |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 119 | self.pg1.set_table_ip4(0) |
| 120 | super(TestGRE, self).tearDown() |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 121 | |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 122 | def create_stream_ip4(self, src_if, src_ip, dst_ip, dscp=0, ecn=0): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 123 | pkts = [] |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 124 | tos = (dscp << 2) | ecn |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 125 | for i in range(0, 257): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 126 | info = self.create_packet_info(src_if, src_if) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 127 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 128 | p = ( |
| 129 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 130 | / IP(src=src_ip, dst=dst_ip, tos=tos) |
| 131 | / UDP(sport=1234, dport=1234) |
| 132 | / Raw(payload) |
| 133 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 134 | info.data = p.copy() |
| 135 | pkts.append(p) |
| 136 | return pkts |
| 137 | |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 138 | def create_stream_ip6(self, src_if, src_ip, dst_ip, dscp=0, ecn=0): |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 139 | pkts = [] |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 140 | tc = (dscp << 2) | ecn |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 141 | for i in range(0, 257): |
| 142 | info = self.create_packet_info(src_if, src_if) |
| 143 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 144 | p = ( |
| 145 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 146 | / IPv6(src=src_ip, dst=dst_ip, tc=tc) |
| 147 | / UDP(sport=1234, dport=1234) |
| 148 | / Raw(payload) |
| 149 | ) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 150 | info.data = p.copy() |
| 151 | pkts.append(p) |
| 152 | return pkts |
| 153 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 154 | def create_tunnel_stream_4o4(self, src_if, tunnel_src, tunnel_dst, src_ip, dst_ip): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 155 | pkts = [] |
| 156 | for i in range(0, 257): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 157 | info = self.create_packet_info(src_if, src_if) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 158 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 159 | p = ( |
| 160 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 161 | / IP(src=tunnel_src, dst=tunnel_dst) |
| 162 | / GRE() |
| 163 | / IP(src=src_ip, dst=dst_ip) |
| 164 | / UDP(sport=1234, dport=1234) |
| 165 | / Raw(payload) |
| 166 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 167 | info.data = p.copy() |
| 168 | pkts.append(p) |
| 169 | return pkts |
| 170 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 171 | def create_tunnel_stream_6o4(self, src_if, tunnel_src, tunnel_dst, src_ip, dst_ip): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 172 | pkts = [] |
| 173 | for i in range(0, 257): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 174 | info = self.create_packet_info(src_if, src_if) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 175 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 176 | p = ( |
| 177 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 178 | / IP(src=tunnel_src, dst=tunnel_dst) |
| 179 | / GRE() |
| 180 | / IPv6(src=src_ip, dst=dst_ip) |
| 181 | / UDP(sport=1234, dport=1234) |
| 182 | / Raw(payload) |
| 183 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 184 | info.data = p.copy() |
| 185 | pkts.append(p) |
| 186 | return pkts |
| 187 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 188 | def create_tunnel_stream_6o6(self, src_if, tunnel_src, tunnel_dst, src_ip, dst_ip): |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 189 | pkts = [] |
| 190 | for i in range(0, 257): |
| 191 | info = self.create_packet_info(src_if, src_if) |
| 192 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 193 | p = ( |
| 194 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 195 | / IPv6(src=tunnel_src, dst=tunnel_dst) |
| 196 | / GRE() |
| 197 | / IPv6(src=src_ip, dst=dst_ip) |
| 198 | / UDP(sport=1234, dport=1234) |
| 199 | / Raw(payload) |
| 200 | ) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 201 | info.data = p.copy() |
| 202 | pkts.append(p) |
| 203 | return pkts |
| 204 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 205 | def create_tunnel_stream_l2o4(self, src_if, tunnel_src, tunnel_dst): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 206 | pkts = [] |
| 207 | for i in range(0, 257): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 208 | info = self.create_packet_info(src_if, src_if) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 209 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 210 | p = ( |
| 211 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 212 | / IP(src=tunnel_src, dst=tunnel_dst) |
| 213 | / GRE() |
| 214 | / Ether(dst=RandMAC("*:*:*:*:*:*"), src=RandMAC("*:*:*:*:*:*")) |
| 215 | / IP(src=scapy.compat.raw(RandIP()), dst=scapy.compat.raw(RandIP())) |
| 216 | / UDP(sport=1234, dport=1234) |
| 217 | / Raw(payload) |
| 218 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 219 | info.data = p.copy() |
| 220 | pkts.append(p) |
| 221 | return pkts |
| 222 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 223 | def create_tunnel_stream_vlano4(self, src_if, tunnel_src, tunnel_dst, vlan): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 224 | pkts = [] |
| 225 | for i in range(0, 257): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 226 | info = self.create_packet_info(src_if, src_if) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 227 | payload = self.info_to_payload(info) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 228 | p = ( |
| 229 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) |
| 230 | / IP(src=tunnel_src, dst=tunnel_dst) |
| 231 | / GRE() |
| 232 | / Ether(dst=RandMAC("*:*:*:*:*:*"), src=RandMAC("*:*:*:*:*:*")) |
| 233 | / Dot1Q(vlan=vlan) |
| 234 | / IP(src=scapy.compat.raw(RandIP()), dst=scapy.compat.raw(RandIP())) |
| 235 | / UDP(sport=1234, dport=1234) |
| 236 | / Raw(payload) |
| 237 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 238 | info.data = p.copy() |
| 239 | pkts.append(p) |
| 240 | return pkts |
| 241 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 242 | def verify_tunneled_4o4( |
| 243 | self, src_if, capture, sent, tunnel_src, tunnel_dst, dscp=0, ecn=0 |
| 244 | ): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 245 | self.assertEqual(len(capture), len(sent)) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 246 | tos = (dscp << 2) | ecn |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 247 | |
| 248 | for i in range(len(capture)): |
| 249 | try: |
| 250 | tx = sent[i] |
| 251 | rx = capture[i] |
| 252 | |
| 253 | tx_ip = tx[IP] |
| 254 | rx_ip = rx[IP] |
| 255 | |
| 256 | self.assertEqual(rx_ip.src, tunnel_src) |
| 257 | self.assertEqual(rx_ip.dst, tunnel_dst) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 258 | self.assertEqual(rx_ip.tos, tos) |
Aloys Augustin | cf86740a | 2020-07-16 11:01:01 +0200 | [diff] [blame] | 259 | self.assertEqual(rx_ip.len, len(rx_ip)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 260 | |
| 261 | rx_gre = rx[GRE] |
| 262 | rx_ip = rx_gre[IP] |
| 263 | |
| 264 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 265 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 266 | # IP processing post pop has decremented the TTL |
| 267 | self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl) |
| 268 | |
| 269 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 270 | self.logger.error(ppp("Rx:", rx)) |
| 271 | self.logger.error(ppp("Tx:", tx)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 272 | raise |
| 273 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 274 | def verify_tunneled_6o6( |
| 275 | self, src_if, capture, sent, tunnel_src, tunnel_dst, dscp=0, ecn=0 |
| 276 | ): |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 277 | self.assertEqual(len(capture), len(sent)) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 278 | tc = (dscp << 2) | ecn |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 279 | |
| 280 | for i in range(len(capture)): |
| 281 | try: |
| 282 | tx = sent[i] |
| 283 | rx = capture[i] |
| 284 | |
| 285 | tx_ip = tx[IPv6] |
| 286 | rx_ip = rx[IPv6] |
| 287 | |
| 288 | self.assertEqual(rx_ip.src, tunnel_src) |
| 289 | self.assertEqual(rx_ip.dst, tunnel_dst) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 290 | self.assertEqual(rx_ip.tc, tc) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 291 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 292 | rx_gre = GRE(scapy.compat.raw(rx_ip[IPv6].payload)) |
Aloys Augustin | cf86740a | 2020-07-16 11:01:01 +0200 | [diff] [blame] | 293 | |
| 294 | self.assertEqual(rx_ip.plen, len(rx_gre)) |
| 295 | |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 296 | rx_ip = rx_gre[IPv6] |
| 297 | |
| 298 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 299 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 300 | |
| 301 | except: |
| 302 | self.logger.error(ppp("Rx:", rx)) |
| 303 | self.logger.error(ppp("Tx:", tx)) |
| 304 | raise |
| 305 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 306 | def verify_tunneled_4o6(self, src_if, capture, sent, tunnel_src, tunnel_dst): |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 307 | self.assertEqual(len(capture), len(sent)) |
| 308 | |
| 309 | for i in range(len(capture)): |
| 310 | try: |
| 311 | tx = sent[i] |
| 312 | rx = capture[i] |
| 313 | |
| 314 | rx_ip = rx[IPv6] |
| 315 | |
| 316 | self.assertEqual(rx_ip.src, tunnel_src) |
| 317 | self.assertEqual(rx_ip.dst, tunnel_dst) |
| 318 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 319 | rx_gre = GRE(scapy.compat.raw(rx_ip[IPv6].payload)) |
Aloys Augustin | cf86740a | 2020-07-16 11:01:01 +0200 | [diff] [blame] | 320 | |
| 321 | self.assertEqual(rx_ip.plen, len(rx_gre)) |
| 322 | |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 323 | tx_ip = tx[IP] |
| 324 | rx_ip = rx_gre[IP] |
| 325 | |
| 326 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 327 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 328 | |
| 329 | except: |
| 330 | self.logger.error(ppp("Rx:", rx)) |
| 331 | self.logger.error(ppp("Tx:", tx)) |
| 332 | raise |
| 333 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 334 | def verify_tunneled_6o4(self, src_if, capture, sent, tunnel_src, tunnel_dst): |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 335 | self.assertEqual(len(capture), len(sent)) |
| 336 | |
| 337 | for i in range(len(capture)): |
| 338 | try: |
| 339 | tx = sent[i] |
| 340 | rx = capture[i] |
| 341 | |
| 342 | rx_ip = rx[IP] |
| 343 | |
| 344 | self.assertEqual(rx_ip.src, tunnel_src) |
| 345 | self.assertEqual(rx_ip.dst, tunnel_dst) |
Aloys Augustin | cf86740a | 2020-07-16 11:01:01 +0200 | [diff] [blame] | 346 | self.assertEqual(rx_ip.len, len(rx_ip)) |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 347 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 348 | rx_gre = GRE(scapy.compat.raw(rx_ip[IP].payload)) |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 349 | rx_ip = rx_gre[IPv6] |
| 350 | tx_ip = tx[IPv6] |
| 351 | |
| 352 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 353 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 354 | |
| 355 | except: |
| 356 | self.logger.error(ppp("Rx:", rx)) |
| 357 | self.logger.error(ppp("Tx:", tx)) |
| 358 | raise |
| 359 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 360 | def verify_tunneled_l2o4(self, src_if, capture, sent, tunnel_src, tunnel_dst): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 361 | self.assertEqual(len(capture), len(sent)) |
| 362 | |
| 363 | for i in range(len(capture)): |
| 364 | try: |
| 365 | tx = sent[i] |
| 366 | rx = capture[i] |
| 367 | |
| 368 | tx_ip = tx[IP] |
| 369 | rx_ip = rx[IP] |
| 370 | |
| 371 | self.assertEqual(rx_ip.src, tunnel_src) |
| 372 | self.assertEqual(rx_ip.dst, tunnel_dst) |
Aloys Augustin | cf86740a | 2020-07-16 11:01:01 +0200 | [diff] [blame] | 373 | self.assertEqual(rx_ip.len, len(rx_ip)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 374 | |
| 375 | rx_gre = rx[GRE] |
| 376 | rx_l2 = rx_gre[Ether] |
| 377 | rx_ip = rx_l2[IP] |
| 378 | tx_gre = tx[GRE] |
| 379 | tx_l2 = tx_gre[Ether] |
| 380 | tx_ip = tx_l2[IP] |
| 381 | |
| 382 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 383 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 384 | # bridged, not L3 forwarded, so no TTL decrement |
| 385 | self.assertEqual(rx_ip.ttl, tx_ip.ttl) |
| 386 | |
| 387 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 388 | self.logger.error(ppp("Rx:", rx)) |
| 389 | self.logger.error(ppp("Tx:", tx)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 390 | raise |
| 391 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 392 | def verify_tunneled_vlano4( |
| 393 | self, src_if, capture, sent, tunnel_src, tunnel_dst, vlan |
| 394 | ): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 395 | try: |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 396 | self.assertEqual(len(capture), len(sent)) |
| 397 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 398 | ppc("Unexpected packets captured:", capture) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 399 | raise |
| 400 | |
| 401 | for i in range(len(capture)): |
| 402 | try: |
| 403 | tx = sent[i] |
| 404 | rx = capture[i] |
| 405 | |
| 406 | tx_ip = tx[IP] |
| 407 | rx_ip = rx[IP] |
| 408 | |
| 409 | self.assertEqual(rx_ip.src, tunnel_src) |
| 410 | self.assertEqual(rx_ip.dst, tunnel_dst) |
| 411 | |
| 412 | rx_gre = rx[GRE] |
| 413 | rx_l2 = rx_gre[Ether] |
| 414 | rx_vlan = rx_l2[Dot1Q] |
| 415 | rx_ip = rx_l2[IP] |
| 416 | |
| 417 | self.assertEqual(rx_vlan.vlan, vlan) |
| 418 | |
| 419 | tx_gre = tx[GRE] |
| 420 | tx_l2 = tx_gre[Ether] |
| 421 | tx_ip = tx_l2[IP] |
| 422 | |
| 423 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 424 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 425 | # bridged, not L3 forwarded, so no TTL decrement |
| 426 | self.assertEqual(rx_ip.ttl, tx_ip.ttl) |
| 427 | |
| 428 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 429 | self.logger.error(ppp("Rx:", rx)) |
| 430 | self.logger.error(ppp("Tx:", tx)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 431 | raise |
| 432 | |
| 433 | def verify_decapped_4o4(self, src_if, capture, sent): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 434 | self.assertEqual(len(capture), len(sent)) |
| 435 | |
| 436 | for i in range(len(capture)): |
| 437 | try: |
| 438 | tx = sent[i] |
| 439 | rx = capture[i] |
| 440 | |
| 441 | tx_ip = tx[IP] |
| 442 | rx_ip = rx[IP] |
| 443 | tx_gre = tx[GRE] |
| 444 | tx_ip = tx_gre[IP] |
| 445 | |
| 446 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 447 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 448 | # IP processing post pop has decremented the TTL |
| 449 | self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl) |
| 450 | |
| 451 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 452 | self.logger.error(ppp("Rx:", rx)) |
| 453 | self.logger.error(ppp("Tx:", tx)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 454 | raise |
| 455 | |
| 456 | def verify_decapped_6o4(self, src_if, capture, sent): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 457 | self.assertEqual(len(capture), len(sent)) |
| 458 | |
| 459 | for i in range(len(capture)): |
| 460 | try: |
| 461 | tx = sent[i] |
| 462 | rx = capture[i] |
| 463 | |
| 464 | tx_ip = tx[IP] |
| 465 | rx_ip = rx[IPv6] |
| 466 | tx_gre = tx[GRE] |
| 467 | tx_ip = tx_gre[IPv6] |
| 468 | |
| 469 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 470 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 471 | self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim) |
| 472 | |
| 473 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 474 | self.logger.error(ppp("Rx:", rx)) |
| 475 | self.logger.error(ppp("Tx:", tx)) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 476 | raise |
| 477 | |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 478 | def verify_decapped_6o6(self, src_if, capture, sent): |
| 479 | self.assertEqual(len(capture), len(sent)) |
| 480 | |
| 481 | for i in range(len(capture)): |
| 482 | try: |
| 483 | tx = sent[i] |
| 484 | rx = capture[i] |
| 485 | |
| 486 | tx_ip = tx[IPv6] |
| 487 | rx_ip = rx[IPv6] |
| 488 | tx_gre = tx[GRE] |
| 489 | tx_ip = tx_gre[IPv6] |
| 490 | |
| 491 | self.assertEqual(rx_ip.src, tx_ip.src) |
| 492 | self.assertEqual(rx_ip.dst, tx_ip.dst) |
| 493 | self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim) |
| 494 | |
| 495 | except: |
| 496 | self.logger.error(ppp("Rx:", rx)) |
| 497 | self.logger.error(ppp("Tx:", tx)) |
| 498 | raise |
| 499 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 500 | def test_gre(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 501 | """GRE IPv4 tunnel Tests""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 502 | |
| 503 | # |
| 504 | # Create an L3 GRE tunnel. |
| 505 | # - set it admin up |
| 506 | # - assign an IP Addres |
| 507 | # - Add a route via the tunnel |
| 508 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 509 | gre_if = VppGreInterface(self, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 510 | gre_if.add_vpp_config() |
| 511 | |
| 512 | # |
| 513 | # The double create (create the same tunnel twice) should fail, |
| 514 | # and we should still be able to use the original |
| 515 | # |
| 516 | try: |
| 517 | gre_if.add_vpp_config() |
| 518 | except Exception: |
| 519 | pass |
| 520 | else: |
| 521 | self.fail("Double GRE tunnel add does not fail") |
| 522 | |
| 523 | gre_if.admin_up() |
| 524 | gre_if.config_ip4() |
| 525 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 526 | route_via_tun = VppIpRoute( |
| 527 | self, "4.4.4.4", 32, [VppRoutePath("0.0.0.0", gre_if.sw_if_index)] |
| 528 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 529 | |
| 530 | route_via_tun.add_vpp_config() |
| 531 | |
| 532 | # |
| 533 | # Send a packet stream that is routed into the tunnel |
Jim Thompson | f324dec | 2019-04-08 03:22:21 -0500 | [diff] [blame] | 534 | # - they are all dropped since the tunnel's destintation IP |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 535 | # is unresolved - or resolves via the default route - which |
| 536 | # which is a drop. |
| 537 | # |
| 538 | tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "4.4.4.4") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 539 | |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 540 | self.send_and_assert_no_replies(self.pg0, tx) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 541 | |
| 542 | # |
| 543 | # Add a route that resolves the tunnel's destination |
| 544 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 545 | route_tun_dst = VppIpRoute( |
| 546 | self, |
| 547 | "1.1.1.2", |
| 548 | 32, |
| 549 | [VppRoutePath(self.pg0.remote_ip4, self.pg0.sw_if_index)], |
| 550 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 551 | route_tun_dst.add_vpp_config() |
| 552 | |
| 553 | # |
| 554 | # Send a packet stream that is routed into the tunnel |
| 555 | # - packets are GRE encapped |
| 556 | # |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 557 | tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "4.4.4.4") |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 558 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 559 | self.verify_tunneled_4o4(self.pg0, rx, tx, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 560 | |
| 561 | # |
| 562 | # Send tunneled packets that match the created tunnel and |
| 563 | # are decapped and forwarded |
| 564 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 565 | tx = self.create_tunnel_stream_4o4( |
| 566 | self.pg0, |
| 567 | "1.1.1.2", |
| 568 | self.pg0.local_ip4, |
| 569 | self.pg0.local_ip4, |
| 570 | self.pg0.remote_ip4, |
| 571 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 572 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 573 | self.verify_decapped_4o4(self.pg0, rx, tx) |
| 574 | |
| 575 | # |
| 576 | # Send tunneled packets that do not match the tunnel's src |
| 577 | # |
| 578 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 579 | tx = self.create_tunnel_stream_4o4( |
| 580 | self.pg0, |
| 581 | "1.1.1.3", |
| 582 | self.pg0.local_ip4, |
| 583 | self.pg0.local_ip4, |
| 584 | self.pg0.remote_ip4, |
| 585 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 586 | self.send_and_assert_no_replies( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 587 | self.pg0, tx, remark="GRE packets forwarded despite no SRC address match" |
| 588 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 589 | |
| 590 | # |
| 591 | # Configure IPv6 on the PG interface so we can route IPv6 |
| 592 | # packets |
| 593 | # |
| 594 | self.pg0.config_ip6() |
| 595 | self.pg0.resolve_ndp() |
| 596 | |
| 597 | # |
| 598 | # Send IPv6 tunnel encapslated packets |
| 599 | # - dropped since IPv6 is not enabled on the tunnel |
| 600 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 601 | tx = self.create_tunnel_stream_6o4( |
| 602 | self.pg0, |
| 603 | "1.1.1.2", |
| 604 | self.pg0.local_ip4, |
| 605 | self.pg0.local_ip6, |
| 606 | self.pg0.remote_ip6, |
| 607 | ) |
| 608 | self.send_and_assert_no_replies( |
| 609 | self.pg0, |
| 610 | tx, |
| 611 | "IPv6 GRE packets forwarded despite IPv6 not enabled on tunnel", |
| 612 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 613 | |
| 614 | # |
| 615 | # Enable IPv6 on the tunnel |
| 616 | # |
| 617 | gre_if.config_ip6() |
| 618 | |
| 619 | # |
| 620 | # Send IPv6 tunnel encapslated packets |
| 621 | # - forwarded since IPv6 is enabled on the tunnel |
| 622 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 623 | tx = self.create_tunnel_stream_6o4( |
| 624 | self.pg0, |
| 625 | "1.1.1.2", |
| 626 | self.pg0.local_ip4, |
| 627 | self.pg0.local_ip6, |
| 628 | self.pg0.remote_ip6, |
| 629 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 630 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 631 | self.verify_decapped_6o4(self.pg0, rx, tx) |
| 632 | |
| 633 | # |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 634 | # Send v6 packets for v4 encap |
| 635 | # |
| 636 | route6_via_tun = VppIpRoute( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 637 | self, |
| 638 | "2001::1", |
| 639 | 128, |
| 640 | [VppRoutePath("::", gre_if.sw_if_index, proto=DpoProto.DPO_PROTO_IP6)], |
| 641 | ) |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 642 | route6_via_tun.add_vpp_config() |
| 643 | |
| 644 | tx = self.create_stream_ip6(self.pg0, "2001::2", "2001::1") |
| 645 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
| 646 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 647 | self.verify_tunneled_6o4(self.pg0, rx, tx, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 648 | |
| 649 | # |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 650 | # add a labelled route through the tunnel |
| 651 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 652 | label_via_tun = VppIpRoute( |
| 653 | self, |
| 654 | "5.4.3.2", |
| 655 | 32, |
| 656 | [VppRoutePath("0.0.0.0", gre_if.sw_if_index, labels=[VppMplsLabel(33)])], |
| 657 | ) |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 658 | label_via_tun.add_vpp_config() |
| 659 | |
| 660 | tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "5.4.3.2") |
| 661 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 662 | self.verify_tunneled_4o4(self.pg0, rx, tx, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 663 | |
| 664 | # |
| 665 | # an MPLS tunnel over the GRE tunnel add a route through |
| 666 | # the mpls tunnel |
| 667 | # |
| 668 | mpls_tun = VppMPLSTunnelInterface( |
| 669 | self, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 670 | [ |
| 671 | VppRoutePath( |
| 672 | "0.0.0.0", |
| 673 | gre_if.sw_if_index, |
| 674 | labels=[VppMplsLabel(44), VppMplsLabel(46)], |
| 675 | ) |
| 676 | ], |
| 677 | ) |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 678 | mpls_tun.add_vpp_config() |
| 679 | mpls_tun.admin_up() |
| 680 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 681 | label_via_mpls = VppIpRoute( |
| 682 | self, |
| 683 | "5.4.3.1", |
| 684 | 32, |
| 685 | [VppRoutePath("0.0.0.0", mpls_tun.sw_if_index, labels=[VppMplsLabel(33)])], |
| 686 | ) |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 687 | label_via_mpls.add_vpp_config() |
| 688 | |
| 689 | tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "5.4.3.1") |
| 690 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 691 | self.verify_tunneled_4o4(self.pg0, rx, tx, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 692 | |
| 693 | mpls_tun_l2 = VppMPLSTunnelInterface( |
| 694 | self, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 695 | [ |
| 696 | VppRoutePath( |
| 697 | "0.0.0.0", |
| 698 | gre_if.sw_if_index, |
| 699 | labels=[VppMplsLabel(44), VppMplsLabel(46)], |
| 700 | ) |
| 701 | ], |
| 702 | is_l2=1, |
| 703 | ) |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 704 | mpls_tun_l2.add_vpp_config() |
| 705 | mpls_tun_l2.admin_up() |
| 706 | |
| 707 | # |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 708 | # test case cleanup |
| 709 | # |
| 710 | route_tun_dst.remove_vpp_config() |
| 711 | route_via_tun.remove_vpp_config() |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 712 | route6_via_tun.remove_vpp_config() |
Neale Ranns | 533bf08 | 2020-10-08 08:10:34 +0000 | [diff] [blame] | 713 | label_via_mpls.remove_vpp_config() |
| 714 | label_via_tun.remove_vpp_config() |
| 715 | mpls_tun.remove_vpp_config() |
| 716 | mpls_tun_l2.remove_vpp_config() |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 717 | gre_if.remove_vpp_config() |
| 718 | |
| 719 | self.pg0.unconfig_ip6() |
| 720 | |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 721 | def test_gre6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 722 | """GRE IPv6 tunnel Tests""" |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 723 | |
Neale Ranns | 8716e6b | 2017-12-13 02:47:27 -0800 | [diff] [blame] | 724 | self.pg1.config_ip6() |
| 725 | self.pg1.resolve_ndp() |
| 726 | |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 727 | # |
| 728 | # Create an L3 GRE tunnel. |
| 729 | # - set it admin up |
| 730 | # - assign an IP Address |
| 731 | # - Add a route via the tunnel |
| 732 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 733 | gre_if = VppGreInterface(self, self.pg2.local_ip6, "1002::1") |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 734 | gre_if.add_vpp_config() |
| 735 | gre_if.admin_up() |
| 736 | gre_if.config_ip6() |
| 737 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 738 | route_via_tun = VppIpRoute( |
| 739 | self, "4004::1", 128, [VppRoutePath("0::0", gre_if.sw_if_index)] |
| 740 | ) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 741 | |
| 742 | route_via_tun.add_vpp_config() |
| 743 | |
| 744 | # |
| 745 | # Send a packet stream that is routed into the tunnel |
Jim Thompson | f324dec | 2019-04-08 03:22:21 -0500 | [diff] [blame] | 746 | # - they are all dropped since the tunnel's destintation IP |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 747 | # is unresolved - or resolves via the default route - which |
| 748 | # which is a drop. |
| 749 | # |
| 750 | tx = self.create_stream_ip6(self.pg2, "5005::1", "4004::1") |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 751 | self.send_and_assert_no_replies( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 752 | self.pg2, tx, "GRE packets forwarded without DIP resolved" |
| 753 | ) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 754 | |
| 755 | # |
| 756 | # Add a route that resolves the tunnel's destination |
| 757 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 758 | route_tun_dst = VppIpRoute( |
| 759 | self, |
| 760 | "1002::1", |
| 761 | 128, |
| 762 | [VppRoutePath(self.pg2.remote_ip6, self.pg2.sw_if_index)], |
| 763 | ) |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 764 | route_tun_dst.add_vpp_config() |
| 765 | |
| 766 | # |
| 767 | # Send a packet stream that is routed into the tunnel |
| 768 | # - packets are GRE encapped |
| 769 | # |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 770 | tx = self.create_stream_ip6(self.pg2, "5005::1", "4004::1") |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 771 | rx = self.send_and_expect(self.pg2, tx, self.pg2) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 772 | self.verify_tunneled_6o6(self.pg2, rx, tx, self.pg2.local_ip6, "1002::1") |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 773 | |
| 774 | # |
Neale Ranns | 8716e6b | 2017-12-13 02:47:27 -0800 | [diff] [blame] | 775 | # Test decap. decapped packets go out pg1 |
| 776 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 777 | tx = self.create_tunnel_stream_6o6( |
| 778 | self.pg2, "1002::1", self.pg2.local_ip6, "2001::1", self.pg1.remote_ip6 |
| 779 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 780 | rx = self.send_and_expect(self.pg2, tx, self.pg1) |
Neale Ranns | 8716e6b | 2017-12-13 02:47:27 -0800 | [diff] [blame] | 781 | |
| 782 | # |
| 783 | # RX'd packet is UDP over IPv6, test the GRE header is gone. |
| 784 | # |
| 785 | self.assertFalse(rx[0].haslayer(GRE)) |
| 786 | self.assertEqual(rx[0][IPv6].dst, self.pg1.remote_ip6) |
| 787 | |
| 788 | # |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 789 | # Send v4 over v6 |
| 790 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 791 | route4_via_tun = VppIpRoute( |
| 792 | self, "1.1.1.1", 32, [VppRoutePath("0.0.0.0", gre_if.sw_if_index)] |
| 793 | ) |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 794 | route4_via_tun.add_vpp_config() |
| 795 | |
| 796 | tx = self.create_stream_ip4(self.pg0, "1.1.1.2", "1.1.1.1") |
| 797 | rx = self.send_and_expect(self.pg0, tx, self.pg2) |
| 798 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 799 | self.verify_tunneled_4o6(self.pg0, rx, tx, self.pg2.local_ip6, "1002::1") |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 800 | |
| 801 | # |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 802 | # test case cleanup |
| 803 | # |
| 804 | route_tun_dst.remove_vpp_config() |
| 805 | route_via_tun.remove_vpp_config() |
Neale Ranns | 2646c80 | 2018-09-19 04:55:32 -0700 | [diff] [blame] | 806 | route4_via_tun.remove_vpp_config() |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 807 | gre_if.remove_vpp_config() |
| 808 | |
| 809 | self.pg2.unconfig_ip6() |
Neale Ranns | 8716e6b | 2017-12-13 02:47:27 -0800 | [diff] [blame] | 810 | self.pg1.unconfig_ip6() |
Ciara Loftus | 7eac916 | 2016-09-30 15:47:03 +0100 | [diff] [blame] | 811 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 812 | def test_gre_vrf(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 813 | """GRE tunnel VRF Tests""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 814 | |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 815 | e = VppEnum.vl_api_tunnel_encap_decap_flags_t |
| 816 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 817 | # |
| 818 | # Create an L3 GRE tunnel whose destination is in the non-default |
| 819 | # table. The underlay is thus non-default - the overlay is still |
| 820 | # the default. |
| 821 | # - set it admin up |
| 822 | # - assign an IP Addres |
| 823 | # |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 824 | gre_if = VppGreInterface( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 825 | self, |
| 826 | self.pg1.local_ip4, |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 827 | "2.2.2.2", |
| 828 | outer_table_id=1, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 829 | flags=( |
| 830 | e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP |
| 831 | | e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN |
| 832 | ), |
| 833 | ) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 834 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 835 | gre_if.add_vpp_config() |
| 836 | gre_if.admin_up() |
| 837 | gre_if.config_ip4() |
| 838 | |
| 839 | # |
| 840 | # Add a route via the tunnel - in the overlay |
| 841 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 842 | route_via_tun = VppIpRoute( |
| 843 | self, "9.9.9.9", 32, [VppRoutePath("0.0.0.0", gre_if.sw_if_index)] |
| 844 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 845 | route_via_tun.add_vpp_config() |
| 846 | |
| 847 | # |
| 848 | # Add a route that resolves the tunnel's destination - in the |
| 849 | # underlay table |
| 850 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 851 | route_tun_dst = VppIpRoute( |
| 852 | self, |
| 853 | "2.2.2.2", |
| 854 | 32, |
| 855 | table_id=1, |
| 856 | paths=[VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)], |
| 857 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 858 | route_tun_dst.add_vpp_config() |
| 859 | |
| 860 | # |
| 861 | # Send a packet stream that is routed into the tunnel |
| 862 | # packets are sent in on pg0 which is in the default table |
| 863 | # - packets are GRE encapped |
| 864 | # |
| 865 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 866 | tx = self.create_stream_ip4(self.pg0, "5.5.5.5", "9.9.9.9", dscp=5, ecn=3) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 867 | rx = self.send_and_expect(self.pg0, tx, self.pg1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 868 | self.verify_tunneled_4o4( |
| 869 | self.pg1, rx, tx, self.pg1.local_ip4, "2.2.2.2", dscp=5, ecn=3 |
| 870 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 871 | |
| 872 | # |
| 873 | # Send tunneled packets that match the created tunnel and |
| 874 | # are decapped and forwarded. This tests the decap lookup |
| 875 | # does not happen in the encap table |
| 876 | # |
| 877 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 878 | tx = self.create_tunnel_stream_4o4( |
| 879 | self.pg1, |
| 880 | "2.2.2.2", |
| 881 | self.pg1.local_ip4, |
| 882 | self.pg0.local_ip4, |
| 883 | self.pg0.remote_ip4, |
| 884 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 885 | rx = self.send_and_expect(self.pg1, tx, self.pg0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 886 | self.verify_decapped_4o4(self.pg0, rx, tx) |
| 887 | |
| 888 | # |
Neale Ranns | 743ee3e | 2018-11-29 08:24:38 +0000 | [diff] [blame] | 889 | # Send tunneled packets that match the created tunnel |
Neale Ranns | 33ce60d | 2017-12-14 08:51:32 -0800 | [diff] [blame] | 890 | # but arrive on an interface that is not in the tunnel's |
Neale Ranns | 743ee3e | 2018-11-29 08:24:38 +0000 | [diff] [blame] | 891 | # encap VRF, these are dropped. |
| 892 | # IP enable the interface so they aren't dropped due to |
| 893 | # IP not being enabled. |
Neale Ranns | 33ce60d | 2017-12-14 08:51:32 -0800 | [diff] [blame] | 894 | # |
Neale Ranns | 743ee3e | 2018-11-29 08:24:38 +0000 | [diff] [blame] | 895 | self.pg2.config_ip4() |
Neale Ranns | 33ce60d | 2017-12-14 08:51:32 -0800 | [diff] [blame] | 896 | self.vapi.cli("clear trace") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 897 | tx = self.create_tunnel_stream_4o4( |
| 898 | self.pg2, |
| 899 | "2.2.2.2", |
| 900 | self.pg1.local_ip4, |
| 901 | self.pg0.local_ip4, |
| 902 | self.pg0.remote_ip4, |
| 903 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 904 | rx = self.send_and_assert_no_replies( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 905 | self.pg2, tx, "GRE decap packets in wrong VRF" |
| 906 | ) |
Neale Ranns | 33ce60d | 2017-12-14 08:51:32 -0800 | [diff] [blame] | 907 | |
Neale Ranns | 743ee3e | 2018-11-29 08:24:38 +0000 | [diff] [blame] | 908 | self.pg2.unconfig_ip4() |
| 909 | |
Neale Ranns | 33ce60d | 2017-12-14 08:51:32 -0800 | [diff] [blame] | 910 | # |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 911 | # test case cleanup |
| 912 | # |
| 913 | route_tun_dst.remove_vpp_config() |
| 914 | route_via_tun.remove_vpp_config() |
| 915 | gre_if.remove_vpp_config() |
| 916 | |
| 917 | def test_gre_l2(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 918 | """GRE tunnel L2 Tests""" |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 919 | |
| 920 | # |
| 921 | # Add routes to resolve the tunnel destinations |
| 922 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 923 | route_tun1_dst = VppIpRoute( |
| 924 | self, |
| 925 | "2.2.2.2", |
| 926 | 32, |
| 927 | [VppRoutePath(self.pg0.remote_ip4, self.pg0.sw_if_index)], |
| 928 | ) |
| 929 | route_tun2_dst = VppIpRoute( |
| 930 | self, |
| 931 | "2.2.2.3", |
| 932 | 32, |
| 933 | [VppRoutePath(self.pg0.remote_ip4, self.pg0.sw_if_index)], |
| 934 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 935 | |
| 936 | route_tun1_dst.add_vpp_config() |
| 937 | route_tun2_dst.add_vpp_config() |
| 938 | |
| 939 | # |
| 940 | # Create 2 L2 GRE tunnels and x-connect them |
| 941 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 942 | gre_if1 = VppGreInterface( |
| 943 | self, |
| 944 | self.pg0.local_ip4, |
| 945 | "2.2.2.2", |
| 946 | type=(VppEnum.vl_api_gre_tunnel_type_t.GRE_API_TUNNEL_TYPE_TEB), |
| 947 | ) |
| 948 | gre_if2 = VppGreInterface( |
| 949 | self, |
| 950 | self.pg0.local_ip4, |
| 951 | "2.2.2.3", |
| 952 | type=(VppEnum.vl_api_gre_tunnel_type_t.GRE_API_TUNNEL_TYPE_TEB), |
| 953 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 954 | gre_if1.add_vpp_config() |
| 955 | gre_if2.add_vpp_config() |
| 956 | |
| 957 | gre_if1.admin_up() |
| 958 | gre_if2.admin_up() |
| 959 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 960 | self.vapi.sw_interface_set_l2_xconnect( |
| 961 | gre_if1.sw_if_index, gre_if2.sw_if_index, enable=1 |
| 962 | ) |
| 963 | self.vapi.sw_interface_set_l2_xconnect( |
| 964 | gre_if2.sw_if_index, gre_if1.sw_if_index, enable=1 |
| 965 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 966 | |
| 967 | # |
| 968 | # Send in tunnel encapped L2. expect out tunnel encapped L2 |
| 969 | # in both directions |
| 970 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 971 | tx = self.create_tunnel_stream_l2o4(self.pg0, "2.2.2.2", self.pg0.local_ip4) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 972 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 973 | self.verify_tunneled_l2o4(self.pg0, rx, tx, self.pg0.local_ip4, "2.2.2.3") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 974 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 975 | tx = self.create_tunnel_stream_l2o4(self.pg0, "2.2.2.3", self.pg0.local_ip4) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 976 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 977 | self.verify_tunneled_l2o4(self.pg0, rx, tx, self.pg0.local_ip4, "2.2.2.2") |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 978 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 979 | self.vapi.sw_interface_set_l2_xconnect( |
| 980 | gre_if1.sw_if_index, gre_if2.sw_if_index, enable=0 |
| 981 | ) |
| 982 | self.vapi.sw_interface_set_l2_xconnect( |
| 983 | gre_if2.sw_if_index, gre_if1.sw_if_index, enable=0 |
| 984 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 985 | |
| 986 | # |
| 987 | # Create a VLAN sub-interfaces on the GRE TEB interfaces |
| 988 | # then x-connect them |
| 989 | # |
| 990 | gre_if_11 = VppDot1QSubint(self, gre_if1, 11) |
| 991 | gre_if_12 = VppDot1QSubint(self, gre_if2, 12) |
| 992 | |
| 993 | # gre_if_11.add_vpp_config() |
| 994 | # gre_if_12.add_vpp_config() |
| 995 | |
| 996 | gre_if_11.admin_up() |
| 997 | gre_if_12.admin_up() |
| 998 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 999 | self.vapi.sw_interface_set_l2_xconnect( |
| 1000 | gre_if_11.sw_if_index, gre_if_12.sw_if_index, enable=1 |
| 1001 | ) |
| 1002 | self.vapi.sw_interface_set_l2_xconnect( |
| 1003 | gre_if_12.sw_if_index, gre_if_11.sw_if_index, enable=1 |
| 1004 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1005 | |
| 1006 | # |
| 1007 | # Configure both to pop thier respective VLAN tags, |
| 1008 | # so that during the x-coonect they will subsequently push |
| 1009 | # |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 1010 | self.vapi.l2_interface_vlan_tag_rewrite( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1011 | sw_if_index=gre_if_12.sw_if_index, vtr_op=L2_VTR_OP.L2_POP_1, push_dot1q=12 |
| 1012 | ) |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 1013 | self.vapi.l2_interface_vlan_tag_rewrite( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1014 | sw_if_index=gre_if_11.sw_if_index, vtr_op=L2_VTR_OP.L2_POP_1, push_dot1q=11 |
| 1015 | ) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1016 | |
| 1017 | # |
| 1018 | # Send traffic in both directiond - expect the VLAN tags to |
| 1019 | # be swapped. |
| 1020 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1021 | tx = self.create_tunnel_stream_vlano4( |
| 1022 | self.pg0, "2.2.2.2", self.pg0.local_ip4, 11 |
| 1023 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 1024 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1025 | self.verify_tunneled_vlano4(self.pg0, rx, tx, self.pg0.local_ip4, "2.2.2.3", 12) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1026 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1027 | tx = self.create_tunnel_stream_vlano4( |
| 1028 | self.pg0, "2.2.2.3", self.pg0.local_ip4, 12 |
| 1029 | ) |
Neale Ranns | 5588225 | 2018-11-29 08:48:37 +0000 | [diff] [blame] | 1030 | rx = self.send_and_expect(self.pg0, tx, self.pg0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1031 | self.verify_tunneled_vlano4(self.pg0, rx, tx, self.pg0.local_ip4, "2.2.2.2", 11) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1032 | |
| 1033 | # |
| 1034 | # Cleanup Test resources |
| 1035 | # |
| 1036 | gre_if_11.remove_vpp_config() |
| 1037 | gre_if_12.remove_vpp_config() |
| 1038 | gre_if1.remove_vpp_config() |
| 1039 | gre_if2.remove_vpp_config() |
| 1040 | route_tun1_dst.add_vpp_config() |
| 1041 | route_tun2_dst.add_vpp_config() |
| 1042 | |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1043 | def test_gre_loop(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1044 | """GRE tunnel loop Tests""" |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1045 | |
| 1046 | # |
| 1047 | # Create an L3 GRE tunnel. |
| 1048 | # - set it admin up |
| 1049 | # - assign an IP Addres |
| 1050 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1051 | gre_if = VppGreInterface(self, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1052 | gre_if.add_vpp_config() |
| 1053 | gre_if.admin_up() |
| 1054 | gre_if.config_ip4() |
| 1055 | |
| 1056 | # |
| 1057 | # add a route to the tunnel's destination that points |
| 1058 | # through the tunnel, hence forming a loop in the forwarding |
| 1059 | # graph |
| 1060 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1061 | route_dst = VppIpRoute( |
| 1062 | self, "1.1.1.2", 32, [VppRoutePath("0.0.0.0", gre_if.sw_if_index)] |
| 1063 | ) |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1064 | route_dst.add_vpp_config() |
| 1065 | |
| 1066 | # |
| 1067 | # packets to the tunnels destination should be dropped |
| 1068 | # |
| 1069 | tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "1.1.1.2") |
| 1070 | self.send_and_assert_no_replies(self.pg2, tx) |
| 1071 | |
| 1072 | self.logger.info(self.vapi.ppcli("sh adj 7")) |
| 1073 | |
| 1074 | # |
| 1075 | # break the loop |
| 1076 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1077 | route_dst.modify([VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)]) |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1078 | route_dst.add_vpp_config() |
| 1079 | |
| 1080 | rx = self.send_and_expect(self.pg0, tx, self.pg1) |
| 1081 | |
| 1082 | # |
| 1083 | # a good route throught the tunnel to check it restacked |
| 1084 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1085 | route_via_tun_2 = VppIpRoute( |
| 1086 | self, "2.2.2.2", 32, [VppRoutePath("0.0.0.0", gre_if.sw_if_index)] |
| 1087 | ) |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1088 | route_via_tun_2.add_vpp_config() |
| 1089 | |
| 1090 | tx = self.create_stream_ip4(self.pg0, "2.2.2.3", "2.2.2.2") |
| 1091 | rx = self.send_and_expect(self.pg0, tx, self.pg1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1092 | self.verify_tunneled_4o4(self.pg1, rx, tx, self.pg0.local_ip4, "1.1.1.2") |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 1093 | |
| 1094 | # |
| 1095 | # cleanup |
| 1096 | # |
| 1097 | route_via_tun_2.remove_vpp_config() |
| 1098 | gre_if.remove_vpp_config() |
| 1099 | |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1100 | def test_mgre(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1101 | """mGRE IPv4 tunnel Tests""" |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1102 | |
| 1103 | for itf in self.pg_interfaces[3:]: |
| 1104 | # |
| 1105 | # one underlay nh for each overlay/tunnel peer |
| 1106 | # |
| 1107 | itf.generate_remote_hosts(4) |
| 1108 | itf.configure_ipv4_neighbors() |
| 1109 | |
| 1110 | # |
| 1111 | # Create an L3 GRE tunnel. |
| 1112 | # - set it admin up |
| 1113 | # - assign an IP Addres |
| 1114 | # - Add a route via the tunnel |
| 1115 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1116 | gre_if = VppGreInterface( |
| 1117 | self, |
| 1118 | itf.local_ip4, |
| 1119 | "0.0.0.0", |
| 1120 | mode=(VppEnum.vl_api_tunnel_mode_t.TUNNEL_API_MODE_MP), |
| 1121 | ) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1122 | gre_if.add_vpp_config() |
| 1123 | gre_if.admin_up() |
| 1124 | gre_if.config_ip4() |
| 1125 | gre_if.generate_remote_hosts(4) |
| 1126 | |
Neale Ranns | 3fd9904 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1127 | self.logger.info(self.vapi.cli("sh adj")) |
| 1128 | self.logger.info(self.vapi.cli("sh ip fib")) |
| 1129 | |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1130 | # |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1131 | # ensure we don't match to the tunnel if the source address |
| 1132 | # is all zeros |
| 1133 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1134 | tx = self.create_tunnel_stream_4o4( |
| 1135 | self.pg0, |
| 1136 | "0.0.0.0", |
| 1137 | itf.local_ip4, |
| 1138 | self.pg0.local_ip4, |
| 1139 | self.pg0.remote_ip4, |
| 1140 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1141 | self.send_and_assert_no_replies(self.pg0, tx) |
| 1142 | |
| 1143 | # |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1144 | # for-each peer |
| 1145 | # |
| 1146 | for ii in range(1, 4): |
| 1147 | route_addr = "4.4.4.%d" % ii |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1148 | tx_e = self.create_stream_ip4(self.pg0, "5.5.5.5", route_addr) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1149 | |
| 1150 | # |
| 1151 | # route traffic via the peer |
| 1152 | # |
| 1153 | route_via_tun = VppIpRoute( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1154 | self, |
| 1155 | route_addr, |
| 1156 | 32, |
| 1157 | [VppRoutePath(gre_if._remote_hosts[ii].ip4, gre_if.sw_if_index)], |
| 1158 | ) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1159 | route_via_tun.add_vpp_config() |
| 1160 | |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1161 | # all packets dropped at this point |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1162 | rx = self.send_and_assert_no_replies(self.pg0, tx_e) |
| 1163 | |
| 1164 | gre_if.admin_down() |
| 1165 | gre_if.admin_up() |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1166 | rx = self.send_and_assert_no_replies(self.pg0, tx_e) |
| 1167 | |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1168 | # |
Neale Ranns | 2828721 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1169 | # Add a TEIB entry resolves the peer |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1170 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1171 | teib = VppTeib( |
| 1172 | self, |
| 1173 | gre_if, |
| 1174 | gre_if._remote_hosts[ii].ip4, |
| 1175 | itf._remote_hosts[ii].ip4, |
| 1176 | ) |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1177 | teib.add_vpp_config() |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1178 | |
| 1179 | # |
| 1180 | # Send a packet stream that is routed into the tunnel |
| 1181 | # - packets are GRE encapped |
| 1182 | # |
Neale Ranns | f2b6b9e | 2021-04-27 13:54:46 +0000 | [diff] [blame] | 1183 | rx = self.send_and_expect(self.pg0, tx_e, itf) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1184 | self.verify_tunneled_4o4( |
| 1185 | self.pg0, rx, tx_e, itf.local_ip4, itf._remote_hosts[ii].ip4 |
| 1186 | ) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1187 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1188 | tx_i = self.create_tunnel_stream_4o4( |
| 1189 | self.pg0, |
| 1190 | itf._remote_hosts[ii].ip4, |
| 1191 | itf.local_ip4, |
| 1192 | self.pg0.local_ip4, |
| 1193 | self.pg0.remote_ip4, |
| 1194 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1195 | rx = self.send_and_expect(self.pg0, tx_i, self.pg0) |
| 1196 | self.verify_decapped_4o4(self.pg0, rx, tx_i) |
| 1197 | |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1198 | # |
Neale Ranns | 2828721 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1199 | # delete and re-add the TEIB |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1200 | # |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1201 | teib.remove_vpp_config() |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1202 | self.send_and_assert_no_replies(self.pg0, tx_e) |
| 1203 | self.send_and_assert_no_replies(self.pg0, tx_i) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1204 | |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1205 | teib.add_vpp_config() |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1206 | rx = self.send_and_expect(self.pg0, tx_e, itf) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1207 | self.verify_tunneled_4o4( |
| 1208 | self.pg0, rx, tx_e, itf.local_ip4, itf._remote_hosts[ii].ip4 |
| 1209 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1210 | rx = self.send_and_expect(self.pg0, tx_i, self.pg0) |
| 1211 | self.verify_decapped_4o4(self.pg0, rx, tx_i) |
Neale Ranns | 5f8f617 | 2019-04-18 10:23:56 +0000 | [diff] [blame] | 1212 | |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1213 | # |
| 1214 | # bounce the interface state and try packets again |
| 1215 | # |
| 1216 | gre_if.admin_down() |
| 1217 | gre_if.admin_up() |
| 1218 | rx = self.send_and_expect(self.pg0, tx_e, itf) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1219 | self.verify_tunneled_4o4( |
| 1220 | self.pg0, rx, tx_e, itf.local_ip4, itf._remote_hosts[ii].ip4 |
| 1221 | ) |
Neale Ranns | bd8e43d | 2021-03-15 14:42:30 +0000 | [diff] [blame] | 1222 | rx = self.send_and_expect(self.pg0, tx_i, self.pg0) |
| 1223 | self.verify_decapped_4o4(self.pg0, rx, tx_i) |
| 1224 | |
Neale Ranns | 3fd9904 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1225 | gre_if.admin_down() |
| 1226 | gre_if.unconfig_ip4() |
| 1227 | |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1228 | def test_mgre6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1229 | """mGRE IPv6 tunnel Tests""" |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1230 | |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1231 | self.pg0.config_ip6() |
| 1232 | self.pg0.resolve_ndp() |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1233 | |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 1234 | e = VppEnum.vl_api_tunnel_encap_decap_flags_t |
| 1235 | |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1236 | for itf in self.pg_interfaces[3:]: |
| 1237 | # |
| 1238 | # one underlay nh for each overlay/tunnel peer |
| 1239 | # |
| 1240 | itf.config_ip6() |
| 1241 | itf.generate_remote_hosts(4) |
| 1242 | itf.configure_ipv6_neighbors() |
| 1243 | |
| 1244 | # |
| 1245 | # Create an L3 GRE tunnel. |
| 1246 | # - set it admin up |
| 1247 | # - assign an IP Addres |
| 1248 | # - Add a route via the tunnel |
| 1249 | # |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 1250 | gre_if = VppGreInterface( |
| 1251 | self, |
| 1252 | itf.local_ip6, |
| 1253 | "::", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1254 | mode=(VppEnum.vl_api_tunnel_mode_t.TUNNEL_API_MODE_MP), |
| 1255 | flags=e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP, |
| 1256 | ) |
Neale Ranns | e5b94dd | 2019-12-31 05:13:14 +0000 | [diff] [blame] | 1257 | |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1258 | gre_if.add_vpp_config() |
| 1259 | gre_if.admin_up() |
| 1260 | gre_if.config_ip6() |
| 1261 | gre_if.generate_remote_hosts(4) |
| 1262 | |
| 1263 | # |
| 1264 | # for-each peer |
| 1265 | # |
| 1266 | for ii in range(1, 4): |
| 1267 | route_addr = "4::%d" % ii |
| 1268 | |
| 1269 | # |
Neale Ranns | 2828721 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1270 | # Add a TEIB entry resolves the peer |
Neale Ranns | 14053c9 | 2019-12-29 23:55:18 +0000 | [diff] [blame] | 1271 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1272 | teib = VppTeib( |
| 1273 | self, |
| 1274 | gre_if, |
| 1275 | gre_if._remote_hosts[ii].ip6, |
| 1276 | itf._remote_hosts[ii].ip6, |
| 1277 | ) |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1278 | teib.add_vpp_config() |
Neale Ranns | 14053c9 | 2019-12-29 23:55:18 +0000 | [diff] [blame] | 1279 | |
| 1280 | # |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1281 | # route traffic via the peer |
| 1282 | # |
| 1283 | route_via_tun = VppIpRoute( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1284 | self, |
| 1285 | route_addr, |
| 1286 | 128, |
| 1287 | [VppRoutePath(gre_if._remote_hosts[ii].ip6, gre_if.sw_if_index)], |
| 1288 | ) |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1289 | route_via_tun.add_vpp_config() |
| 1290 | |
| 1291 | # |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1292 | # Send a packet stream that is routed into the tunnel |
| 1293 | # - packets are GRE encapped |
| 1294 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1295 | tx_e = self.create_stream_ip6( |
| 1296 | self.pg0, "5::5", route_addr, dscp=2, ecn=1 |
| 1297 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1298 | rx = self.send_and_expect(self.pg0, tx_e, itf) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1299 | self.verify_tunneled_6o6( |
| 1300 | self.pg0, rx, tx_e, itf.local_ip6, itf._remote_hosts[ii].ip6, dscp=2 |
| 1301 | ) |
| 1302 | tx_i = self.create_tunnel_stream_6o6( |
| 1303 | self.pg0, |
| 1304 | itf._remote_hosts[ii].ip6, |
| 1305 | itf.local_ip6, |
| 1306 | self.pg0.local_ip6, |
| 1307 | self.pg0.remote_ip6, |
| 1308 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1309 | rx = self.send_and_expect(self.pg0, tx_i, self.pg0) |
| 1310 | self.verify_decapped_6o6(self.pg0, rx, tx_i) |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1311 | |
| 1312 | # |
Neale Ranns | 2828721 | 2019-12-16 00:53:11 +0000 | [diff] [blame] | 1313 | # delete and re-add the TEIB |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1314 | # |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1315 | teib.remove_vpp_config() |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1316 | self.send_and_assert_no_replies(self.pg0, tx_e) |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1317 | |
Neale Ranns | 03ce462 | 2020-02-03 10:55:09 +0000 | [diff] [blame] | 1318 | teib.add_vpp_config() |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1319 | rx = self.send_and_expect(self.pg0, tx_e, itf) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1320 | self.verify_tunneled_6o6( |
| 1321 | self.pg0, rx, tx_e, itf.local_ip6, itf._remote_hosts[ii].ip6, dscp=2 |
| 1322 | ) |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1323 | rx = self.send_and_expect(self.pg0, tx_i, self.pg0) |
| 1324 | self.verify_decapped_6o6(self.pg0, rx, tx_i) |
| 1325 | |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1326 | gre_if.admin_down() |
| 1327 | gre_if.unconfig_ip4() |
| 1328 | itf.unconfig_ip6() |
Neale Ranns | 4c16d80 | 2019-12-17 20:15:03 +0000 | [diff] [blame] | 1329 | self.pg0.unconfig_ip6() |
Neale Ranns | e11dce2 | 2019-12-17 00:14:26 +0000 | [diff] [blame] | 1330 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1331 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1332 | if __name__ == "__main__": |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1333 | unittest.main(testRunner=VppTestRunner) |