Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 2 | """ 6RD RFC5969 functional tests """ |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3 | |
| 4 | import unittest |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 5 | from scapy.layers.inet import IP, UDP, Ether |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 6 | from scapy.layers.inet6 import IPv6 |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 7 | from scapy.packet import Raw |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 8 | from framework import VppTestCase, VppTestRunner |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 9 | from vpp_ip import DpoProto |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 10 | from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 11 | from socket import AF_INET, AF_INET6, inet_pton |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 12 | |
| 13 | """ Test6rd is a subclass of VPPTestCase classes. |
| 14 | |
| 15 | 6RD tests. |
| 16 | |
| 17 | """ |
| 18 | |
| 19 | |
| 20 | class Test6RD(VppTestCase): |
| 21 | """ 6RD Test Case """ |
| 22 | |
| 23 | @classmethod |
| 24 | def setUpClass(cls): |
| 25 | super(Test6RD, cls).setUpClass() |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 26 | cls.create_pg_interfaces(range(4)) |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 27 | cls.interfaces = list(cls.pg_interfaces) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 28 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 29 | @classmethod |
| 30 | def tearDownClass(cls): |
| 31 | super(Test6RD, cls).tearDownClass() |
| 32 | |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 33 | 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 Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 43 | i.admin_up() |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 44 | if (n > 1): |
| 45 | i.set_table_ip4(10) |
| 46 | i.set_table_ip6(20) |
Ole Troan | 46c1c11 | 2018-03-14 20:39:40 +0100 | [diff] [blame] | 47 | i.config_ip4() |
| 48 | i.config_ip6() |
| 49 | i.disable_ipv6_ra() |
| 50 | i.resolve_arp() |
| 51 | i.resolve_ndp() |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 52 | |
| 53 | def tearDown(self): |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 54 | 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) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 59 | super(Test6RD, self).tearDown() |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 60 | |
| 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 Vinciguerra | 3d2df21 | 2018-11-24 23:19:53 -0800 | [diff] [blame] | 79 | 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 Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 82 | |
| 83 | def payload(self, len): |
| 84 | return 'x' * len |
| 85 | |
| 86 | def test_6rd_ip6_to_ip4(self): |
| 87 | """ ip6 -> ip4 (encap) 6rd test """ |
| 88 | p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 89 | p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh='UDP') |
| 90 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 91 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 92 | ip4_table_id=0, |
| 93 | ip6_prefix='2002::/16', |
| 94 | ip4_prefix='0.0.0.0/0', |
| 95 | ip4_src=self.pg0.local_ip4, |
| 96 | security_check=True) |
| 97 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 98 | self.tunnel_index = rv.sw_if_index |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 99 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 100 | self.vapi.cli("show ip6 fib") |
| 101 | p_payload = UDP(sport=1234, dport=1234) |
| 102 | p = (p_ether / p_ip6 / p_payload) |
| 103 | |
| 104 | p_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, |
| 105 | proto='ipv6') / p_ip6) |
| 106 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 107 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 108 | for p in rx: |
| 109 | self.validate_6in4(p, p_reply) |
| 110 | |
| 111 | # MTU tests (default is 1480) |
| 112 | plen = 1481 - 40 - 8 |
| 113 | p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1") |
| 114 | p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen)) |
| 115 | p = (p_ether / p_ip6 / p_payload) |
| 116 | |
| 117 | p_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, |
| 118 | proto='ipv6') / p_ip6) |
| 119 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 120 | rx = self.send_and_assert_no_replies(self.pg0, p * 10) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 121 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
| 122 | |
| 123 | def test_6rd_ip6_to_ip4_vrf(self): |
| 124 | """ ip6 -> ip4 (encap) 6rd VRF test """ |
| 125 | p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) |
| 126 | p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh='UDP') |
| 127 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 128 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, ip4_table_id=10, |
| 129 | ip6_prefix='2002::/16', |
| 130 | ip4_prefix='0.0.0.0/0', |
| 131 | ip4_src=self.pg2.local_ip4, |
| 132 | security_check=True) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 133 | self.tunnel_index = rv.sw_if_index |
| 134 | |
| 135 | self.vapi.cli("show ip6 fib") |
| 136 | p_payload = UDP(sport=1234, dport=1234) |
| 137 | p = (p_ether / p_ip6 / p_payload) |
| 138 | |
| 139 | p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, |
| 140 | proto='ipv6') / p_ip6) |
| 141 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 142 | rx = self.send_and_expect(self.pg2, p * 10, self.pg3) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 143 | for p in rx: |
| 144 | self.validate_6in4(p, p_reply) |
| 145 | |
| 146 | # MTU tests (default is 1480) |
| 147 | plen = 1481 - 40 - 8 |
| 148 | p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1") |
| 149 | p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen)) |
| 150 | p = (p_ether / p_ip6 / p_payload) |
| 151 | |
| 152 | p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, |
| 153 | proto='ipv6') / p_ip6) |
| 154 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 155 | rx = self.send_and_assert_no_replies(self.pg0, p * 10) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 156 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 157 | |
| 158 | def test_6rd_ip4_to_ip6(self): |
| 159 | """ ip4 -> ip6 (decap) 6rd test """ |
| 160 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 161 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 162 | ip4_table_id=0, |
| 163 | ip6_prefix='2002::/16', |
| 164 | ip4_prefix='0.0.0.0/0', |
| 165 | ip4_src=self.pg0.local_ip4, |
| 166 | security_check=True) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 167 | self.tunnel_index = rv.sw_if_index |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 168 | rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index) |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 169 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 170 | ip4_table_id=0, |
| 171 | ip6_prefix='2002::/16', |
| 172 | ip4_prefix='0.0.0.0/0', |
| 173 | ip4_src=self.pg0.local_ip4, |
| 174 | security_check=True) |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 175 | self.tunnel_index = rv.sw_if_index |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 176 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 177 | p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / |
| 178 | UDP(sport=1234, dport=1234)) |
| 179 | |
| 180 | p = (Ether(src=self.pg0.remote_mac, |
| 181 | dst=self.pg0.local_mac) / |
| 182 | IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / |
| 183 | p_ip6) |
| 184 | |
| 185 | p_reply = p_ip6 |
| 186 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 187 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 188 | for p in rx: |
| 189 | self.validate_4in6(p, p_reply) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 190 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
| 191 | |
| 192 | def test_6rd_ip4_to_ip6_vrf(self): |
| 193 | """ ip4 -> ip6 (decap) 6rd VRF test """ |
| 194 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 195 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, |
| 196 | ip4_table_id=10, |
| 197 | ip6_prefix='2002::/16', |
| 198 | ip4_prefix='0.0.0.0/0', |
| 199 | ip4_src=self.pg2.local_ip4, |
| 200 | security_check=True) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 201 | self.tunnel_index = rv.sw_if_index |
| 202 | rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index) |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 203 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, |
| 204 | ip4_table_id=10, |
| 205 | ip6_prefix='2002::/16', |
| 206 | ip4_prefix='0.0.0.0/0', |
| 207 | ip4_src=self.pg2.local_ip4, |
| 208 | security_check=True) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 209 | self.tunnel_index = rv.sw_if_index |
| 210 | self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20) |
| 211 | |
| 212 | p_ip6 = (IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) / |
| 213 | UDP(sport=1234, dport=1234)) |
| 214 | |
| 215 | p = (Ether(src=self.pg2.remote_mac, |
| 216 | dst=self.pg2.local_mac) / |
| 217 | IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4) / |
| 218 | p_ip6) |
| 219 | |
| 220 | p_reply = p_ip6 |
| 221 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 222 | rx = self.send_and_expect(self.pg2, p * 10, self.pg3) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 223 | for p in rx: |
| 224 | self.validate_4in6(p, p_reply) |
| 225 | self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0) |
| 226 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 227 | |
| 228 | def test_6rd_ip4_to_ip6_multiple(self): |
| 229 | """ ip4 -> ip6 (decap) 6rd test """ |
| 230 | |
| 231 | self.tunnel_index = [] |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 232 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 233 | ip4_table_id=0, |
| 234 | ip6_prefix='2002::/16', |
| 235 | ip4_prefix='0.0.0.0/0', |
| 236 | ip4_src=self.pg0.local_ip4, |
| 237 | security_check=True) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 238 | self.tunnel_index.append(rv.sw_if_index) |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 239 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 240 | ip4_table_id=0, |
| 241 | ip6_prefix='2003::/16', |
| 242 | ip4_prefix='0.0.0.0/0', |
| 243 | ip4_src=self.pg1.local_ip4, |
| 244 | security_check=True) |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 245 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 246 | self.tunnel_index.append(rv.sw_if_index) |
| 247 | |
| 248 | self.vapi.cli("show ip6 fib") |
| 249 | p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 250 | p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) |
| 251 | p_ip6_1 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / |
| 252 | UDP(sport=1234, dport=1234)) |
| 253 | p_ip6_2 = (IPv6(src="2003:AC10:0202::1", dst=self.pg1.remote_ip6) / |
| 254 | UDP(sport=1234, dport=1234)) |
| 255 | |
| 256 | p = (p_ether / p_ip4 / p_ip6_1) |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 257 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 258 | for p in rx: |
| 259 | self.validate_4in6(p, p_ip6_1) |
| 260 | |
| 261 | p = (p_ether / p_ip4 / p_ip6_2) |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 262 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 263 | for p in rx: |
| 264 | self.validate_4in6(p, p_ip6_2) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 265 | for i in self.tunnel_index: |
| 266 | self.vapi.ipip_6rd_del_tunnel(i) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 267 | |
| 268 | def test_6rd_ip4_to_ip6_suffix(self): |
| 269 | """ ip4 -> ip6 (decap) 6rd test """ |
| 270 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 271 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 272 | ip4_table_id=0, |
| 273 | ip6_prefix='2002::/16', |
| 274 | ip4_prefix='172.0.0.0/8', |
| 275 | ip4_src=self.pg0.local_ip4, |
| 276 | security_check=True) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 277 | self.tunnel_index = rv.sw_if_index |
| 278 | |
| 279 | self.vapi.cli("show ip6 fib") |
| 280 | p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 281 | p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) |
| 282 | p_ip6 = (IPv6(src="2002:1002:0200::1", dst=self.pg1.remote_ip6) / |
| 283 | UDP(sport=1234, dport=1234)) |
| 284 | |
| 285 | p = (p_ether / p_ip4 / p_ip6) |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 286 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 287 | for p in rx: |
| 288 | self.validate_4in6(p, p_ip6) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 289 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 290 | |
| 291 | def test_6rd_ip4_to_ip6_sec_check(self): |
| 292 | """ ip4 -> ip6 (decap) security check 6rd test """ |
| 293 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 294 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 295 | ip4_table_id=0, |
| 296 | ip6_prefix='2002::/16', |
| 297 | ip4_prefix='0.0.0.0/0', |
| 298 | ip4_src=self.pg0.local_ip4, |
| 299 | security_check=True) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 300 | self.tunnel_index = rv.sw_if_index |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 301 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 302 | self.vapi.cli("show ip6 fib") |
| 303 | p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / |
| 304 | UDP(sport=1234, dport=1234)) |
| 305 | p_ip6_fail = (IPv6(src="2002:DEAD:0202::1", dst=self.pg1.remote_ip6) / |
| 306 | UDP(sport=1234, dport=1234)) |
| 307 | |
| 308 | p = (Ether(src=self.pg0.remote_mac, |
| 309 | dst=self.pg0.local_mac) / |
| 310 | IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / |
| 311 | p_ip6) |
| 312 | |
| 313 | p_reply = p_ip6 |
| 314 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 315 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 316 | for p in rx: |
| 317 | self.validate_4in6(p, p_reply) |
| 318 | |
| 319 | p = (Ether(src=self.pg0.remote_mac, |
| 320 | dst=self.pg0.local_mac) / |
| 321 | IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / |
| 322 | p_ip6_fail) |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 323 | rx = self.send_and_assert_no_replies(self.pg0, p * 10) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 324 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 325 | |
| 326 | def test_6rd_bgp_tunnel(self): |
| 327 | """ 6rd BGP tunnel """ |
| 328 | |
Ole Troan | 288e093 | 2019-05-29 12:30:05 +0200 | [diff] [blame] | 329 | rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, |
| 330 | ip4_table_id=0, |
| 331 | ip6_prefix='2002::/16', |
| 332 | ip4_prefix='0.0.0.0/0', |
| 333 | ip4_src=self.pg0.local_ip4, |
| 334 | security_check=False) |
| 335 | |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 336 | self.tunnel_index = rv.sw_if_index |
| 337 | |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 338 | default_route = VppIpRoute(self, "DEAD::", 16, |
| 339 | [VppRoutePath("2002:0808:0808::", |
| 340 | self.tunnel_index)]) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 341 | default_route.add_vpp_config() |
| 342 | |
| 343 | ip4_route = VppIpRoute(self, "8.0.0.0", 8, |
| 344 | [VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)]) |
| 345 | ip4_route.add_vpp_config() |
| 346 | |
| 347 | # Via recursive route 6 -> 4 |
| 348 | p = (Ether(src=self.pg0.remote_mac, |
| 349 | dst=self.pg0.local_mac) / |
| 350 | IPv6(src="1::1", dst="DEAD:BEEF::1") / |
| 351 | UDP(sport=1234, dport=1234)) |
| 352 | |
| 353 | p_reply = (IP(src=self.pg0.local_ip4, dst="8.8.8.8", |
| 354 | proto='ipv6') / |
| 355 | IPv6(src='1::1', dst='DEAD:BEEF::1', nh='UDP')) |
| 356 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 357 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 358 | for p in rx: |
| 359 | self.validate_6in4(p, p_reply) |
| 360 | |
| 361 | # Via recursive route 4 -> 6 (Security check must be disabled) |
| 362 | p_ip6 = (IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) / |
| 363 | UDP(sport=1234, dport=1234)) |
| 364 | p = (Ether(src=self.pg0.remote_mac, |
| 365 | dst=self.pg0.local_mac) / |
| 366 | IP(src="8.8.8.8", dst=self.pg0.local_ip4) / |
| 367 | p_ip6) |
| 368 | |
| 369 | p_reply = p_ip6 |
| 370 | |
Ole Troan | 9a47537 | 2019-03-05 16:58:24 +0100 | [diff] [blame] | 371 | rx = self.send_and_expect(self.pg0, p * 10, self.pg1) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 372 | for p in rx: |
| 373 | self.validate_4in6(p, p_reply) |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 374 | ip4_route.remove_vpp_config() |
| 375 | default_route.remove_vpp_config() |
| 376 | self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 377 | |
| 378 | |
| 379 | if __name__ == '__main__': |
| 380 | unittest.main(testRunner=VppTestRunner) |