blob: 70ff1fc87695666d53b1db2be008b2eb8e3482d1 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Ole Troan46c1c112018-03-14 20:39:40 +01002""" 6RD RFC5969 functional tests """
Ole Troan6ee40512018-02-12 18:14:39 +01003
4import unittest
Ole Troan46c1c112018-03-14 20:39:40 +01005from scapy.layers.inet import IP, UDP, Ether
Ole Troan6ee40512018-02-12 18:14:39 +01006from scapy.layers.inet6 import IPv6
Ole Troan6ee40512018-02-12 18:14:39 +01007from scapy.packet import Raw
Ole Troan46c1c112018-03-14 20:39:40 +01008from framework import VppTestCase, VppTestRunner
Neale Rannsc0a93142018-09-05 15:42:26 -07009from vpp_ip import DpoProto
Neale Ranns097fa662018-05-01 05:17:55 -070010from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
Ole Troan46c1c112018-03-14 20:39:40 +010011from socket import AF_INET, AF_INET6, inet_pton
Ole Troan6ee40512018-02-12 18:14:39 +010012
13""" Test6rd is a subclass of VPPTestCase classes.
14
156RD tests.
16
17"""
18
19
20class Test6RD(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020021 """6RD Test Case"""
Ole Troan6ee40512018-02-12 18:14:39 +010022
23 @classmethod
24 def setUpClass(cls):
25 super(Test6RD, cls).setUpClass()
Neale Ranns61502112018-08-22 00:21:14 -070026 cls.create_pg_interfaces(range(4))
Ole Troan46c1c112018-03-14 20:39:40 +010027 cls.interfaces = list(cls.pg_interfaces)
Ole Troan6ee40512018-02-12 18:14:39 +010028
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070029 @classmethod
30 def tearDownClass(cls):
31 super(Test6RD, cls).tearDownClass()
32
Neale Ranns61502112018-08-22 00:21:14 -070033 def setUp(self):
34 super(Test6RD, self).setUp()
35 t4 = VppIpTable(self, 10)
36 t6 = VppIpTable(self, 20, True)
37
38 t4.add_vpp_config()
39 t6.add_vpp_config()
40
41 for n in range(4):
42 i = self.pg_interfaces[n]
Ole Troan46c1c112018-03-14 20:39:40 +010043 i.admin_up()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020044 if n > 1:
Neale Ranns61502112018-08-22 00:21:14 -070045 i.set_table_ip4(10)
46 i.set_table_ip6(20)
Ole Troan46c1c112018-03-14 20:39:40 +010047 i.config_ip4()
48 i.config_ip6()
49 i.disable_ipv6_ra()
50 i.resolve_arp()
51 i.resolve_ndp()
Ole Troan6ee40512018-02-12 18:14:39 +010052
53 def tearDown(self):
Neale Ranns61502112018-08-22 00:21:14 -070054 for i in self.pg_interfaces:
55 i.unconfig_ip4()
56 i.unconfig_ip6()
57 i.set_table_ip4(0)
58 i.set_table_ip6(0)
Neale Rannscbe25aa2019-09-30 10:53:31 +000059 i.admin_down()
Ole Troan6ee40512018-02-12 18:14:39 +010060 super(Test6RD, self).tearDown()
Ole Troan6ee40512018-02-12 18:14:39 +010061
62 def validate_6in4(self, rx, expected):
63 if IP not in rx:
64 self.fail()
65 if IPv6 not in rx:
66 self.fail()
67
68 self.assertEqual(rx[IP].src, expected[IP].src)
69 self.assertEqual(rx[IP].dst, expected[IP].dst)
70 self.assertEqual(rx[IP].proto, expected[IP].proto)
71 self.assertEqual(rx[IPv6].src, expected[IPv6].src)
72 self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
73
74 def validate_4in6(self, rx, expected):
75 if IPv6 not in rx:
76 self.fail()
77 if IP in rx:
78 self.fail()
79
Paul Vinciguerra3d2df212018-11-24 23:19:53 -080080 self.assertEqual(rx[IPv6].src, expected[IPv6].src)
81 self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
82 self.assertEqual(rx[IPv6].nh, expected[IPv6].nh)
Ole Troan6ee40512018-02-12 18:14:39 +010083
84 def payload(self, len):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020085 return "x" * len
Ole Troan6ee40512018-02-12 18:14:39 +010086
87 def test_6rd_ip6_to_ip4(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020088 """ip6 -> ip4 (encap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +010089 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020090 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh="UDP")
Ole Troan6ee40512018-02-12 18:14:39 +010091
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020092 rv = self.vapi.ipip_6rd_add_tunnel(
93 ip6_table_id=0,
94 ip4_table_id=0,
95 ip6_prefix="2002::/16",
96 ip4_prefix="0.0.0.0/0",
97 ip4_src=self.pg0.local_ip4,
98 security_check=True,
99 )
Ole Troan288e0932019-05-29 12:30:05 +0200100
Ole Troan6ee40512018-02-12 18:14:39 +0100101 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100102
Ole Troan6ee40512018-02-12 18:14:39 +0100103 self.vapi.cli("show ip6 fib")
104 p_payload = UDP(sport=1234, dport=1234)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200105 p = p_ether / p_ip6 / p_payload
Ole Troan6ee40512018-02-12 18:14:39 +0100106
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200107 p_reply = (
108 IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
109 )
Ole Troan6ee40512018-02-12 18:14:39 +0100110
Ole Troan9a475372019-03-05 16:58:24 +0100111 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100112 for p in rx:
113 self.validate_6in4(p, p_reply)
114
115 # MTU tests (default is 1480)
116 plen = 1481 - 40 - 8
117 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1")
118 p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200119 p = p_ether / p_ip6 / p_payload
Ole Troan6ee40512018-02-12 18:14:39 +0100120
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200121 p_reply = (
122 IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
123 )
Ole Troan6ee40512018-02-12 18:14:39 +0100124
Ole Troan9a475372019-03-05 16:58:24 +0100125 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700126 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
127
128 def test_6rd_ip6_to_ip4_vrf(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200129 """ip6 -> ip4 (encap) 6rd VRF test"""
Neale Ranns61502112018-08-22 00:21:14 -0700130 p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200131 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh="UDP")
Neale Ranns61502112018-08-22 00:21:14 -0700132
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200133 rv = self.vapi.ipip_6rd_add_tunnel(
134 ip6_table_id=20,
135 ip4_table_id=10,
136 ip6_prefix="2002::/16",
137 ip4_prefix="0.0.0.0/0",
138 ip4_src=self.pg2.local_ip4,
139 security_check=True,
140 )
Neale Ranns61502112018-08-22 00:21:14 -0700141 self.tunnel_index = rv.sw_if_index
142
143 self.vapi.cli("show ip6 fib")
144 p_payload = UDP(sport=1234, dport=1234)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200145 p = p_ether / p_ip6 / p_payload
Neale Ranns61502112018-08-22 00:21:14 -0700146
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200147 p_reply = (
148 IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
149 )
Neale Ranns61502112018-08-22 00:21:14 -0700150
Ole Troan9a475372019-03-05 16:58:24 +0100151 rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
Neale Ranns61502112018-08-22 00:21:14 -0700152 for p in rx:
153 self.validate_6in4(p, p_reply)
154
155 # MTU tests (default is 1480)
156 plen = 1481 - 40 - 8
157 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1")
158 p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200159 p = p_ether / p_ip6 / p_payload
Neale Ranns61502112018-08-22 00:21:14 -0700160
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200161 p_reply = (
162 IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
163 )
Neale Ranns61502112018-08-22 00:21:14 -0700164
Ole Troan9a475372019-03-05 16:58:24 +0100165 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700166 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100167
168 def test_6rd_ip4_to_ip6(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200169 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100170
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200171 rv = self.vapi.ipip_6rd_add_tunnel(
172 ip6_table_id=0,
173 ip4_table_id=0,
174 ip6_prefix="2002::/16",
175 ip4_prefix="0.0.0.0/0",
176 ip4_src=self.pg0.local_ip4,
177 security_check=True,
178 )
Ole Troan6ee40512018-02-12 18:14:39 +0100179 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100180 rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200181 rv = self.vapi.ipip_6rd_add_tunnel(
182 ip6_table_id=0,
183 ip4_table_id=0,
184 ip6_prefix="2002::/16",
185 ip4_prefix="0.0.0.0/0",
186 ip4_src=self.pg0.local_ip4,
187 security_check=True,
188 )
Ole Troan298c6952018-03-08 12:30:43 +0100189 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100190
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200191 p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
192 sport=1234, dport=1234
193 )
Ole Troan6ee40512018-02-12 18:14:39 +0100194
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200195 p = (
196 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
197 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
198 / p_ip6
199 )
Ole Troan6ee40512018-02-12 18:14:39 +0100200
201 p_reply = p_ip6
202
Ole Troan9a475372019-03-05 16:58:24 +0100203 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100204 for p in rx:
205 self.validate_4in6(p, p_reply)
Neale Ranns61502112018-08-22 00:21:14 -0700206 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
207
208 def test_6rd_ip4_to_ip6_vrf(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200209 """ip4 -> ip6 (decap) 6rd VRF test"""
Neale Ranns61502112018-08-22 00:21:14 -0700210
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200211 rv = self.vapi.ipip_6rd_add_tunnel(
212 ip6_table_id=20,
213 ip4_table_id=10,
214 ip6_prefix="2002::/16",
215 ip4_prefix="0.0.0.0/0",
216 ip4_src=self.pg2.local_ip4,
217 security_check=True,
218 )
Neale Ranns61502112018-08-22 00:21:14 -0700219 self.tunnel_index = rv.sw_if_index
220 rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200221 rv = self.vapi.ipip_6rd_add_tunnel(
222 ip6_table_id=20,
223 ip4_table_id=10,
224 ip6_prefix="2002::/16",
225 ip4_prefix="0.0.0.0/0",
226 ip4_src=self.pg2.local_ip4,
227 security_check=True,
228 )
Neale Ranns61502112018-08-22 00:21:14 -0700229 self.tunnel_index = rv.sw_if_index
230 self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20)
231
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200232 p_ip6 = IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) / UDP(
233 sport=1234, dport=1234
234 )
Neale Ranns61502112018-08-22 00:21:14 -0700235
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200236 p = (
237 Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
238 / IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4)
239 / p_ip6
240 )
Neale Ranns61502112018-08-22 00:21:14 -0700241
242 p_reply = p_ip6
243
Ole Troan9a475372019-03-05 16:58:24 +0100244 rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
Neale Ranns61502112018-08-22 00:21:14 -0700245 for p in rx:
246 self.validate_4in6(p, p_reply)
247 self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0)
248 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100249
250 def test_6rd_ip4_to_ip6_multiple(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200251 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100252
253 self.tunnel_index = []
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200254 rv = self.vapi.ipip_6rd_add_tunnel(
255 ip6_table_id=0,
256 ip4_table_id=0,
257 ip6_prefix="2002::/16",
258 ip4_prefix="0.0.0.0/0",
259 ip4_src=self.pg0.local_ip4,
260 security_check=True,
261 )
Ole Troan6ee40512018-02-12 18:14:39 +0100262 self.tunnel_index.append(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200263 rv = self.vapi.ipip_6rd_add_tunnel(
264 ip6_table_id=0,
265 ip4_table_id=0,
266 ip6_prefix="2003::/16",
267 ip4_prefix="0.0.0.0/0",
268 ip4_src=self.pg1.local_ip4,
269 security_check=True,
270 )
Ole Troan298c6952018-03-08 12:30:43 +0100271
Ole Troan6ee40512018-02-12 18:14:39 +0100272 self.tunnel_index.append(rv.sw_if_index)
273
274 self.vapi.cli("show ip6 fib")
275 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
276 p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200277 p_ip6_1 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
278 sport=1234, dport=1234
279 )
280 p_ip6_2 = IPv6(src="2003:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
281 sport=1234, dport=1234
282 )
Ole Troan6ee40512018-02-12 18:14:39 +0100283
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200284 p = p_ether / p_ip4 / p_ip6_1
Ole Troan9a475372019-03-05 16:58:24 +0100285 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100286 for p in rx:
287 self.validate_4in6(p, p_ip6_1)
288
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200289 p = p_ether / p_ip4 / p_ip6_2
Ole Troan9a475372019-03-05 16:58:24 +0100290 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100291 for p in rx:
292 self.validate_4in6(p, p_ip6_2)
Neale Ranns61502112018-08-22 00:21:14 -0700293 for i in self.tunnel_index:
294 self.vapi.ipip_6rd_del_tunnel(i)
Ole Troan6ee40512018-02-12 18:14:39 +0100295
296 def test_6rd_ip4_to_ip6_suffix(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200297 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100298
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200299 rv = self.vapi.ipip_6rd_add_tunnel(
300 ip6_table_id=0,
301 ip4_table_id=0,
302 ip6_prefix="2002::/16",
303 ip4_prefix="172.0.0.0/8",
304 ip4_src=self.pg0.local_ip4,
305 security_check=True,
306 )
Ole Troan6ee40512018-02-12 18:14:39 +0100307 self.tunnel_index = rv.sw_if_index
308
309 self.vapi.cli("show ip6 fib")
310 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
311 p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200312 p_ip6 = IPv6(src="2002:1002:0200::1", dst=self.pg1.remote_ip6) / UDP(
313 sport=1234, dport=1234
314 )
Ole Troan6ee40512018-02-12 18:14:39 +0100315
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200316 p = p_ether / p_ip4 / p_ip6
Ole Troan9a475372019-03-05 16:58:24 +0100317 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100318 for p in rx:
319 self.validate_4in6(p, p_ip6)
Neale Ranns61502112018-08-22 00:21:14 -0700320 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100321
322 def test_6rd_ip4_to_ip6_sec_check(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200323 """ip4 -> ip6 (decap) security check 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100324
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200325 rv = self.vapi.ipip_6rd_add_tunnel(
326 ip6_table_id=0,
327 ip4_table_id=0,
328 ip6_prefix="2002::/16",
329 ip4_prefix="0.0.0.0/0",
330 ip4_src=self.pg0.local_ip4,
331 security_check=True,
332 )
Ole Troan6ee40512018-02-12 18:14:39 +0100333 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100334
Ole Troan6ee40512018-02-12 18:14:39 +0100335 self.vapi.cli("show ip6 fib")
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200336 p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
337 sport=1234, dport=1234
338 )
339 p_ip6_fail = IPv6(src="2002:DEAD:0202::1", dst=self.pg1.remote_ip6) / UDP(
340 sport=1234, dport=1234
341 )
Ole Troan6ee40512018-02-12 18:14:39 +0100342
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200343 p = (
344 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
345 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
346 / p_ip6
347 )
Ole Troan6ee40512018-02-12 18:14:39 +0100348
349 p_reply = p_ip6
350
Ole Troan9a475372019-03-05 16:58:24 +0100351 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100352 for p in rx:
353 self.validate_4in6(p, p_reply)
354
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200355 p = (
356 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
357 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
358 / p_ip6_fail
359 )
Ole Troan9a475372019-03-05 16:58:24 +0100360 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700361 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100362
363 def test_6rd_bgp_tunnel(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200364 """6rd BGP tunnel"""
Ole Troan6ee40512018-02-12 18:14:39 +0100365
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200366 rv = self.vapi.ipip_6rd_add_tunnel(
367 ip6_table_id=0,
368 ip4_table_id=0,
369 ip6_prefix="2002::/16",
370 ip4_prefix="0.0.0.0/0",
371 ip4_src=self.pg0.local_ip4,
372 security_check=False,
373 )
Ole Troan288e0932019-05-29 12:30:05 +0200374
Ole Troan6ee40512018-02-12 18:14:39 +0100375 self.tunnel_index = rv.sw_if_index
376
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200377 default_route = VppIpRoute(
378 self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::", self.tunnel_index)]
379 )
Ole Troan6ee40512018-02-12 18:14:39 +0100380 default_route.add_vpp_config()
381
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200382 ip4_route = VppIpRoute(
383 self, "8.0.0.0", 8, [VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)]
384 )
Ole Troan6ee40512018-02-12 18:14:39 +0100385 ip4_route.add_vpp_config()
386
387 # Via recursive route 6 -> 4
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200388 p = (
389 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
390 / IPv6(src="1::1", dst="DEAD:BEEF::1")
391 / UDP(sport=1234, dport=1234)
392 )
Ole Troan6ee40512018-02-12 18:14:39 +0100393
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200394 p_reply = IP(src=self.pg0.local_ip4, dst="8.8.8.8", proto="ipv6") / IPv6(
395 src="1::1", dst="DEAD:BEEF::1", nh="UDP"
396 )
Ole Troan6ee40512018-02-12 18:14:39 +0100397
Ole Troan9a475372019-03-05 16:58:24 +0100398 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100399 for p in rx:
400 self.validate_6in4(p, p_reply)
401
402 # Via recursive route 4 -> 6 (Security check must be disabled)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200403 p_ip6 = IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) / UDP(
404 sport=1234, dport=1234
405 )
406 p = (
407 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
408 / IP(src="8.8.8.8", dst=self.pg0.local_ip4)
409 / p_ip6
410 )
Ole Troan6ee40512018-02-12 18:14:39 +0100411
412 p_reply = p_ip6
413
Ole Troan9a475372019-03-05 16:58:24 +0100414 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100415 for p in rx:
416 self.validate_4in6(p, p_reply)
Neale Ranns61502112018-08-22 00:21:14 -0700417 ip4_route.remove_vpp_config()
418 default_route.remove_vpp_config()
419 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100420
421
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200422if __name__ == "__main__":
Ole Troan6ee40512018-02-12 18:14:39 +0100423 unittest.main(testRunner=VppTestRunner)