blob: aad3713c4c02ea5f312b370ccb3c5d9f5cb9e0a4 [file] [log] [blame]
Damjan Marionf56b77a2016-10-03 19:44:57 +02001#!/usr/bin/env python
2
Damjan Marionf56b77a2016-10-03 19:44:57 +02003import unittest
Neale Ranns3f844d02017-02-18 00:03:54 -08004from socket import AF_INET6
Klement Sekeraf62ae122016-10-11 11:47:09 +02005
Damjan Marionf56b77a2016-10-03 19:44:57 +02006from framework import VppTestCase, VppTestRunner
Matej Klotton86d87c42016-11-11 11:38:55 +01007from vpp_sub_interface import VppSubInterface, VppDot1QSubint
Neale Ranns32e1c012016-11-22 17:07:28 +00008from vpp_pg_interface import is_ipv6_misc
Neale Ranns180279b2017-03-16 15:49:09 -04009from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, VppIpMRoute, \
Neale Ranns71275e32017-05-25 12:38:58 -070010 VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
Neale Ranns15002542017-09-10 04:39:11 -070011 VppMplsRoute, DpoProto, VppMplsTable
Neale Rannsb3b2de72017-03-08 05:17:22 -080012from vpp_neighbor import find_nbr, VppNeighbor
Damjan Marionf56b77a2016-10-03 19:44:57 +020013
14from scapy.packet import Raw
15from scapy.layers.l2 import Ether, Dot1Q
Klement Sekerada505f62017-01-04 12:58:53 +010016from scapy.layers.inet6 import IPv6, UDP, ICMPv6ND_NS, ICMPv6ND_RS, \
Neale Ranns87df12d2017-02-18 08:16:41 -080017 ICMPv6ND_RA, ICMPv6NDOptSrcLLAddr, getmacbyip6, ICMPv6MRD_Solicitation, \
Neale Ranns3f844d02017-02-18 00:03:54 -080018 ICMPv6NDOptMTU, ICMPv6NDOptSrcLLAddr, ICMPv6NDOptPrefixInfo, \
Neale Ranns37be7362017-02-21 17:30:26 -080019 ICMPv6ND_NA, ICMPv6NDOptDstLLAddr, ICMPv6DestUnreach, icmp6types
Neale Ranns3f844d02017-02-18 00:03:54 -080020
Klement Sekera7bb873a2016-11-18 07:38:42 +010021from util import ppp
Neale Ranns75152282017-01-09 01:00:45 -080022from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
Neale Ranns32e1c012016-11-22 17:07:28 +000023 in6_mactoifaceid, in6_ismaddr
Neale Ranns75152282017-01-09 01:00:45 -080024from scapy.utils import inet_pton, inet_ntop
Neale Ranns71275e32017-05-25 12:38:58 -070025from scapy.contrib.mpls import MPLS
Neale Ranns75152282017-01-09 01:00:45 -080026
Neale Ranns5737d882017-02-03 06:14:49 -080027
Neale Ranns75152282017-01-09 01:00:45 -080028def mk_ll_addr(mac):
29 euid = in6_mactoifaceid(mac)
30 addr = "fe80::" + euid
31 return addr
Damjan Marionf56b77a2016-10-03 19:44:57 +020032
33
Neale Ranns3f844d02017-02-18 00:03:54 -080034class TestIPv6ND(VppTestCase):
35 def validate_ra(self, intf, rx, dst_ip=None):
36 if not dst_ip:
37 dst_ip = intf.remote_ip6
38
39 # unicasted packets must come to the unicast mac
40 self.assertEqual(rx[Ether].dst, intf.remote_mac)
41
42 # and from the router's MAC
43 self.assertEqual(rx[Ether].src, intf.local_mac)
44
45 # the rx'd RA should be addressed to the sender's source
46 self.assertTrue(rx.haslayer(ICMPv6ND_RA))
47 self.assertEqual(in6_ptop(rx[IPv6].dst),
48 in6_ptop(dst_ip))
49
50 # and come from the router's link local
51 self.assertTrue(in6_islladdr(rx[IPv6].src))
52 self.assertEqual(in6_ptop(rx[IPv6].src),
53 in6_ptop(mk_ll_addr(intf.local_mac)))
54
55 def validate_na(self, intf, rx, dst_ip=None, tgt_ip=None):
56 if not dst_ip:
57 dst_ip = intf.remote_ip6
58 if not tgt_ip:
59 dst_ip = intf.local_ip6
60
61 # unicasted packets must come to the unicast mac
62 self.assertEqual(rx[Ether].dst, intf.remote_mac)
63
64 # and from the router's MAC
65 self.assertEqual(rx[Ether].src, intf.local_mac)
66
67 # the rx'd NA should be addressed to the sender's source
68 self.assertTrue(rx.haslayer(ICMPv6ND_NA))
69 self.assertEqual(in6_ptop(rx[IPv6].dst),
70 in6_ptop(dst_ip))
71
72 # and come from the target address
73 self.assertEqual(in6_ptop(rx[IPv6].src), in6_ptop(tgt_ip))
74
75 # Dest link-layer options should have the router's MAC
76 dll = rx[ICMPv6NDOptDstLLAddr]
77 self.assertEqual(dll.lladdr, intf.local_mac)
78
Neale Rannsdcd6d622017-05-26 02:59:16 -070079 def validate_ns(self, intf, rx, tgt_ip):
80 nsma = in6_getnsma(inet_pton(AF_INET6, tgt_ip))
81 dst_ip = inet_ntop(AF_INET6, nsma)
82
83 # NS is broadcast
84 self.assertEqual(rx[Ether].dst, "ff:ff:ff:ff:ff:ff")
85
86 # and from the router's MAC
87 self.assertEqual(rx[Ether].src, intf.local_mac)
88
89 # the rx'd NS should be addressed to an mcast address
90 # derived from the target address
91 self.assertEqual(in6_ptop(rx[IPv6].dst), in6_ptop(dst_ip))
92
93 # expect the tgt IP in the NS header
94 ns = rx[ICMPv6ND_NS]
95 self.assertEqual(in6_ptop(ns.tgt), in6_ptop(tgt_ip))
96
97 # packet is from the router's local address
98 self.assertEqual(in6_ptop(rx[IPv6].src), intf.local_ip6)
99
100 # Src link-layer options should have the router's MAC
101 sll = rx[ICMPv6NDOptSrcLLAddr]
102 self.assertEqual(sll.lladdr, intf.local_mac)
103
Neale Ranns3f844d02017-02-18 00:03:54 -0800104 def send_and_expect_ra(self, intf, pkts, remark, dst_ip=None,
105 filter_out_fn=is_ipv6_misc):
106 intf.add_stream(pkts)
Neale Ranns3f844d02017-02-18 00:03:54 -0800107 self.pg_enable_capture(self.pg_interfaces)
108 self.pg_start()
109 rx = intf.get_capture(1, filter_out_fn=filter_out_fn)
110
111 self.assertEqual(len(rx), 1)
112 rx = rx[0]
113 self.validate_ra(intf, rx, dst_ip)
114
Neale Ranns2a3ea492017-04-19 05:24:40 -0700115 def send_and_expect_na(self, intf, pkts, remark, dst_ip=None,
116 tgt_ip=None,
117 filter_out_fn=is_ipv6_misc):
118 intf.add_stream(pkts)
119 self.pg_enable_capture(self.pg_interfaces)
120 self.pg_start()
121 rx = intf.get_capture(1, filter_out_fn=filter_out_fn)
122
123 self.assertEqual(len(rx), 1)
124 rx = rx[0]
125 self.validate_na(intf, rx, dst_ip, tgt_ip)
126
Neale Rannsdcd6d622017-05-26 02:59:16 -0700127 def send_and_expect_ns(self, tx_intf, rx_intf, pkts, tgt_ip,
128 filter_out_fn=is_ipv6_misc):
129 tx_intf.add_stream(pkts)
130 self.pg_enable_capture(self.pg_interfaces)
131 self.pg_start()
132 rx = rx_intf.get_capture(1, filter_out_fn=filter_out_fn)
133
134 self.assertEqual(len(rx), 1)
135 rx = rx[0]
136 self.validate_ns(rx_intf, rx, tgt_ip)
137
Neale Ranns3f844d02017-02-18 00:03:54 -0800138 def send_and_assert_no_replies(self, intf, pkts, remark):
139 intf.add_stream(pkts)
140 self.pg_enable_capture(self.pg_interfaces)
141 self.pg_start()
Neale Ranns2a3ea492017-04-19 05:24:40 -0700142 for i in self.pg_interfaces:
143 i.get_capture(0)
144 i.assert_nothing_captured(remark=remark)
Neale Ranns3f844d02017-02-18 00:03:54 -0800145
Neale Rannsdcd6d622017-05-26 02:59:16 -0700146 def verify_ip(self, rx, smac, dmac, sip, dip):
147 ether = rx[Ether]
148 self.assertEqual(ether.dst, dmac)
149 self.assertEqual(ether.src, smac)
150
151 ip = rx[IPv6]
152 self.assertEqual(ip.src, sip)
153 self.assertEqual(ip.dst, dip)
154
Neale Ranns3f844d02017-02-18 00:03:54 -0800155
156class TestIPv6(TestIPv6ND):
Damjan Marionf56b77a2016-10-03 19:44:57 +0200157 """ IPv6 Test Case """
158
159 @classmethod
160 def setUpClass(cls):
161 super(TestIPv6, cls).setUpClass()
162
Klement Sekeraf62ae122016-10-11 11:47:09 +0200163 def setUp(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100164 """
165 Perform test setup before test case.
166
167 **Config:**
168 - create 3 pg interfaces
169 - untagged pg0 interface
170 - Dot1Q subinterface on pg1
171 - Dot1AD subinterface on pg2
172 - setup interfaces:
173 - put it into UP state
174 - set IPv6 addresses
175 - resolve neighbor address using NDP
176 - configure 200 fib entries
177
178 :ivar list interfaces: pg interfaces and subinterfaces.
179 :ivar dict flows: IPv4 packet flows in test.
180 :ivar list pg_if_packet_sizes: packet sizes in test.
181
182 *TODO:* Create AD sub interface
183 """
Klement Sekeraf62ae122016-10-11 11:47:09 +0200184 super(TestIPv6, self).setUp()
Damjan Marionf56b77a2016-10-03 19:44:57 +0200185
Klement Sekeraf62ae122016-10-11 11:47:09 +0200186 # create 3 pg interfaces
187 self.create_pg_interfaces(range(3))
Damjan Marionf56b77a2016-10-03 19:44:57 +0200188
Klement Sekeraf62ae122016-10-11 11:47:09 +0200189 # create 2 subinterfaces for p1 and pg2
190 self.sub_interfaces = [
191 VppDot1QSubint(self, self.pg1, 100),
Matej Klotton86d87c42016-11-11 11:38:55 +0100192 VppDot1QSubint(self, self.pg2, 200)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200193 # TODO: VppDot1ADSubint(self, self.pg2, 200, 300, 400)
Matej Klotton86d87c42016-11-11 11:38:55 +0100194 ]
Damjan Marionf56b77a2016-10-03 19:44:57 +0200195
Klement Sekeraf62ae122016-10-11 11:47:09 +0200196 # packet flows mapping pg0 -> pg1.sub, pg2.sub, etc.
197 self.flows = dict()
198 self.flows[self.pg0] = [self.pg1.sub_if, self.pg2.sub_if]
199 self.flows[self.pg1.sub_if] = [self.pg0, self.pg2.sub_if]
200 self.flows[self.pg2.sub_if] = [self.pg0, self.pg1.sub_if]
Damjan Marionf56b77a2016-10-03 19:44:57 +0200201
Klement Sekeraf62ae122016-10-11 11:47:09 +0200202 # packet sizes
203 self.pg_if_packet_sizes = [64, 512, 1518, 9018]
204 self.sub_if_packet_sizes = [64, 512, 1518 + 4, 9018 + 4]
Damjan Marionf56b77a2016-10-03 19:44:57 +0200205
Klement Sekeraf62ae122016-10-11 11:47:09 +0200206 self.interfaces = list(self.pg_interfaces)
207 self.interfaces.extend(self.sub_interfaces)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200208
Klement Sekeraf62ae122016-10-11 11:47:09 +0200209 # setup all interfaces
210 for i in self.interfaces:
211 i.admin_up()
212 i.config_ip6()
213 i.resolve_ndp()
214
Matej Klotton86d87c42016-11-11 11:38:55 +0100215 # config 2M FIB entries
Klement Sekeraf62ae122016-10-11 11:47:09 +0200216 self.config_fib_entries(200)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200217
218 def tearDown(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100219 """Run standard test teardown and log ``show ip6 neighbors``."""
Neale Ranns75152282017-01-09 01:00:45 -0800220 for i in self.sub_interfaces:
221 i.unconfig_ip6()
222 i.ip6_disable()
223 i.admin_down()
224 i.remove_vpp_config()
225
Klement Sekeraf62ae122016-10-11 11:47:09 +0200226 super(TestIPv6, self).tearDown()
227 if not self.vpp_dead:
Matej Klotton86d87c42016-11-11 11:38:55 +0100228 self.logger.info(self.vapi.cli("show ip6 neighbors"))
Klement Sekeraf62ae122016-10-11 11:47:09 +0200229 # info(self.vapi.cli("show ip6 fib")) # many entries
Damjan Marionf56b77a2016-10-03 19:44:57 +0200230
Klement Sekeraf62ae122016-10-11 11:47:09 +0200231 def config_fib_entries(self, count):
Matej Klotton86d87c42016-11-11 11:38:55 +0100232 """For each interface add to the FIB table *count* routes to
233 "fd02::1/128" destination with interface's local address as next-hop
234 address.
235
236 :param int count: Number of FIB entries.
237
238 - *TODO:* check if the next-hop address shouldn't be remote address
239 instead of local address.
240 """
Klement Sekeraf62ae122016-10-11 11:47:09 +0200241 n_int = len(self.interfaces)
242 percent = 0
243 counter = 0.0
Neale Ranns3f844d02017-02-18 00:03:54 -0800244 dest_addr = inet_pton(AF_INET6, "fd02::1")
Klement Sekeraf62ae122016-10-11 11:47:09 +0200245 dest_addr_len = 128
246 for i in self.interfaces:
247 next_hop_address = i.local_ip6n
248 for j in range(count / n_int):
249 self.vapi.ip_add_del_route(
250 dest_addr, dest_addr_len, next_hop_address, is_ipv6=1)
Matej Klotton86d87c42016-11-11 11:38:55 +0100251 counter += 1
Klement Sekeraf62ae122016-10-11 11:47:09 +0200252 if counter / count * 100 > percent:
Matej Klotton86d87c42016-11-11 11:38:55 +0100253 self.logger.info("Configure %d FIB entries .. %d%% done" %
Klement Sekera7bb873a2016-11-18 07:38:42 +0100254 (count, percent))
Matej Klotton86d87c42016-11-11 11:38:55 +0100255 percent += 1
Damjan Marionf56b77a2016-10-03 19:44:57 +0200256
Klement Sekeraf62ae122016-10-11 11:47:09 +0200257 def create_stream(self, src_if, packet_sizes):
Matej Klotton86d87c42016-11-11 11:38:55 +0100258 """Create input packet stream for defined interface.
259
260 :param VppInterface src_if: Interface to create packet stream for.
261 :param list packet_sizes: Required packet sizes.
262 """
Damjan Marionf56b77a2016-10-03 19:44:57 +0200263 pkts = []
264 for i in range(0, 257):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200265 dst_if = self.flows[src_if][i % 2]
Klement Sekeradab231a2016-12-21 08:50:14 +0100266 info = self.create_packet_info(src_if, dst_if)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200267 payload = self.info_to_payload(info)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200268 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
269 IPv6(src=src_if.remote_ip6, dst=dst_if.remote_ip6) /
Damjan Marionf56b77a2016-10-03 19:44:57 +0200270 UDP(sport=1234, dport=1234) /
271 Raw(payload))
272 info.data = p.copy()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200273 if isinstance(src_if, VppSubInterface):
274 p = src_if.add_dot1_layer(p)
275 size = packet_sizes[(i // 2) % len(packet_sizes)]
Damjan Marionf56b77a2016-10-03 19:44:57 +0200276 self.extend_packet(p, size)
277 pkts.append(p)
278 return pkts
279
Klement Sekeraf62ae122016-10-11 11:47:09 +0200280 def verify_capture(self, dst_if, capture):
Matej Klotton86d87c42016-11-11 11:38:55 +0100281 """Verify captured input packet stream for defined interface.
282
283 :param VppInterface dst_if: Interface to verify captured packet stream
284 for.
285 :param list capture: Captured packet stream.
286 """
287 self.logger.info("Verifying capture on interface %s" % dst_if.name)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200288 last_info = dict()
Damjan Marionf56b77a2016-10-03 19:44:57 +0200289 for i in self.interfaces:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200290 last_info[i.sw_if_index] = None
291 is_sub_if = False
292 dst_sw_if_index = dst_if.sw_if_index
293 if hasattr(dst_if, 'parent'):
294 is_sub_if = True
Damjan Marionf56b77a2016-10-03 19:44:57 +0200295 for packet in capture:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200296 if is_sub_if:
297 # Check VLAN tags and Ethernet header
298 packet = dst_if.remove_dot1_layer(packet)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200299 self.assertTrue(Dot1Q not in packet)
300 try:
301 ip = packet[IPv6]
302 udp = packet[UDP]
303 payload_info = self.payload_to_info(str(packet[Raw]))
304 packet_index = payload_info.index
Klement Sekeraf62ae122016-10-11 11:47:09 +0200305 self.assertEqual(payload_info.dst, dst_sw_if_index)
Klement Sekerada505f62017-01-04 12:58:53 +0100306 self.logger.debug(
307 "Got packet on port %s: src=%u (id=%u)" %
308 (dst_if.name, payload_info.src, packet_index))
Klement Sekeraf62ae122016-10-11 11:47:09 +0200309 next_info = self.get_next_packet_info_for_interface2(
310 payload_info.src, dst_sw_if_index,
311 last_info[payload_info.src])
312 last_info[payload_info.src] = next_info
Damjan Marionf56b77a2016-10-03 19:44:57 +0200313 self.assertTrue(next_info is not None)
314 self.assertEqual(packet_index, next_info.index)
315 saved_packet = next_info.data
316 # Check standard fields
317 self.assertEqual(ip.src, saved_packet[IPv6].src)
318 self.assertEqual(ip.dst, saved_packet[IPv6].dst)
319 self.assertEqual(udp.sport, saved_packet[UDP].sport)
320 self.assertEqual(udp.dport, saved_packet[UDP].dport)
321 except:
Klement Sekera7bb873a2016-11-18 07:38:42 +0100322 self.logger.error(ppp("Unexpected or invalid packet:", packet))
Damjan Marionf56b77a2016-10-03 19:44:57 +0200323 raise
324 for i in self.interfaces:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200325 remaining_packet = self.get_next_packet_info_for_interface2(
326 i.sw_if_index, dst_sw_if_index, last_info[i.sw_if_index])
Klement Sekera7bb873a2016-11-18 07:38:42 +0100327 self.assertTrue(remaining_packet is None,
328 "Interface %s: Packet expected from interface %s "
329 "didn't arrive" % (dst_if.name, i.name))
Damjan Marionf56b77a2016-10-03 19:44:57 +0200330
331 def test_fib(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100332 """ IPv6 FIB test
333
334 Test scenario:
335 - Create IPv6 stream for pg0 interface
336 - Create IPv6 tagged streams for pg1's and pg2's subinterface.
337 - Send and verify received packets on each interface.
338 """
Damjan Marionf56b77a2016-10-03 19:44:57 +0200339
Klement Sekeraf62ae122016-10-11 11:47:09 +0200340 pkts = self.create_stream(self.pg0, self.pg_if_packet_sizes)
341 self.pg0.add_stream(pkts)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200342
Klement Sekeraf62ae122016-10-11 11:47:09 +0200343 for i in self.sub_interfaces:
344 pkts = self.create_stream(i, self.sub_if_packet_sizes)
345 i.parent.add_stream(pkts)
346
347 self.pg_enable_capture(self.pg_interfaces)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200348 self.pg_start()
349
Klement Sekeraf62ae122016-10-11 11:47:09 +0200350 pkts = self.pg0.get_capture()
351 self.verify_capture(self.pg0, pkts)
352
353 for i in self.sub_interfaces:
354 pkts = i.parent.get_capture()
355 self.verify_capture(i, pkts)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200356
Neale Ranns75152282017-01-09 01:00:45 -0800357 def test_ns(self):
Klement Sekerada505f62017-01-04 12:58:53 +0100358 """ IPv6 Neighbour Solicitation Exceptions
Neale Ranns75152282017-01-09 01:00:45 -0800359
Klement Sekerada505f62017-01-04 12:58:53 +0100360 Test scenario:
Neale Ranns75152282017-01-09 01:00:45 -0800361 - Send an NS Sourced from an address not covered by the link sub-net
362 - Send an NS to an mcast address the router has not joined
363 - Send NS for a target address the router does not onn.
364 """
365
366 #
367 # An NS from a non link source address
368 #
Neale Ranns3f844d02017-02-18 00:03:54 -0800369 nsma = in6_getnsma(inet_pton(AF_INET6, self.pg0.local_ip6))
370 d = inet_ntop(AF_INET6, nsma)
Neale Ranns75152282017-01-09 01:00:45 -0800371
372 p = (Ether(dst=in6_getnsmac(nsma)) /
373 IPv6(dst=d, src="2002::2") /
374 ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
375 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
376 pkts = [p]
377
Klement Sekerada505f62017-01-04 12:58:53 +0100378 self.send_and_assert_no_replies(
379 self.pg0, pkts,
380 "No response to NS source by address not on sub-net")
Neale Ranns75152282017-01-09 01:00:45 -0800381
382 #
Klement Sekerada505f62017-01-04 12:58:53 +0100383 # An NS for sent to a solicited mcast group the router is
384 # not a member of FAILS
Neale Ranns75152282017-01-09 01:00:45 -0800385 #
386 if 0:
Neale Ranns3f844d02017-02-18 00:03:54 -0800387 nsma = in6_getnsma(inet_pton(AF_INET6, "fd::ffff"))
388 d = inet_ntop(AF_INET6, nsma)
Neale Ranns75152282017-01-09 01:00:45 -0800389
390 p = (Ether(dst=in6_getnsmac(nsma)) /
391 IPv6(dst=d, src=self.pg0.remote_ip6) /
392 ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
393 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
394 pkts = [p]
395
Klement Sekerada505f62017-01-04 12:58:53 +0100396 self.send_and_assert_no_replies(
397 self.pg0, pkts,
398 "No response to NS sent to unjoined mcast address")
Neale Ranns75152282017-01-09 01:00:45 -0800399
400 #
401 # An NS whose target address is one the router does not own
402 #
Neale Ranns3f844d02017-02-18 00:03:54 -0800403 nsma = in6_getnsma(inet_pton(AF_INET6, self.pg0.local_ip6))
404 d = inet_ntop(AF_INET6, nsma)
Neale Ranns75152282017-01-09 01:00:45 -0800405
406 p = (Ether(dst=in6_getnsmac(nsma)) /
407 IPv6(dst=d, src=self.pg0.remote_ip6) /
408 ICMPv6ND_NS(tgt="fd::ffff") /
409 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
410 pkts = [p]
411
412 self.send_and_assert_no_replies(self.pg0, pkts,
413 "No response to NS for unknown target")
414
Neale Rannsb3b2de72017-03-08 05:17:22 -0800415 #
416 # A neighbor entry that has no associated FIB-entry
417 #
418 self.pg0.generate_remote_hosts(4)
419 nd_entry = VppNeighbor(self,
420 self.pg0.sw_if_index,
421 self.pg0.remote_hosts[2].mac,
422 self.pg0.remote_hosts[2].ip6,
423 af=AF_INET6,
424 is_no_fib_entry=1)
425 nd_entry.add_vpp_config()
426
427 #
428 # check we have the neighbor, but no route
429 #
430 self.assertTrue(find_nbr(self,
431 self.pg0.sw_if_index,
432 self.pg0._remote_hosts[2].ip6,
433 inet=AF_INET6))
434 self.assertFalse(find_route(self,
435 self.pg0._remote_hosts[2].ip6,
436 128,
437 inet=AF_INET6))
438
Neale Ranns2a3ea492017-04-19 05:24:40 -0700439 #
440 # send an NS from a link local address to the interface's global
441 # address
442 #
443 p = (Ether(dst=in6_getnsmac(nsma), src=self.pg0.remote_mac) /
444 IPv6(dst=d, src=self.pg0._remote_hosts[2].ip6_ll) /
445 ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
446 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
447
448 self.send_and_expect_na(self.pg0, p,
449 "NS from link-local",
450 dst_ip=self.pg0._remote_hosts[2].ip6_ll,
451 tgt_ip=self.pg0.local_ip6)
452
453 #
454 # we should have learned an ND entry for the peer's link-local
455 # but not inserted a route to it in the FIB
456 #
457 self.assertTrue(find_nbr(self,
458 self.pg0.sw_if_index,
459 self.pg0._remote_hosts[2].ip6_ll,
460 inet=AF_INET6))
461 self.assertFalse(find_route(self,
462 self.pg0._remote_hosts[2].ip6_ll,
463 128,
464 inet=AF_INET6))
465
466 #
467 # An NS to the router's own Link-local
468 #
469 p = (Ether(dst=in6_getnsmac(nsma), src=self.pg0.remote_mac) /
470 IPv6(dst=d, src=self.pg0._remote_hosts[3].ip6_ll) /
471 ICMPv6ND_NS(tgt=self.pg0.local_ip6_ll) /
472 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
473
474 self.send_and_expect_na(self.pg0, p,
475 "NS to/from link-local",
476 dst_ip=self.pg0._remote_hosts[3].ip6_ll,
477 tgt_ip=self.pg0.local_ip6_ll)
478
479 #
480 # we should have learned an ND entry for the peer's link-local
481 # but not inserted a route to it in the FIB
482 #
483 self.assertTrue(find_nbr(self,
484 self.pg0.sw_if_index,
485 self.pg0._remote_hosts[3].ip6_ll,
486 inet=AF_INET6))
487 self.assertFalse(find_route(self,
488 self.pg0._remote_hosts[3].ip6_ll,
489 128,
490 inet=AF_INET6))
491
Neale Rannsdcd6d622017-05-26 02:59:16 -0700492 def test_ns_duplicates(self):
Neale Rannsda78f952017-05-24 09:15:43 -0700493 """ ND Duplicates"""
Neale Rannsdcd6d622017-05-26 02:59:16 -0700494
495 #
496 # Generate some hosts on the LAN
497 #
498 self.pg1.generate_remote_hosts(3)
499
500 #
501 # Add host 1 on pg1 and pg2
502 #
503 ns_pg1 = VppNeighbor(self,
504 self.pg1.sw_if_index,
505 self.pg1.remote_hosts[1].mac,
506 self.pg1.remote_hosts[1].ip6,
507 af=AF_INET6)
508 ns_pg1.add_vpp_config()
509 ns_pg2 = VppNeighbor(self,
510 self.pg2.sw_if_index,
511 self.pg2.remote_mac,
512 self.pg1.remote_hosts[1].ip6,
513 af=AF_INET6)
514 ns_pg2.add_vpp_config()
515
516 #
517 # IP packet destined for pg1 remote host arrives on pg1 again.
518 #
519 p = (Ether(dst=self.pg0.local_mac,
520 src=self.pg0.remote_mac) /
521 IPv6(src=self.pg0.remote_ip6,
522 dst=self.pg1.remote_hosts[1].ip6) /
523 UDP(sport=1234, dport=1234) /
524 Raw())
525
526 self.pg0.add_stream(p)
527 self.pg_enable_capture(self.pg_interfaces)
528 self.pg_start()
529
530 rx1 = self.pg1.get_capture(1)
531
532 self.verify_ip(rx1[0],
533 self.pg1.local_mac,
534 self.pg1.remote_hosts[1].mac,
535 self.pg0.remote_ip6,
536 self.pg1.remote_hosts[1].ip6)
537
538 #
539 # remove the duplicate on pg1
Neale Rannsda78f952017-05-24 09:15:43 -0700540 # packet stream shoud generate NSs out of pg1
Neale Rannsdcd6d622017-05-26 02:59:16 -0700541 #
542 ns_pg1.remove_vpp_config()
543
544 self.send_and_expect_ns(self.pg0, self.pg1,
545 p, self.pg1.remote_hosts[1].ip6)
546
547 #
548 # Add it back
549 #
550 ns_pg1.add_vpp_config()
551
552 self.pg0.add_stream(p)
553 self.pg_enable_capture(self.pg_interfaces)
554 self.pg_start()
555
556 rx1 = self.pg1.get_capture(1)
557
558 self.verify_ip(rx1[0],
559 self.pg1.local_mac,
560 self.pg1.remote_hosts[1].mac,
561 self.pg0.remote_ip6,
562 self.pg1.remote_hosts[1].ip6)
563
Neale Ranns87df12d2017-02-18 08:16:41 -0800564 def validate_ra(self, intf, rx, dst_ip=None, mtu=9000, pi_opt=None):
Neale Ranns32e1c012016-11-22 17:07:28 +0000565 if not dst_ip:
566 dst_ip = intf.remote_ip6
Neale Ranns75152282017-01-09 01:00:45 -0800567
Neale Ranns5737d882017-02-03 06:14:49 -0800568 # unicasted packets must come to the unicast mac
Neale Ranns32e1c012016-11-22 17:07:28 +0000569 self.assertEqual(rx[Ether].dst, intf.remote_mac)
570
571 # and from the router's MAC
572 self.assertEqual(rx[Ether].src, intf.local_mac)
Neale Ranns75152282017-01-09 01:00:45 -0800573
574 # the rx'd RA should be addressed to the sender's source
575 self.assertTrue(rx.haslayer(ICMPv6ND_RA))
576 self.assertEqual(in6_ptop(rx[IPv6].dst),
Neale Ranns32e1c012016-11-22 17:07:28 +0000577 in6_ptop(dst_ip))
Neale Ranns75152282017-01-09 01:00:45 -0800578
579 # and come from the router's link local
580 self.assertTrue(in6_islladdr(rx[IPv6].src))
581 self.assertEqual(in6_ptop(rx[IPv6].src),
582 in6_ptop(mk_ll_addr(intf.local_mac)))
583
Neale Ranns87df12d2017-02-18 08:16:41 -0800584 # it should contain the links MTU
585 ra = rx[ICMPv6ND_RA]
586 self.assertEqual(ra[ICMPv6NDOptMTU].mtu, mtu)
587
588 # it should contain the source's link layer address option
589 sll = ra[ICMPv6NDOptSrcLLAddr]
590 self.assertEqual(sll.lladdr, intf.local_mac)
591
592 if not pi_opt:
593 # the RA should not contain prefix information
594 self.assertFalse(ra.haslayer(ICMPv6NDOptPrefixInfo))
595 else:
596 raos = rx.getlayer(ICMPv6NDOptPrefixInfo, 1)
597
598 # the options are nested in the scapy packet in way that i cannot
599 # decipher how to decode. this 1st layer of option always returns
600 # nested classes, so a direct obj1=obj2 comparison always fails.
601 # however, the getlayer(.., 2) does give one instnace.
602 # so we cheat here and construct a new opt instnace for comparison
603 rd = ICMPv6NDOptPrefixInfo(prefixlen=raos.prefixlen,
604 prefix=raos.prefix,
605 L=raos.L,
606 A=raos.A)
607 if type(pi_opt) is list:
608 for ii in range(len(pi_opt)):
609 self.assertEqual(pi_opt[ii], rd)
610 rd = rx.getlayer(ICMPv6NDOptPrefixInfo, ii+2)
611 else:
612 self.assertEqual(pi_opt, raos)
613
Neale Ranns32e1c012016-11-22 17:07:28 +0000614 def send_and_expect_ra(self, intf, pkts, remark, dst_ip=None,
Neale Ranns87df12d2017-02-18 08:16:41 -0800615 filter_out_fn=is_ipv6_misc,
616 opt=None):
Neale Ranns32e1c012016-11-22 17:07:28 +0000617 intf.add_stream(pkts)
Neale Ranns32e1c012016-11-22 17:07:28 +0000618 self.pg_enable_capture(self.pg_interfaces)
619 self.pg_start()
620 rx = intf.get_capture(1, filter_out_fn=filter_out_fn)
621
622 self.assertEqual(len(rx), 1)
623 rx = rx[0]
Neale Ranns87df12d2017-02-18 08:16:41 -0800624 self.validate_ra(intf, rx, dst_ip, pi_opt=opt)
Neale Ranns32e1c012016-11-22 17:07:28 +0000625
Neale Ranns75152282017-01-09 01:00:45 -0800626 def test_rs(self):
Klement Sekerada505f62017-01-04 12:58:53 +0100627 """ IPv6 Router Solicitation Exceptions
Neale Ranns75152282017-01-09 01:00:45 -0800628
Klement Sekerada505f62017-01-04 12:58:53 +0100629 Test scenario:
Neale Ranns75152282017-01-09 01:00:45 -0800630 """
631
632 #
Klement Sekerada505f62017-01-04 12:58:53 +0100633 # Before we begin change the IPv6 RA responses to use the unicast
634 # address - that way we will not confuse them with the periodic
635 # RAs which go to the mcast address
Neale Ranns32e1c012016-11-22 17:07:28 +0000636 # Sit and wait for the first periodic RA.
637 #
638 # TODO
Neale Ranns75152282017-01-09 01:00:45 -0800639 #
640 self.pg0.ip6_ra_config(send_unicast=1)
641
642 #
643 # An RS from a link source address
644 # - expect an RA in return
645 #
646 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
647 IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) /
648 ICMPv6ND_RS())
649 pkts = [p]
650 self.send_and_expect_ra(self.pg0, pkts, "Genuine RS")
651
652 #
653 # For the next RS sent the RA should be rate limited
654 #
655 self.send_and_assert_no_replies(self.pg0, pkts, "RA rate limited")
656
657 #
658 # When we reconfiure the IPv6 RA config, we reset the RA rate limiting,
Klement Sekerada505f62017-01-04 12:58:53 +0100659 # so we need to do this before each test below so as not to drop
660 # packets for rate limiting reasons. Test this works here.
Neale Ranns75152282017-01-09 01:00:45 -0800661 #
662 self.pg0.ip6_ra_config(send_unicast=1)
663 self.send_and_expect_ra(self.pg0, pkts, "Rate limit reset RS")
664
665 #
666 # An RS sent from a non-link local source
667 #
668 self.pg0.ip6_ra_config(send_unicast=1)
669 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
670 IPv6(dst=self.pg0.local_ip6, src="2002::ffff") /
671 ICMPv6ND_RS())
672 pkts = [p]
673 self.send_and_assert_no_replies(self.pg0, pkts,
674 "RS from non-link source")
675
676 #
677 # Source an RS from a link local address
678 #
679 self.pg0.ip6_ra_config(send_unicast=1)
680 ll = mk_ll_addr(self.pg0.remote_mac)
681 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
682 IPv6(dst=self.pg0.local_ip6, src=ll) /
683 ICMPv6ND_RS())
684 pkts = [p]
Neale Ranns32e1c012016-11-22 17:07:28 +0000685 self.send_and_expect_ra(self.pg0, pkts,
686 "RS sourced from link-local",
687 dst_ip=ll)
688
689 #
690 # Send the RS multicast
691 #
692 self.pg0.ip6_ra_config(send_unicast=1)
Neale Ranns3f844d02017-02-18 00:03:54 -0800693 dmac = in6_getnsmac(inet_pton(AF_INET6, "ff02::2"))
Neale Ranns32e1c012016-11-22 17:07:28 +0000694 ll = mk_ll_addr(self.pg0.remote_mac)
695 p = (Ether(dst=dmac, src=self.pg0.remote_mac) /
696 IPv6(dst="ff02::2", src=ll) /
697 ICMPv6ND_RS())
698 pkts = [p]
699 self.send_and_expect_ra(self.pg0, pkts,
700 "RS sourced from link-local",
701 dst_ip=ll)
Neale Ranns75152282017-01-09 01:00:45 -0800702
703 #
Klement Sekerada505f62017-01-04 12:58:53 +0100704 # Source from the unspecified address ::. This happens when the RS
705 # is sent before the host has a configured address/sub-net,
706 # i.e. auto-config. Since the sender has no IP address, the reply
707 # comes back mcast - so the capture needs to not filter this.
708 # If we happen to pick up the periodic RA at this point then so be it,
709 # it's not an error.
Neale Ranns75152282017-01-09 01:00:45 -0800710 #
Neale Ranns32e1c012016-11-22 17:07:28 +0000711 self.pg0.ip6_ra_config(send_unicast=1, suppress=1)
712 p = (Ether(dst=dmac, src=self.pg0.remote_mac) /
713 IPv6(dst="ff02::2", src="::") /
Neale Ranns75152282017-01-09 01:00:45 -0800714 ICMPv6ND_RS())
715 pkts = [p]
Neale Ranns32e1c012016-11-22 17:07:28 +0000716 self.send_and_expect_ra(self.pg0, pkts,
717 "RS sourced from unspecified",
718 dst_ip="ff02::1",
719 filter_out_fn=None)
Neale Ranns75152282017-01-09 01:00:45 -0800720
721 #
Neale Ranns87df12d2017-02-18 08:16:41 -0800722 # Configure The RA to announce the links prefix
723 #
724 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
725 self.pg0.local_ip6_prefix_len)
726
727 #
728 # RAs should now contain the prefix information option
729 #
730 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
731 prefix=self.pg0.local_ip6,
732 L=1,
733 A=1)
734
735 self.pg0.ip6_ra_config(send_unicast=1)
736 ll = mk_ll_addr(self.pg0.remote_mac)
737 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
738 IPv6(dst=self.pg0.local_ip6, src=ll) /
739 ICMPv6ND_RS())
740 self.send_and_expect_ra(self.pg0, p,
741 "RA with prefix-info",
742 dst_ip=ll,
743 opt=opt)
744
745 #
746 # Change the prefix info to not off-link
747 # L-flag is clear
748 #
749 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
750 self.pg0.local_ip6_prefix_len,
751 off_link=1)
752
753 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
754 prefix=self.pg0.local_ip6,
755 L=0,
756 A=1)
757
758 self.pg0.ip6_ra_config(send_unicast=1)
759 self.send_and_expect_ra(self.pg0, p,
760 "RA with Prefix info with L-flag=0",
761 dst_ip=ll,
762 opt=opt)
763
764 #
765 # Change the prefix info to not off-link, no-autoconfig
766 # L and A flag are clear in the advert
767 #
768 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
769 self.pg0.local_ip6_prefix_len,
770 off_link=1,
771 no_autoconfig=1)
772
773 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
774 prefix=self.pg0.local_ip6,
775 L=0,
776 A=0)
777
778 self.pg0.ip6_ra_config(send_unicast=1)
779 self.send_and_expect_ra(self.pg0, p,
780 "RA with Prefix info with A & L-flag=0",
781 dst_ip=ll,
782 opt=opt)
783
784 #
785 # Change the flag settings back to the defaults
786 # L and A flag are set in the advert
787 #
788 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
789 self.pg0.local_ip6_prefix_len)
790
791 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
792 prefix=self.pg0.local_ip6,
793 L=1,
794 A=1)
795
796 self.pg0.ip6_ra_config(send_unicast=1)
797 self.send_and_expect_ra(self.pg0, p,
798 "RA with Prefix info",
799 dst_ip=ll,
800 opt=opt)
801
802 #
803 # Change the prefix info to not off-link, no-autoconfig
804 # L and A flag are clear in the advert
805 #
806 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
807 self.pg0.local_ip6_prefix_len,
808 off_link=1,
809 no_autoconfig=1)
810
811 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
812 prefix=self.pg0.local_ip6,
813 L=0,
814 A=0)
815
816 self.pg0.ip6_ra_config(send_unicast=1)
817 self.send_and_expect_ra(self.pg0, p,
818 "RA with Prefix info with A & L-flag=0",
819 dst_ip=ll,
820 opt=opt)
821
822 #
823 # Use the reset to defults option to revert to defaults
824 # L and A flag are clear in the advert
825 #
826 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
827 self.pg0.local_ip6_prefix_len,
828 use_default=1)
829
830 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
831 prefix=self.pg0.local_ip6,
832 L=1,
833 A=1)
834
835 self.pg0.ip6_ra_config(send_unicast=1)
836 self.send_and_expect_ra(self.pg0, p,
837 "RA with Prefix reverted to defaults",
838 dst_ip=ll,
839 opt=opt)
840
841 #
842 # Advertise Another prefix. With no L-flag/A-flag
843 #
844 self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
845 self.pg1.local_ip6_prefix_len,
846 off_link=1,
847 no_autoconfig=1)
848
849 opt = [ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
850 prefix=self.pg0.local_ip6,
851 L=1,
852 A=1),
853 ICMPv6NDOptPrefixInfo(prefixlen=self.pg1.local_ip6_prefix_len,
854 prefix=self.pg1.local_ip6,
855 L=0,
856 A=0)]
857
858 self.pg0.ip6_ra_config(send_unicast=1)
859 ll = mk_ll_addr(self.pg0.remote_mac)
860 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
861 IPv6(dst=self.pg0.local_ip6, src=ll) /
862 ICMPv6ND_RS())
863 self.send_and_expect_ra(self.pg0, p,
864 "RA with multiple Prefix infos",
865 dst_ip=ll,
866 opt=opt)
867
868 #
869 # Remove the first refix-info - expect the second is still in the
870 # advert
871 #
872 self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
873 self.pg0.local_ip6_prefix_len,
874 is_no=1)
875
876 opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg1.local_ip6_prefix_len,
877 prefix=self.pg1.local_ip6,
878 L=0,
879 A=0)
880
881 self.pg0.ip6_ra_config(send_unicast=1)
882 self.send_and_expect_ra(self.pg0, p,
883 "RA with Prefix reverted to defaults",
884 dst_ip=ll,
885 opt=opt)
886
887 #
888 # Remove the second prefix-info - expect no prefix-info i nthe adverts
889 #
890 self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
891 self.pg1.local_ip6_prefix_len,
892 is_no=1)
893
894 self.pg0.ip6_ra_config(send_unicast=1)
895 self.send_and_expect_ra(self.pg0, p,
896 "RA with Prefix reverted to defaults",
897 dst_ip=ll)
898
899 #
Neale Ranns5737d882017-02-03 06:14:49 -0800900 # Reset the periodic advertisements back to default values
Neale Ranns75152282017-01-09 01:00:45 -0800901 #
Neale Ranns32e1c012016-11-22 17:07:28 +0000902 self.pg0.ip6_ra_config(no=1, suppress=1, send_unicast=0)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200903
Neale Ranns3f844d02017-02-18 00:03:54 -0800904
905class IPv6NDProxyTest(TestIPv6ND):
906 """ IPv6 ND ProxyTest Case """
907
908 def setUp(self):
909 super(IPv6NDProxyTest, self).setUp()
910
911 # create 3 pg interfaces
912 self.create_pg_interfaces(range(3))
913
914 # pg0 is the master interface, with the configured subnet
915 self.pg0.admin_up()
916 self.pg0.config_ip6()
917 self.pg0.resolve_ndp()
918
919 self.pg1.ip6_enable()
920 self.pg2.ip6_enable()
921
922 def tearDown(self):
923 super(IPv6NDProxyTest, self).tearDown()
924
925 def test_nd_proxy(self):
926 """ IPv6 Proxy ND """
927
928 #
929 # Generate some hosts in the subnet that we are proxying
930 #
931 self.pg0.generate_remote_hosts(8)
932
933 nsma = in6_getnsma(inet_pton(AF_INET6, self.pg0.local_ip6))
934 d = inet_ntop(AF_INET6, nsma)
935
936 #
937 # Send an NS for one of those remote hosts on one of the proxy links
938 # expect no response since it's from an address that is not
939 # on the link that has the prefix configured
940 #
941 ns_pg1 = (Ether(dst=in6_getnsmac(nsma), src=self.pg1.remote_mac) /
942 IPv6(dst=d, src=self.pg0._remote_hosts[2].ip6) /
943 ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
944 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0._remote_hosts[2].mac))
945
946 self.send_and_assert_no_replies(self.pg1, ns_pg1, "Off link NS")
947
948 #
949 # Add proxy support for the host
950 #
951 self.vapi.ip6_nd_proxy(
952 inet_pton(AF_INET6, self.pg0._remote_hosts[2].ip6),
953 self.pg1.sw_if_index)
954
955 #
956 # try that NS again. this time we expect an NA back
957 #
Neale Ranns2a3ea492017-04-19 05:24:40 -0700958 self.send_and_expect_na(self.pg1, ns_pg1,
959 "NS to proxy entry",
960 dst_ip=self.pg0._remote_hosts[2].ip6,
961 tgt_ip=self.pg0.local_ip6)
Neale Ranns3f844d02017-02-18 00:03:54 -0800962
963 #
964 # ... and that we have an entry in the ND cache
965 #
966 self.assertTrue(find_nbr(self,
967 self.pg1.sw_if_index,
968 self.pg0._remote_hosts[2].ip6,
969 inet=AF_INET6))
970
971 #
972 # ... and we can route traffic to it
973 #
974 t = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
975 IPv6(dst=self.pg0._remote_hosts[2].ip6,
976 src=self.pg0.remote_ip6) /
977 UDP(sport=10000, dport=20000) /
978 Raw('\xa5' * 100))
979
980 self.pg0.add_stream(t)
981 self.pg_enable_capture(self.pg_interfaces)
982 self.pg_start()
983 rx = self.pg1.get_capture(1)
984 rx = rx[0]
985
986 self.assertEqual(rx[Ether].dst, self.pg0._remote_hosts[2].mac)
987 self.assertEqual(rx[Ether].src, self.pg1.local_mac)
988
989 self.assertEqual(rx[IPv6].src, t[IPv6].src)
990 self.assertEqual(rx[IPv6].dst, t[IPv6].dst)
991
992 #
993 # Test we proxy for the host on the main interface
994 #
995 ns_pg0 = (Ether(dst=in6_getnsmac(nsma), src=self.pg0.remote_mac) /
996 IPv6(dst=d, src=self.pg0.remote_ip6) /
997 ICMPv6ND_NS(tgt=self.pg0._remote_hosts[2].ip6) /
998 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0.remote_mac))
999
Neale Ranns2a3ea492017-04-19 05:24:40 -07001000 self.send_and_expect_na(self.pg0, ns_pg0,
1001 "NS to proxy entry on main",
1002 tgt_ip=self.pg0._remote_hosts[2].ip6,
1003 dst_ip=self.pg0.remote_ip6)
Neale Ranns3f844d02017-02-18 00:03:54 -08001004
1005 #
1006 # Setup and resolve proxy for another host on another interface
1007 #
1008 ns_pg2 = (Ether(dst=in6_getnsmac(nsma), src=self.pg2.remote_mac) /
1009 IPv6(dst=d, src=self.pg0._remote_hosts[3].ip6) /
1010 ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
1011 ICMPv6NDOptSrcLLAddr(lladdr=self.pg0._remote_hosts[2].mac))
1012
1013 self.vapi.ip6_nd_proxy(
1014 inet_pton(AF_INET6, self.pg0._remote_hosts[3].ip6),
1015 self.pg2.sw_if_index)
1016
Neale Ranns2a3ea492017-04-19 05:24:40 -07001017 self.send_and_expect_na(self.pg2, ns_pg2,
1018 "NS to proxy entry other interface",
1019 dst_ip=self.pg0._remote_hosts[3].ip6,
1020 tgt_ip=self.pg0.local_ip6)
Neale Ranns3f844d02017-02-18 00:03:54 -08001021
1022 self.assertTrue(find_nbr(self,
1023 self.pg2.sw_if_index,
1024 self.pg0._remote_hosts[3].ip6,
1025 inet=AF_INET6))
1026
1027 #
1028 # hosts can communicate. pg2->pg1
1029 #
1030 t2 = (Ether(dst=self.pg2.local_mac,
1031 src=self.pg0.remote_hosts[3].mac) /
1032 IPv6(dst=self.pg0._remote_hosts[2].ip6,
1033 src=self.pg0._remote_hosts[3].ip6) /
1034 UDP(sport=10000, dport=20000) /
1035 Raw('\xa5' * 100))
1036
1037 self.pg2.add_stream(t2)
1038 self.pg_enable_capture(self.pg_interfaces)
1039 self.pg_start()
1040 rx = self.pg1.get_capture(1)
1041 rx = rx[0]
1042
1043 self.assertEqual(rx[Ether].dst, self.pg0._remote_hosts[2].mac)
1044 self.assertEqual(rx[Ether].src, self.pg1.local_mac)
1045
1046 self.assertEqual(rx[IPv6].src, t2[IPv6].src)
1047 self.assertEqual(rx[IPv6].dst, t2[IPv6].dst)
1048
1049 #
1050 # remove the proxy configs
1051 #
1052 self.vapi.ip6_nd_proxy(
1053 inet_pton(AF_INET6, self.pg0._remote_hosts[2].ip6),
1054 self.pg1.sw_if_index,
1055 is_del=1)
1056 self.vapi.ip6_nd_proxy(
1057 inet_pton(AF_INET6, self.pg0._remote_hosts[3].ip6),
1058 self.pg2.sw_if_index,
1059 is_del=1)
1060
1061 self.assertFalse(find_nbr(self,
1062 self.pg2.sw_if_index,
1063 self.pg0._remote_hosts[3].ip6,
1064 inet=AF_INET6))
1065 self.assertFalse(find_nbr(self,
1066 self.pg1.sw_if_index,
1067 self.pg0._remote_hosts[2].ip6,
1068 inet=AF_INET6))
1069
1070 #
1071 # no longer proxy-ing...
1072 #
1073 self.send_and_assert_no_replies(self.pg0, ns_pg0, "Proxy unconfigured")
1074 self.send_and_assert_no_replies(self.pg1, ns_pg1, "Proxy unconfigured")
1075 self.send_and_assert_no_replies(self.pg2, ns_pg2, "Proxy unconfigured")
1076
1077 #
1078 # no longer forwarding. traffic generates NS out of the glean/main
1079 # interface
1080 #
1081 self.pg2.add_stream(t2)
1082 self.pg_enable_capture(self.pg_interfaces)
1083 self.pg_start()
1084
1085 rx = self.pg0.get_capture(1)
1086
1087 self.assertTrue(rx[0].haslayer(ICMPv6ND_NS))
1088
1089
Neale Ranns37be7362017-02-21 17:30:26 -08001090class TestIPNull(VppTestCase):
1091 """ IPv6 routes via NULL """
1092
1093 def setUp(self):
1094 super(TestIPNull, self).setUp()
1095
1096 # create 2 pg interfaces
1097 self.create_pg_interfaces(range(1))
1098
1099 for i in self.pg_interfaces:
1100 i.admin_up()
1101 i.config_ip6()
1102 i.resolve_ndp()
1103
1104 def tearDown(self):
1105 super(TestIPNull, self).tearDown()
1106 for i in self.pg_interfaces:
1107 i.unconfig_ip6()
1108 i.admin_down()
1109
1110 def test_ip_null(self):
1111 """ IP NULL route """
1112
1113 p = (Ether(src=self.pg0.remote_mac,
1114 dst=self.pg0.local_mac) /
1115 IPv6(src=self.pg0.remote_ip6, dst="2001::1") /
1116 UDP(sport=1234, dport=1234) /
1117 Raw('\xa5' * 100))
1118
1119 #
1120 # A route via IP NULL that will reply with ICMP unreachables
1121 #
1122 ip_unreach = VppIpRoute(self, "2001::", 64, [], is_unreach=1, is_ip6=1)
1123 ip_unreach.add_vpp_config()
1124
1125 self.pg0.add_stream(p)
1126 self.pg_enable_capture(self.pg_interfaces)
1127 self.pg_start()
1128
1129 rx = self.pg0.get_capture(1)
1130 rx = rx[0]
1131 icmp = rx[ICMPv6DestUnreach]
1132
1133 # 0 = "No route to destination"
1134 self.assertEqual(icmp.code, 0)
1135
1136 # ICMP is rate limited. pause a bit
1137 self.sleep(1)
1138
1139 #
1140 # A route via IP NULL that will reply with ICMP prohibited
1141 #
1142 ip_prohibit = VppIpRoute(self, "2001::1", 128, [],
1143 is_prohibit=1, is_ip6=1)
1144 ip_prohibit.add_vpp_config()
1145
1146 self.pg0.add_stream(p)
1147 self.pg_enable_capture(self.pg_interfaces)
1148 self.pg_start()
1149
1150 rx = self.pg0.get_capture(1)
1151 rx = rx[0]
1152 icmp = rx[ICMPv6DestUnreach]
1153
1154 # 1 = "Communication with destination administratively prohibited"
1155 self.assertEqual(icmp.code, 1)
1156
1157
Neale Ranns180279b2017-03-16 15:49:09 -04001158class TestIPDisabled(VppTestCase):
1159 """ IPv6 disabled """
1160
1161 def setUp(self):
1162 super(TestIPDisabled, self).setUp()
1163
1164 # create 2 pg interfaces
1165 self.create_pg_interfaces(range(2))
1166
1167 # PG0 is IP enalbed
1168 self.pg0.admin_up()
1169 self.pg0.config_ip6()
1170 self.pg0.resolve_ndp()
1171
1172 # PG 1 is not IP enabled
1173 self.pg1.admin_up()
1174
1175 def tearDown(self):
1176 super(TestIPDisabled, self).tearDown()
1177 for i in self.pg_interfaces:
1178 i.unconfig_ip4()
1179 i.admin_down()
1180
1181 def send_and_assert_no_replies(self, intf, pkts, remark):
1182 intf.add_stream(pkts)
1183 self.pg_enable_capture(self.pg_interfaces)
1184 self.pg_start()
1185 for i in self.pg_interfaces:
1186 i.get_capture(0)
1187 i.assert_nothing_captured(remark=remark)
1188
1189 def test_ip_disabled(self):
1190 """ IP Disabled """
1191
1192 #
1193 # An (S,G).
1194 # one accepting interface, pg0, 2 forwarding interfaces
1195 #
1196 route_ff_01 = VppIpMRoute(
1197 self,
1198 "::",
1199 "ffef::1", 128,
1200 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
1201 [VppMRoutePath(self.pg1.sw_if_index,
1202 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
1203 VppMRoutePath(self.pg0.sw_if_index,
1204 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)],
1205 is_ip6=1)
1206 route_ff_01.add_vpp_config()
1207
1208 pu = (Ether(src=self.pg1.remote_mac,
1209 dst=self.pg1.local_mac) /
1210 IPv6(src="2001::1", dst=self.pg0.remote_ip6) /
1211 UDP(sport=1234, dport=1234) /
1212 Raw('\xa5' * 100))
1213 pm = (Ether(src=self.pg1.remote_mac,
1214 dst=self.pg1.local_mac) /
1215 IPv6(src="2001::1", dst="ffef::1") /
1216 UDP(sport=1234, dport=1234) /
1217 Raw('\xa5' * 100))
1218
1219 #
1220 # PG1 does not forward IP traffic
1221 #
1222 self.send_and_assert_no_replies(self.pg1, pu, "IPv6 disabled")
1223 self.send_and_assert_no_replies(self.pg1, pm, "IPv6 disabled")
1224
1225 #
1226 # IP enable PG1
1227 #
1228 self.pg1.config_ip6()
1229
1230 #
1231 # Now we get packets through
1232 #
1233 self.pg1.add_stream(pu)
1234 self.pg_enable_capture(self.pg_interfaces)
1235 self.pg_start()
1236 rx = self.pg0.get_capture(1)
1237
1238 self.pg1.add_stream(pm)
1239 self.pg_enable_capture(self.pg_interfaces)
1240 self.pg_start()
1241 rx = self.pg0.get_capture(1)
1242
1243 #
1244 # Disable PG1
1245 #
1246 self.pg1.unconfig_ip6()
1247
1248 #
1249 # PG1 does not forward IP traffic
1250 #
1251 self.send_and_assert_no_replies(self.pg1, pu, "IPv6 disabled")
1252 self.send_and_assert_no_replies(self.pg1, pm, "IPv6 disabled")
1253
1254
Neale Ranns227038a2017-04-21 01:07:59 -07001255class TestIP6LoadBalance(VppTestCase):
1256 """ IPv6 Load-Balancing """
1257
1258 def setUp(self):
1259 super(TestIP6LoadBalance, self).setUp()
1260
1261 self.create_pg_interfaces(range(5))
1262
Neale Ranns15002542017-09-10 04:39:11 -07001263 mpls_tbl = VppMplsTable(self, 0)
1264 mpls_tbl.add_vpp_config()
1265
Neale Ranns227038a2017-04-21 01:07:59 -07001266 for i in self.pg_interfaces:
1267 i.admin_up()
1268 i.config_ip6()
1269 i.resolve_ndp()
Neale Ranns71275e32017-05-25 12:38:58 -07001270 i.enable_mpls()
Neale Ranns227038a2017-04-21 01:07:59 -07001271
1272 def tearDown(self):
Neale Ranns227038a2017-04-21 01:07:59 -07001273 for i in self.pg_interfaces:
1274 i.unconfig_ip6()
1275 i.admin_down()
Neale Ranns71275e32017-05-25 12:38:58 -07001276 i.disable_mpls()
Neale Ranns15002542017-09-10 04:39:11 -07001277 super(TestIP6LoadBalance, self).tearDown()
Neale Ranns227038a2017-04-21 01:07:59 -07001278
1279 def send_and_expect_load_balancing(self, input, pkts, outputs):
1280 input.add_stream(pkts)
1281 self.pg_enable_capture(self.pg_interfaces)
1282 self.pg_start()
1283 for oo in outputs:
1284 rx = oo._get_capture(1)
1285 self.assertNotEqual(0, len(rx))
1286
Neale Ranns71275e32017-05-25 12:38:58 -07001287 def send_and_expect_one_itf(self, input, pkts, itf):
1288 input.add_stream(pkts)
1289 self.pg_enable_capture(self.pg_interfaces)
1290 self.pg_start()
1291 rx = itf.get_capture(len(pkts))
1292
Neale Ranns227038a2017-04-21 01:07:59 -07001293 def test_ip6_load_balance(self):
1294 """ IPv6 Load-Balancing """
1295
1296 #
1297 # An array of packets that differ only in the destination port
Neale Ranns71275e32017-05-25 12:38:58 -07001298 # - IP only
1299 # - MPLS EOS
1300 # - MPLS non-EOS
1301 # - MPLS non-EOS with an entropy label
Neale Ranns227038a2017-04-21 01:07:59 -07001302 #
Neale Ranns71275e32017-05-25 12:38:58 -07001303 port_ip_pkts = []
1304 port_mpls_pkts = []
1305 port_mpls_neos_pkts = []
1306 port_ent_pkts = []
Neale Ranns227038a2017-04-21 01:07:59 -07001307
1308 #
1309 # An array of packets that differ only in the source address
1310 #
Neale Ranns71275e32017-05-25 12:38:58 -07001311 src_ip_pkts = []
1312 src_mpls_pkts = []
Neale Ranns227038a2017-04-21 01:07:59 -07001313
1314 for ii in range(65):
Neale Ranns71275e32017-05-25 12:38:58 -07001315 port_ip_hdr = (IPv6(dst="3000::1", src="3000:1::1") /
1316 UDP(sport=1234, dport=1234 + ii) /
1317 Raw('\xa5' * 100))
1318 port_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1319 dst=self.pg0.local_mac) /
1320 port_ip_hdr))
1321 port_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1322 dst=self.pg0.local_mac) /
1323 MPLS(label=66, ttl=2) /
1324 port_ip_hdr))
1325 port_mpls_neos_pkts.append((Ether(src=self.pg0.remote_mac,
1326 dst=self.pg0.local_mac) /
1327 MPLS(label=67, ttl=2) /
1328 MPLS(label=77, ttl=2) /
1329 port_ip_hdr))
1330 port_ent_pkts.append((Ether(src=self.pg0.remote_mac,
1331 dst=self.pg0.local_mac) /
1332 MPLS(label=67, ttl=2) /
1333 MPLS(label=14, ttl=2) /
1334 MPLS(label=999, ttl=2) /
1335 port_ip_hdr))
1336 src_ip_hdr = (IPv6(dst="3000::1", src="3000:1::%d" % ii) /
1337 UDP(sport=1234, dport=1234) /
1338 Raw('\xa5' * 100))
1339 src_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1340 dst=self.pg0.local_mac) /
1341 src_ip_hdr))
1342 src_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1343 dst=self.pg0.local_mac) /
1344 MPLS(label=66, ttl=2) /
1345 src_ip_hdr))
Neale Ranns227038a2017-04-21 01:07:59 -07001346
Neale Ranns71275e32017-05-25 12:38:58 -07001347 #
1348 # A route for the IP pacekts
1349 #
Neale Ranns227038a2017-04-21 01:07:59 -07001350 route_3000_1 = VppIpRoute(self, "3000::1", 128,
1351 [VppRoutePath(self.pg1.remote_ip6,
1352 self.pg1.sw_if_index,
Neale Rannsda78f952017-05-24 09:15:43 -07001353 proto=DpoProto.DPO_PROTO_IP6),
Neale Ranns227038a2017-04-21 01:07:59 -07001354 VppRoutePath(self.pg2.remote_ip6,
1355 self.pg2.sw_if_index,
Neale Rannsda78f952017-05-24 09:15:43 -07001356 proto=DpoProto.DPO_PROTO_IP6)],
Neale Ranns227038a2017-04-21 01:07:59 -07001357 is_ip6=1)
1358 route_3000_1.add_vpp_config()
1359
1360 #
Neale Ranns71275e32017-05-25 12:38:58 -07001361 # a local-label for the EOS packets
1362 #
1363 binding = VppMplsIpBind(self, 66, "3000::1", 128, is_ip6=1)
1364 binding.add_vpp_config()
1365
1366 #
1367 # An MPLS route for the non-EOS packets
1368 #
1369 route_67 = VppMplsRoute(self, 67, 0,
1370 [VppRoutePath(self.pg1.remote_ip6,
1371 self.pg1.sw_if_index,
1372 labels=[67],
Neale Rannsda78f952017-05-24 09:15:43 -07001373 proto=DpoProto.DPO_PROTO_IP6),
Neale Ranns71275e32017-05-25 12:38:58 -07001374 VppRoutePath(self.pg2.remote_ip6,
1375 self.pg2.sw_if_index,
1376 labels=[67],
Neale Rannsda78f952017-05-24 09:15:43 -07001377 proto=DpoProto.DPO_PROTO_IP6)])
Neale Ranns71275e32017-05-25 12:38:58 -07001378 route_67.add_vpp_config()
1379
1380 #
Neale Ranns227038a2017-04-21 01:07:59 -07001381 # inject the packet on pg0 - expect load-balancing across the 2 paths
1382 # - since the default hash config is to use IP src,dst and port
1383 # src,dst
1384 # We are not going to ensure equal amounts of packets across each link,
1385 # since the hash algorithm is statistical and therefore this can never
1386 # be guaranteed. But wuth 64 different packets we do expect some
1387 # balancing. So instead just ensure there is traffic on each link.
1388 #
Neale Ranns71275e32017-05-25 12:38:58 -07001389 self.send_and_expect_load_balancing(self.pg0, port_ip_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001390 [self.pg1, self.pg2])
Neale Ranns71275e32017-05-25 12:38:58 -07001391 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001392 [self.pg1, self.pg2])
Neale Ranns71275e32017-05-25 12:38:58 -07001393 self.send_and_expect_load_balancing(self.pg0, port_mpls_pkts,
1394 [self.pg1, self.pg2])
1395 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
1396 [self.pg1, self.pg2])
1397 self.send_and_expect_load_balancing(self.pg0, port_mpls_neos_pkts,
1398 [self.pg1, self.pg2])
1399
1400 #
1401 # The packets with Entropy label in should not load-balance,
1402 # since the Entorpy value is fixed.
1403 #
1404 self.send_and_expect_one_itf(self.pg0, port_ent_pkts, self.pg1)
Neale Ranns227038a2017-04-21 01:07:59 -07001405
1406 #
1407 # change the flow hash config so it's only IP src,dst
1408 # - now only the stream with differing source address will
1409 # load-balance
1410 #
1411 self.vapi.set_ip_flow_hash(0, is_ip6=1, src=1, dst=1, sport=0, dport=0)
1412
Neale Ranns71275e32017-05-25 12:38:58 -07001413 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001414 [self.pg1, self.pg2])
Neale Ranns71275e32017-05-25 12:38:58 -07001415 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
1416 [self.pg1, self.pg2])
1417 self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2)
Neale Ranns227038a2017-04-21 01:07:59 -07001418
1419 #
1420 # change the flow hash config back to defaults
1421 #
1422 self.vapi.set_ip_flow_hash(0, is_ip6=1, src=1, dst=1, sport=1, dport=1)
1423
1424 #
1425 # Recursive prefixes
1426 # - testing that 2 stages of load-balancing occurs and there is no
1427 # polarisation (i.e. only 2 of 4 paths are used)
1428 #
1429 port_pkts = []
1430 src_pkts = []
1431
1432 for ii in range(257):
1433 port_pkts.append((Ether(src=self.pg0.remote_mac,
1434 dst=self.pg0.local_mac) /
1435 IPv6(dst="4000::1", src="4000:1::1") /
1436 UDP(sport=1234, dport=1234 + ii) /
1437 Raw('\xa5' * 100)))
1438 src_pkts.append((Ether(src=self.pg0.remote_mac,
1439 dst=self.pg0.local_mac) /
1440 IPv6(dst="4000::1", src="4000:1::%d" % ii) /
1441 UDP(sport=1234, dport=1234) /
1442 Raw('\xa5' * 100)))
1443
1444 route_3000_2 = VppIpRoute(self, "3000::2", 128,
1445 [VppRoutePath(self.pg3.remote_ip6,
1446 self.pg3.sw_if_index,
Neale Rannsda78f952017-05-24 09:15:43 -07001447 proto=DpoProto.DPO_PROTO_IP6),
Neale Ranns227038a2017-04-21 01:07:59 -07001448 VppRoutePath(self.pg4.remote_ip6,
1449 self.pg4.sw_if_index,
Neale Rannsda78f952017-05-24 09:15:43 -07001450 proto=DpoProto.DPO_PROTO_IP6)],
Neale Ranns227038a2017-04-21 01:07:59 -07001451 is_ip6=1)
1452 route_3000_2.add_vpp_config()
1453
1454 route_4000_1 = VppIpRoute(self, "4000::1", 128,
1455 [VppRoutePath("3000::1",
1456 0xffffffff,
Neale Rannsda78f952017-05-24 09:15:43 -07001457 proto=DpoProto.DPO_PROTO_IP6),
Neale Ranns227038a2017-04-21 01:07:59 -07001458 VppRoutePath("3000::2",
1459 0xffffffff,
Neale Rannsda78f952017-05-24 09:15:43 -07001460 proto=DpoProto.DPO_PROTO_IP6)],
Neale Ranns227038a2017-04-21 01:07:59 -07001461 is_ip6=1)
1462 route_4000_1.add_vpp_config()
1463
1464 #
1465 # inject the packet on pg0 - expect load-balancing across all 4 paths
1466 #
1467 self.vapi.cli("clear trace")
1468 self.send_and_expect_load_balancing(self.pg0, port_pkts,
1469 [self.pg1, self.pg2,
1470 self.pg3, self.pg4])
1471 self.send_and_expect_load_balancing(self.pg0, src_pkts,
1472 [self.pg1, self.pg2,
1473 self.pg3, self.pg4])
1474
Neale Ranns42e6b092017-07-31 02:56:03 -07001475 #
1476 # Recursive prefixes
1477 # - testing that 2 stages of load-balancing no choices
1478 #
1479 port_pkts = []
1480
1481 for ii in range(257):
1482 port_pkts.append((Ether(src=self.pg0.remote_mac,
1483 dst=self.pg0.local_mac) /
1484 IPv6(dst="6000::1", src="6000:1::1") /
1485 UDP(sport=1234, dport=1234 + ii) /
1486 Raw('\xa5' * 100)))
1487
1488 route_5000_2 = VppIpRoute(self, "5000::2", 128,
1489 [VppRoutePath(self.pg3.remote_ip6,
1490 self.pg3.sw_if_index,
Neale Rannsda78f952017-05-24 09:15:43 -07001491 proto=DpoProto.DPO_PROTO_IP6)],
Neale Ranns42e6b092017-07-31 02:56:03 -07001492 is_ip6=1)
1493 route_5000_2.add_vpp_config()
1494
1495 route_6000_1 = VppIpRoute(self, "6000::1", 128,
1496 [VppRoutePath("5000::2",
1497 0xffffffff,
Neale Rannsda78f952017-05-24 09:15:43 -07001498 proto=DpoProto.DPO_PROTO_IP6)],
Neale Ranns42e6b092017-07-31 02:56:03 -07001499 is_ip6=1)
1500 route_6000_1.add_vpp_config()
1501
1502 #
1503 # inject the packet on pg0 - expect load-balancing across all 4 paths
1504 #
1505 self.vapi.cli("clear trace")
1506 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3)
1507
Neale Ranns227038a2017-04-21 01:07:59 -07001508
Damjan Marionf56b77a2016-10-03 19:44:57 +02001509if __name__ == '__main__':
Klement Sekeraf62ae122016-10-11 11:47:09 +02001510 unittest.main(testRunner=VppTestRunner)