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