blob: eca05452e3b5914aaaa713350acd9239d3cbebb7 [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
Dave Wallace8800f732023-08-31 00:47:44 -04008from framework import VppTestCase
9from asfframework import VppTestRunner
10from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
Ole Troan6ee40512018-02-12 18:14:39 +010011
12""" Test6rd is a subclass of VPPTestCase classes.
13
146RD tests.
15
16"""
17
18
19class Test6RD(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020020 """6RD Test Case"""
Ole Troan6ee40512018-02-12 18:14:39 +010021
22 @classmethod
23 def setUpClass(cls):
24 super(Test6RD, cls).setUpClass()
Neale Ranns61502112018-08-22 00:21:14 -070025 cls.create_pg_interfaces(range(4))
Ole Troan46c1c112018-03-14 20:39:40 +010026 cls.interfaces = list(cls.pg_interfaces)
Ole Troan6ee40512018-02-12 18:14:39 +010027
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070028 @classmethod
29 def tearDownClass(cls):
30 super(Test6RD, cls).tearDownClass()
31
Neale Ranns61502112018-08-22 00:21:14 -070032 def setUp(self):
33 super(Test6RD, self).setUp()
34 t4 = VppIpTable(self, 10)
35 t6 = VppIpTable(self, 20, True)
36
37 t4.add_vpp_config()
38 t6.add_vpp_config()
39
40 for n in range(4):
41 i = self.pg_interfaces[n]
Ole Troan46c1c112018-03-14 20:39:40 +010042 i.admin_up()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020043 if n > 1:
Neale Ranns61502112018-08-22 00:21:14 -070044 i.set_table_ip4(10)
45 i.set_table_ip6(20)
Ole Troan46c1c112018-03-14 20:39:40 +010046 i.config_ip4()
47 i.config_ip6()
48 i.disable_ipv6_ra()
49 i.resolve_arp()
50 i.resolve_ndp()
Ole Troan6ee40512018-02-12 18:14:39 +010051
52 def tearDown(self):
Neale Ranns61502112018-08-22 00:21:14 -070053 for i in self.pg_interfaces:
54 i.unconfig_ip4()
55 i.unconfig_ip6()
56 i.set_table_ip4(0)
57 i.set_table_ip6(0)
Neale Rannscbe25aa2019-09-30 10:53:31 +000058 i.admin_down()
Ole Troan6ee40512018-02-12 18:14:39 +010059 super(Test6RD, self).tearDown()
Ole Troan6ee40512018-02-12 18:14:39 +010060
61 def validate_6in4(self, rx, expected):
62 if IP not in rx:
63 self.fail()
64 if IPv6 not in rx:
65 self.fail()
66
67 self.assertEqual(rx[IP].src, expected[IP].src)
68 self.assertEqual(rx[IP].dst, expected[IP].dst)
69 self.assertEqual(rx[IP].proto, expected[IP].proto)
70 self.assertEqual(rx[IPv6].src, expected[IPv6].src)
71 self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
72
73 def validate_4in6(self, rx, expected):
74 if IPv6 not in rx:
75 self.fail()
76 if IP in rx:
77 self.fail()
78
Paul Vinciguerra3d2df212018-11-24 23:19:53 -080079 self.assertEqual(rx[IPv6].src, expected[IPv6].src)
80 self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
81 self.assertEqual(rx[IPv6].nh, expected[IPv6].nh)
Ole Troan6ee40512018-02-12 18:14:39 +010082
83 def payload(self, len):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020084 return "x" * len
Ole Troan6ee40512018-02-12 18:14:39 +010085
86 def test_6rd_ip6_to_ip4(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020087 """ip6 -> ip4 (encap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +010088 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020089 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh="UDP")
Ole Troan6ee40512018-02-12 18:14:39 +010090
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020091 rv = self.vapi.ipip_6rd_add_tunnel(
92 ip6_table_id=0,
93 ip4_table_id=0,
94 ip6_prefix="2002::/16",
95 ip4_prefix="0.0.0.0/0",
96 ip4_src=self.pg0.local_ip4,
97 security_check=True,
98 )
Ole Troan288e0932019-05-29 12:30:05 +020099
Ole Troan6ee40512018-02-12 18:14:39 +0100100 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100101
Ole Troan6ee40512018-02-12 18:14:39 +0100102 self.vapi.cli("show ip6 fib")
103 p_payload = UDP(sport=1234, dport=1234)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200104 p = p_ether / p_ip6 / p_payload
Ole Troan6ee40512018-02-12 18:14:39 +0100105
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200106 p_reply = (
107 IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
108 )
Ole Troan6ee40512018-02-12 18:14:39 +0100109
Ole Troan9a475372019-03-05 16:58:24 +0100110 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100111 for p in rx:
112 self.validate_6in4(p, p_reply)
113
114 # MTU tests (default is 1480)
115 plen = 1481 - 40 - 8
116 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1")
117 p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200118 p = p_ether / p_ip6 / p_payload
Ole Troan6ee40512018-02-12 18:14:39 +0100119
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200120 p_reply = (
121 IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
122 )
Ole Troan6ee40512018-02-12 18:14:39 +0100123
Ole Troan9a475372019-03-05 16:58:24 +0100124 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700125 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
126
127 def test_6rd_ip6_to_ip4_vrf(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200128 """ip6 -> ip4 (encap) 6rd VRF test"""
Neale Ranns61502112018-08-22 00:21:14 -0700129 p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200130 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh="UDP")
Neale Ranns61502112018-08-22 00:21:14 -0700131
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200132 rv = self.vapi.ipip_6rd_add_tunnel(
133 ip6_table_id=20,
134 ip4_table_id=10,
135 ip6_prefix="2002::/16",
136 ip4_prefix="0.0.0.0/0",
137 ip4_src=self.pg2.local_ip4,
138 security_check=True,
139 )
Neale Ranns61502112018-08-22 00:21:14 -0700140 self.tunnel_index = rv.sw_if_index
141
142 self.vapi.cli("show ip6 fib")
143 p_payload = UDP(sport=1234, dport=1234)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200144 p = p_ether / p_ip6 / p_payload
Neale Ranns61502112018-08-22 00:21:14 -0700145
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200146 p_reply = (
147 IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
148 )
Neale Ranns61502112018-08-22 00:21:14 -0700149
Ole Troan9a475372019-03-05 16:58:24 +0100150 rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
Neale Ranns61502112018-08-22 00:21:14 -0700151 for p in rx:
152 self.validate_6in4(p, p_reply)
153
154 # MTU tests (default is 1480)
155 plen = 1481 - 40 - 8
156 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1")
157 p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200158 p = p_ether / p_ip6 / p_payload
Neale Ranns61502112018-08-22 00:21:14 -0700159
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200160 p_reply = (
161 IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
162 )
Neale Ranns61502112018-08-22 00:21:14 -0700163
Ole Troan9a475372019-03-05 16:58:24 +0100164 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700165 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100166
167 def test_6rd_ip4_to_ip6(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200168 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100169
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200170 rv = self.vapi.ipip_6rd_add_tunnel(
171 ip6_table_id=0,
172 ip4_table_id=0,
173 ip6_prefix="2002::/16",
174 ip4_prefix="0.0.0.0/0",
175 ip4_src=self.pg0.local_ip4,
176 security_check=True,
177 )
Ole Troan6ee40512018-02-12 18:14:39 +0100178 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100179 rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200180 rv = self.vapi.ipip_6rd_add_tunnel(
181 ip6_table_id=0,
182 ip4_table_id=0,
183 ip6_prefix="2002::/16",
184 ip4_prefix="0.0.0.0/0",
185 ip4_src=self.pg0.local_ip4,
186 security_check=True,
187 )
Ole Troan298c6952018-03-08 12:30:43 +0100188 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100189
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200190 p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
191 sport=1234, dport=1234
192 )
Ole Troan6ee40512018-02-12 18:14:39 +0100193
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200194 p = (
195 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
196 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
197 / p_ip6
198 )
Ole Troan6ee40512018-02-12 18:14:39 +0100199
200 p_reply = p_ip6
201
Ole Troan9a475372019-03-05 16:58:24 +0100202 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100203 for p in rx:
204 self.validate_4in6(p, p_reply)
Neale Ranns61502112018-08-22 00:21:14 -0700205 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
206
207 def test_6rd_ip4_to_ip6_vrf(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200208 """ip4 -> ip6 (decap) 6rd VRF test"""
Neale Ranns61502112018-08-22 00:21:14 -0700209
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200210 rv = self.vapi.ipip_6rd_add_tunnel(
211 ip6_table_id=20,
212 ip4_table_id=10,
213 ip6_prefix="2002::/16",
214 ip4_prefix="0.0.0.0/0",
215 ip4_src=self.pg2.local_ip4,
216 security_check=True,
217 )
Neale Ranns61502112018-08-22 00:21:14 -0700218 self.tunnel_index = rv.sw_if_index
219 rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200220 rv = self.vapi.ipip_6rd_add_tunnel(
221 ip6_table_id=20,
222 ip4_table_id=10,
223 ip6_prefix="2002::/16",
224 ip4_prefix="0.0.0.0/0",
225 ip4_src=self.pg2.local_ip4,
226 security_check=True,
227 )
Neale Ranns61502112018-08-22 00:21:14 -0700228 self.tunnel_index = rv.sw_if_index
229 self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20)
230
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200231 p_ip6 = IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) / UDP(
232 sport=1234, dport=1234
233 )
Neale Ranns61502112018-08-22 00:21:14 -0700234
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200235 p = (
236 Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
237 / IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4)
238 / p_ip6
239 )
Neale Ranns61502112018-08-22 00:21:14 -0700240
241 p_reply = p_ip6
242
Ole Troan9a475372019-03-05 16:58:24 +0100243 rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
Neale Ranns61502112018-08-22 00:21:14 -0700244 for p in rx:
245 self.validate_4in6(p, p_reply)
246 self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0)
247 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100248
249 def test_6rd_ip4_to_ip6_multiple(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200250 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100251
252 self.tunnel_index = []
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200253 rv = self.vapi.ipip_6rd_add_tunnel(
254 ip6_table_id=0,
255 ip4_table_id=0,
256 ip6_prefix="2002::/16",
257 ip4_prefix="0.0.0.0/0",
258 ip4_src=self.pg0.local_ip4,
259 security_check=True,
260 )
Ole Troan6ee40512018-02-12 18:14:39 +0100261 self.tunnel_index.append(rv.sw_if_index)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200262 rv = self.vapi.ipip_6rd_add_tunnel(
263 ip6_table_id=0,
264 ip4_table_id=0,
265 ip6_prefix="2003::/16",
266 ip4_prefix="0.0.0.0/0",
267 ip4_src=self.pg1.local_ip4,
268 security_check=True,
269 )
Ole Troan298c6952018-03-08 12:30:43 +0100270
Ole Troan6ee40512018-02-12 18:14:39 +0100271 self.tunnel_index.append(rv.sw_if_index)
272
273 self.vapi.cli("show ip6 fib")
274 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
275 p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200276 p_ip6_1 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
277 sport=1234, dport=1234
278 )
279 p_ip6_2 = IPv6(src="2003:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
280 sport=1234, dport=1234
281 )
Ole Troan6ee40512018-02-12 18:14:39 +0100282
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200283 p = p_ether / p_ip4 / p_ip6_1
Ole Troan9a475372019-03-05 16:58:24 +0100284 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100285 for p in rx:
286 self.validate_4in6(p, p_ip6_1)
287
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200288 p = p_ether / p_ip4 / p_ip6_2
Ole Troan9a475372019-03-05 16:58:24 +0100289 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100290 for p in rx:
291 self.validate_4in6(p, p_ip6_2)
Neale Ranns61502112018-08-22 00:21:14 -0700292 for i in self.tunnel_index:
293 self.vapi.ipip_6rd_del_tunnel(i)
Ole Troan6ee40512018-02-12 18:14:39 +0100294
295 def test_6rd_ip4_to_ip6_suffix(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200296 """ip4 -> ip6 (decap) 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100297
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200298 rv = self.vapi.ipip_6rd_add_tunnel(
299 ip6_table_id=0,
300 ip4_table_id=0,
301 ip6_prefix="2002::/16",
302 ip4_prefix="172.0.0.0/8",
303 ip4_src=self.pg0.local_ip4,
304 security_check=True,
305 )
Ole Troan6ee40512018-02-12 18:14:39 +0100306 self.tunnel_index = rv.sw_if_index
307
308 self.vapi.cli("show ip6 fib")
309 p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
310 p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200311 p_ip6 = IPv6(src="2002:1002:0200::1", dst=self.pg1.remote_ip6) / UDP(
312 sport=1234, dport=1234
313 )
Ole Troan6ee40512018-02-12 18:14:39 +0100314
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200315 p = p_ether / p_ip4 / p_ip6
Ole Troan9a475372019-03-05 16:58:24 +0100316 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100317 for p in rx:
318 self.validate_4in6(p, p_ip6)
Neale Ranns61502112018-08-22 00:21:14 -0700319 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100320
321 def test_6rd_ip4_to_ip6_sec_check(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200322 """ip4 -> ip6 (decap) security check 6rd test"""
Ole Troan6ee40512018-02-12 18:14:39 +0100323
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200324 rv = self.vapi.ipip_6rd_add_tunnel(
325 ip6_table_id=0,
326 ip4_table_id=0,
327 ip6_prefix="2002::/16",
328 ip4_prefix="0.0.0.0/0",
329 ip4_src=self.pg0.local_ip4,
330 security_check=True,
331 )
Ole Troan6ee40512018-02-12 18:14:39 +0100332 self.tunnel_index = rv.sw_if_index
Ole Troan298c6952018-03-08 12:30:43 +0100333
Ole Troan6ee40512018-02-12 18:14:39 +0100334 self.vapi.cli("show ip6 fib")
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200335 p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
336 sport=1234, dport=1234
337 )
338 p_ip6_fail = IPv6(src="2002:DEAD:0202::1", dst=self.pg1.remote_ip6) / UDP(
339 sport=1234, dport=1234
340 )
Ole Troan6ee40512018-02-12 18:14:39 +0100341
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200342 p = (
343 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
344 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
345 / p_ip6
346 )
Ole Troan6ee40512018-02-12 18:14:39 +0100347
348 p_reply = p_ip6
349
Ole Troan9a475372019-03-05 16:58:24 +0100350 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100351 for p in rx:
352 self.validate_4in6(p, p_reply)
353
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200354 p = (
355 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
356 / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
357 / p_ip6_fail
358 )
Ole Troan9a475372019-03-05 16:58:24 +0100359 rx = self.send_and_assert_no_replies(self.pg0, p * 10)
Neale Ranns61502112018-08-22 00:21:14 -0700360 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100361
362 def test_6rd_bgp_tunnel(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200363 """6rd BGP tunnel"""
Ole Troan6ee40512018-02-12 18:14:39 +0100364
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200365 rv = self.vapi.ipip_6rd_add_tunnel(
366 ip6_table_id=0,
367 ip4_table_id=0,
368 ip6_prefix="2002::/16",
369 ip4_prefix="0.0.0.0/0",
370 ip4_src=self.pg0.local_ip4,
371 security_check=False,
372 )
Ole Troan288e0932019-05-29 12:30:05 +0200373
Ole Troan6ee40512018-02-12 18:14:39 +0100374 self.tunnel_index = rv.sw_if_index
375
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200376 default_route = VppIpRoute(
377 self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::", self.tunnel_index)]
378 )
Ole Troan6ee40512018-02-12 18:14:39 +0100379 default_route.add_vpp_config()
380
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200381 ip4_route = VppIpRoute(
382 self, "8.0.0.0", 8, [VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)]
383 )
Ole Troan6ee40512018-02-12 18:14:39 +0100384 ip4_route.add_vpp_config()
385
386 # Via recursive route 6 -> 4
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200387 p = (
388 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
389 / IPv6(src="1::1", dst="DEAD:BEEF::1")
390 / UDP(sport=1234, dport=1234)
391 )
Ole Troan6ee40512018-02-12 18:14:39 +0100392
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200393 p_reply = IP(src=self.pg0.local_ip4, dst="8.8.8.8", proto="ipv6") / IPv6(
394 src="1::1", dst="DEAD:BEEF::1", nh="UDP"
395 )
Ole Troan6ee40512018-02-12 18:14:39 +0100396
Ole Troan9a475372019-03-05 16:58:24 +0100397 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100398 for p in rx:
399 self.validate_6in4(p, p_reply)
400
401 # Via recursive route 4 -> 6 (Security check must be disabled)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200402 p_ip6 = IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) / UDP(
403 sport=1234, dport=1234
404 )
405 p = (
406 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
407 / IP(src="8.8.8.8", dst=self.pg0.local_ip4)
408 / p_ip6
409 )
Ole Troan6ee40512018-02-12 18:14:39 +0100410
411 p_reply = p_ip6
412
Ole Troan9a475372019-03-05 16:58:24 +0100413 rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
Ole Troan6ee40512018-02-12 18:14:39 +0100414 for p in rx:
415 self.validate_4in6(p, p_reply)
Neale Ranns61502112018-08-22 00:21:14 -0700416 ip4_route.remove_vpp_config()
417 default_route.remove_vpp_config()
418 self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
Ole Troan6ee40512018-02-12 18:14:39 +0100419
420
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200421if __name__ == "__main__":
Ole Troan6ee40512018-02-12 18:14:39 +0100422 unittest.main(testRunner=VppTestRunner)