2019-10-31 13:31:07 -05:00
|
|
|
#!/usr/bin/env python3
|
2018-03-14 20:39:40 +01:00
|
|
|
""" 6RD RFC5969 functional tests """
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
import unittest
|
2018-03-14 20:39:40 +01:00
|
|
|
from scapy.layers.inet import IP, UDP, Ether
|
2018-02-12 18:14:39 +01:00
|
|
|
from scapy.layers.inet6 import IPv6
|
|
|
|
from scapy.packet import Raw
|
2023-08-31 00:47:44 -04:00
|
|
|
from framework import VppTestCase
|
|
|
|
from asfframework import VppTestRunner
|
|
|
|
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
""" Test6rd is a subclass of VPPTestCase classes.
|
|
|
|
|
|
|
|
6RD tests.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
class Test6RD(VppTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""6RD Test Case"""
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(Test6RD, cls).setUpClass()
|
2018-08-22 00:21:14 -07:00
|
|
|
cls.create_pg_interfaces(range(4))
|
2018-03-14 20:39:40 +01:00
|
|
|
cls.interfaces = list(cls.pg_interfaces)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(Test6RD, cls).tearDownClass()
|
|
|
|
|
2018-08-22 00:21:14 -07:00
|
|
|
def setUp(self):
|
|
|
|
super(Test6RD, self).setUp()
|
|
|
|
t4 = VppIpTable(self, 10)
|
|
|
|
t6 = VppIpTable(self, 20, True)
|
|
|
|
|
|
|
|
t4.add_vpp_config()
|
|
|
|
t6.add_vpp_config()
|
|
|
|
|
|
|
|
for n in range(4):
|
|
|
|
i = self.pg_interfaces[n]
|
2018-03-14 20:39:40 +01:00
|
|
|
i.admin_up()
|
2022-04-26 19:02:15 +02:00
|
|
|
if n > 1:
|
2018-08-22 00:21:14 -07:00
|
|
|
i.set_table_ip4(10)
|
|
|
|
i.set_table_ip6(20)
|
2018-03-14 20:39:40 +01:00
|
|
|
i.config_ip4()
|
|
|
|
i.config_ip6()
|
|
|
|
i.disable_ipv6_ra()
|
|
|
|
i.resolve_arp()
|
|
|
|
i.resolve_ndp()
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def tearDown(self):
|
2018-08-22 00:21:14 -07:00
|
|
|
for i in self.pg_interfaces:
|
|
|
|
i.unconfig_ip4()
|
|
|
|
i.unconfig_ip6()
|
|
|
|
i.set_table_ip4(0)
|
|
|
|
i.set_table_ip6(0)
|
2019-09-30 10:53:31 +00:00
|
|
|
i.admin_down()
|
2018-02-12 18:14:39 +01:00
|
|
|
super(Test6RD, self).tearDown()
|
|
|
|
|
|
|
|
def validate_6in4(self, rx, expected):
|
|
|
|
if IP not in rx:
|
|
|
|
self.fail()
|
|
|
|
if IPv6 not in rx:
|
|
|
|
self.fail()
|
|
|
|
|
|
|
|
self.assertEqual(rx[IP].src, expected[IP].src)
|
|
|
|
self.assertEqual(rx[IP].dst, expected[IP].dst)
|
|
|
|
self.assertEqual(rx[IP].proto, expected[IP].proto)
|
|
|
|
self.assertEqual(rx[IPv6].src, expected[IPv6].src)
|
|
|
|
self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
|
|
|
|
|
|
|
|
def validate_4in6(self, rx, expected):
|
|
|
|
if IPv6 not in rx:
|
|
|
|
self.fail()
|
|
|
|
if IP in rx:
|
|
|
|
self.fail()
|
|
|
|
|
2018-11-24 23:19:53 -08:00
|
|
|
self.assertEqual(rx[IPv6].src, expected[IPv6].src)
|
|
|
|
self.assertEqual(rx[IPv6].dst, expected[IPv6].dst)
|
|
|
|
self.assertEqual(rx[IPv6].nh, expected[IPv6].nh)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def payload(self, len):
|
2022-04-26 19:02:15 +02:00
|
|
|
return "x" * len
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_ip6_to_ip4(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip6 -> ip4 (encap) 6rd test"""
|
2018-02-12 18:14:39 +01:00
|
|
|
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh="UDP")
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2019-05-29 12:30:05 +02:00
|
|
|
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
2018-03-08 12:30:43 +01:00
|
|
|
|
2018-02-12 18:14:39 +01:00
|
|
|
self.vapi.cli("show ip6 fib")
|
|
|
|
p_payload = UDP(sport=1234, dport=1234)
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip6 / p_payload
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_reply = (
|
|
|
|
IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_6in4(p, p_reply)
|
|
|
|
|
|
|
|
# MTU tests (default is 1480)
|
|
|
|
plen = 1481 - 40 - 8
|
|
|
|
p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1")
|
|
|
|
p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip6 / p_payload
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_reply = (
|
|
|
|
IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto="ipv6") / p_ip6
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_assert_no_replies(self.pg0, p * 10)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
|
|
|
|
|
|
|
def test_6rd_ip6_to_ip4_vrf(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip6 -> ip4 (encap) 6rd VRF test"""
|
2018-08-22 00:21:14 -07:00
|
|
|
p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh="UDP")
|
|
|
|
|
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=20,
|
|
|
|
ip4_table_id=10,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg2.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
|
|
|
|
self.vapi.cli("show ip6 fib")
|
|
|
|
p_payload = UDP(sport=1234, dport=1234)
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip6 / p_payload
|
2018-08-22 00:21:14 -07:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_reply = (
|
|
|
|
IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
|
2018-08-22 00:21:14 -07:00
|
|
|
for p in rx:
|
|
|
|
self.validate_6in4(p, p_reply)
|
|
|
|
|
|
|
|
# MTU tests (default is 1480)
|
|
|
|
plen = 1481 - 40 - 8
|
|
|
|
p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1")
|
|
|
|
p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip6 / p_payload
|
2018-08-22 00:21:14 -07:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_reply = (
|
|
|
|
IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto="ipv6") / p_ip6
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_assert_no_replies(self.pg0, p * 10)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_ip4_to_ip6(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip4 -> ip6 (decap) 6rd test"""
|
|
|
|
|
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
2018-03-08 12:30:43 +01:00
|
|
|
rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-03-08 12:30:43 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
|
|
|
|
/ p_ip6
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
p_reply = p_ip6
|
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_reply)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
|
|
|
|
|
|
|
def test_6rd_ip4_to_ip6_vrf(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip4 -> ip6 (decap) 6rd VRF test"""
|
|
|
|
|
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=20,
|
|
|
|
ip4_table_id=10,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg2.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=20,
|
|
|
|
ip4_table_id=10,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg2.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20)
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
|
|
|
|
/ IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4)
|
|
|
|
/ p_ip6
|
|
|
|
)
|
2018-08-22 00:21:14 -07:00
|
|
|
|
|
|
|
p_reply = p_ip6
|
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg2, p * 10, self.pg3)
|
2018-08-22 00:21:14 -07:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_reply)
|
|
|
|
self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0)
|
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_ip4_to_ip6_multiple(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip4 -> ip6 (decap) 6rd test"""
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
self.tunnel_index = []
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index.append(rv.sw_if_index)
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2003::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg1.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-03-08 12:30:43 +01:00
|
|
|
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index.append(rv.sw_if_index)
|
|
|
|
|
|
|
|
self.vapi.cli("show ip6 fib")
|
|
|
|
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6_1 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
|
|
|
p_ip6_2 = IPv6(src="2003:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
|
|
|
|
|
|
|
p = p_ether / p_ip4 / p_ip6_1
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_ip6_1)
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip4 / p_ip6_2
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_ip6_2)
|
2018-08-22 00:21:14 -07:00
|
|
|
for i in self.tunnel_index:
|
|
|
|
self.vapi.ipip_6rd_del_tunnel(i)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_ip4_to_ip6_suffix(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip4 -> ip6 (decap) 6rd test"""
|
|
|
|
|
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="172.0.0.0/8",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
|
|
|
|
self.vapi.cli("show ip6 fib")
|
|
|
|
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="2002:1002:0200::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p = p_ether / p_ip4 / p_ip6
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_ip6)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_ip4_to_ip6_sec_check(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""ip4 -> ip6 (decap) security check 6rd test"""
|
|
|
|
|
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=True,
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
2018-03-08 12:30:43 +01:00
|
|
|
|
2018-02-12 18:14:39 +01:00
|
|
|
self.vapi.cli("show ip6 fib")
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
|
|
|
p_ip6_fail = IPv6(src="2002:DEAD:0202::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
|
|
|
|
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
|
|
|
|
/ p_ip6
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
p_reply = p_ip6
|
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_reply)
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4)
|
|
|
|
/ p_ip6_fail
|
|
|
|
)
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_assert_no_replies(self.pg0, p * 10)
|
2018-08-22 00:21:14 -07:00
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
def test_6rd_bgp_tunnel(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""6rd BGP tunnel"""
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
rv = self.vapi.ipip_6rd_add_tunnel(
|
|
|
|
ip6_table_id=0,
|
|
|
|
ip4_table_id=0,
|
|
|
|
ip6_prefix="2002::/16",
|
|
|
|
ip4_prefix="0.0.0.0/0",
|
|
|
|
ip4_src=self.pg0.local_ip4,
|
|
|
|
security_check=False,
|
|
|
|
)
|
2019-05-29 12:30:05 +02:00
|
|
|
|
2018-02-12 18:14:39 +01:00
|
|
|
self.tunnel_index = rv.sw_if_index
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
default_route = VppIpRoute(
|
|
|
|
self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::", self.tunnel_index)]
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
default_route.add_vpp_config()
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
ip4_route = VppIpRoute(
|
|
|
|
self, "8.0.0.0", 8, [VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)]
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
ip4_route.add_vpp_config()
|
|
|
|
|
|
|
|
# Via recursive route 6 -> 4
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IPv6(src="1::1", dst="DEAD:BEEF::1")
|
|
|
|
/ UDP(sport=1234, dport=1234)
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
p_reply = IP(src=self.pg0.local_ip4, dst="8.8.8.8", proto="ipv6") / IPv6(
|
|
|
|
src="1::1", dst="DEAD:BEEF::1", nh="UDP"
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_6in4(p, p_reply)
|
|
|
|
|
|
|
|
# Via recursive route 4 -> 6 (Security check must be disabled)
|
2022-04-26 19:02:15 +02:00
|
|
|
p_ip6 = IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) / UDP(
|
|
|
|
sport=1234, dport=1234
|
|
|
|
)
|
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IP(src="8.8.8.8", dst=self.pg0.local_ip4)
|
|
|
|
/ p_ip6
|
|
|
|
)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
p_reply = p_ip6
|
|
|
|
|
2019-03-05 16:58:24 +01:00
|
|
|
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
|
2018-02-12 18:14:39 +01:00
|
|
|
for p in rx:
|
|
|
|
self.validate_4in6(p, p_reply)
|
2018-08-22 00:21:14 -07:00
|
|
|
ip4_route.remove_vpp_config()
|
|
|
|
default_route.remove_vpp_config()
|
|
|
|
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
|
2018-02-12 18:14:39 +01:00
|
|
|
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
if __name__ == "__main__":
|
2018-02-12 18:14:39 +01:00
|
|
|
unittest.main(testRunner=VppTestRunner)
|