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