blob: 35be24ca34d7072cf3bbbb42548bc3f7d5b910ce [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Paul Vinciguerra6e4c6ad2018-11-25 10:35:29 -08002import binascii
Matej Klotton16a14cd2016-12-07 15:09:13 +01003import random
Klement Sekeraf62ae122016-10-11 11:47:09 +02004import socket
Matej Klotton16a14cd2016-12-07 15:09:13 +01005import unittest
Klement Sekeraf62ae122016-10-11 11:47:09 +02006
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -07007import scapy.compat
Paul Vinciguerraa6fe4632018-11-25 11:21:50 -08008from scapy.contrib.mpls import MPLS
9from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
10from scapy.layers.l2 import Ether, Dot1Q, ARP
11from scapy.packet import Raw
12from six import moves
13
Damjan Marionf56b77a2016-10-03 19:44:57 +020014from framework import VppTestCase, VppTestRunner
Paul Vinciguerraa6fe4632018-11-25 11:21:50 -080015from util import ppp
Neale Ranns180279b2017-03-16 15:49:09 -040016from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
Neale Ranns990f6942020-10-20 07:20:17 +000017 VppMRoutePath, VppMplsIpBind, \
Matthew Smith6c92f5b2019-08-07 11:46:30 -050018 VppMplsTable, VppIpTable, FibPathType, find_route, \
Neale Ranns9db6ada2019-11-08 12:42:31 +000019 VppIpInterfaceAddress, find_route_in_dump, find_mroute_in_dump
Paul Vinciguerraa6fe4632018-11-25 11:21:50 -080020from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
Neale Ranns68577d22019-06-04 13:31:23 +000021from vpp_papi import VppEnum
Neale Ranns0b6a8572019-10-30 17:34:14 +000022from vpp_neighbor import VppNeighbor
Neale Ranns9efcee62019-11-26 19:30:08 +000023from vpp_lo_interface import VppLoInterface
Jakub Grajciarcd01fb42020-03-02 13:16:53 +010024from vpp_policer import VppPolicer
Damjan Marionf56b77a2016-10-03 19:44:57 +020025
Paul Vinciguerra4271c972019-05-14 13:25:49 -040026NUM_PKTS = 67
27
Damjan Marionf56b77a2016-10-03 19:44:57 +020028
Klement Sekeraf62ae122016-10-11 11:47:09 +020029class TestIPv4(VppTestCase):
Damjan Marionf56b77a2016-10-03 19:44:57 +020030 """ IPv4 Test Case """
31
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070032 @classmethod
33 def setUpClass(cls):
34 super(TestIPv4, cls).setUpClass()
35
36 @classmethod
37 def tearDownClass(cls):
38 super(TestIPv4, cls).tearDownClass()
39
Klement Sekeraf62ae122016-10-11 11:47:09 +020040 def setUp(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010041 """
42 Perform test setup before test case.
43
44 **Config:**
45 - create 3 pg interfaces
46 - untagged pg0 interface
47 - Dot1Q subinterface on pg1
48 - Dot1AD subinterface on pg2
49 - setup interfaces:
50 - put it into UP state
51 - set IPv4 addresses
52 - resolve neighbor address using ARP
53 - configure 200 fib entries
54
55 :ivar list interfaces: pg interfaces and subinterfaces.
56 :ivar dict flows: IPv4 packet flows in test.
Matej Klotton86d87c42016-11-11 11:38:55 +010057 """
Klement Sekeraf62ae122016-10-11 11:47:09 +020058 super(TestIPv4, self).setUp()
Damjan Marionf56b77a2016-10-03 19:44:57 +020059
Klement Sekeraf62ae122016-10-11 11:47:09 +020060 # create 3 pg interfaces
61 self.create_pg_interfaces(range(3))
Damjan Marionf56b77a2016-10-03 19:44:57 +020062
Klement Sekeraf62ae122016-10-11 11:47:09 +020063 # create 2 subinterfaces for pg1 and pg2
64 self.sub_interfaces = [
65 VppDot1QSubint(self, self.pg1, 100),
66 VppDot1ADSubint(self, self.pg2, 200, 300, 400)]
Damjan Marionf56b77a2016-10-03 19:44:57 +020067
Klement Sekeraf62ae122016-10-11 11:47:09 +020068 # packet flows mapping pg0 -> pg1.sub, pg2.sub, etc.
69 self.flows = dict()
70 self.flows[self.pg0] = [self.pg1.sub_if, self.pg2.sub_if]
71 self.flows[self.pg1.sub_if] = [self.pg0, self.pg2.sub_if]
72 self.flows[self.pg2.sub_if] = [self.pg0, self.pg1.sub_if]
Damjan Marionf56b77a2016-10-03 19:44:57 +020073
Klement Sekeraf62ae122016-10-11 11:47:09 +020074 # packet sizes
Jan Geletye6c78ee2018-06-26 12:24:03 +020075 self.pg_if_packet_sizes = [64, 1500, 9020]
Damjan Marionf56b77a2016-10-03 19:44:57 +020076
Klement Sekeraf62ae122016-10-11 11:47:09 +020077 self.interfaces = list(self.pg_interfaces)
78 self.interfaces.extend(self.sub_interfaces)
Damjan Marionf56b77a2016-10-03 19:44:57 +020079
Klement Sekeraf62ae122016-10-11 11:47:09 +020080 # setup all interfaces
81 for i in self.interfaces:
82 i.admin_up()
83 i.config_ip4()
84 i.resolve_arp()
85
Matej Klotton86d87c42016-11-11 11:38:55 +010086 # config 2M FIB entries
Damjan Marionf56b77a2016-10-03 19:44:57 +020087
88 def tearDown(self):
Matej Klotton86d87c42016-11-11 11:38:55 +010089 """Run standard test teardown and log ``show ip arp``."""
Klement Sekeraf62ae122016-10-11 11:47:09 +020090 super(TestIPv4, self).tearDown()
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -070091
92 def show_commands_at_teardown(self):
Neale Rannscbe25aa2019-09-30 10:53:31 +000093 self.logger.info(self.vapi.cli("show ip4 neighbors"))
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -070094 # info(self.vapi.cli("show ip fib")) # many entries
Damjan Marionf56b77a2016-10-03 19:44:57 +020095
Jan Geletye6c78ee2018-06-26 12:24:03 +020096 def modify_packet(self, src_if, packet_size, pkt):
97 """Add load, set destination IP and extend packet to required packet
98 size for defined interface.
99
100 :param VppInterface src_if: Interface to create packet for.
101 :param int packet_size: Required packet size.
102 :param Scapy pkt: Packet to be modified.
103 """
Ole Troan6ed154f2019-10-15 19:31:55 +0200104 dst_if_idx = int(packet_size / 10 % 2)
Jan Geletye6c78ee2018-06-26 12:24:03 +0200105 dst_if = self.flows[src_if][dst_if_idx]
106 info = self.create_packet_info(src_if, dst_if)
107 payload = self.info_to_payload(info)
108 p = pkt/Raw(payload)
109 p[IP].dst = dst_if.remote_ip4
110 info.data = p.copy()
111 if isinstance(src_if, VppSubInterface):
112 p = src_if.add_dot1_layer(p)
113 self.extend_packet(p, packet_size)
114
115 return p
116
117 def create_stream(self, src_if):
Matej Klotton86d87c42016-11-11 11:38:55 +0100118 """Create input packet stream for defined interface.
119
120 :param VppInterface src_if: Interface to create packet stream for.
Matej Klotton86d87c42016-11-11 11:38:55 +0100121 """
Jan Geletye6c78ee2018-06-26 12:24:03 +0200122 hdr_ext = 4 if isinstance(src_if, VppSubInterface) else 0
123 pkt_tmpl = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
124 IP(src=src_if.remote_ip4) /
125 UDP(sport=1234, dport=1234))
126
127 pkts = [self.modify_packet(src_if, i, pkt_tmpl)
Paul Vinciguerraa6fe4632018-11-25 11:21:50 -0800128 for i in moves.range(self.pg_if_packet_sizes[0],
129 self.pg_if_packet_sizes[1], 10)]
Jan Geletye6c78ee2018-06-26 12:24:03 +0200130 pkts_b = [self.modify_packet(src_if, i, pkt_tmpl)
Paul Vinciguerraa6fe4632018-11-25 11:21:50 -0800131 for i in moves.range(self.pg_if_packet_sizes[1] + hdr_ext,
132 self.pg_if_packet_sizes[2] + hdr_ext,
133 50)]
Jan Geletye6c78ee2018-06-26 12:24:03 +0200134 pkts.extend(pkts_b)
135
Damjan Marionf56b77a2016-10-03 19:44:57 +0200136 return pkts
137
Klement Sekeraf62ae122016-10-11 11:47:09 +0200138 def verify_capture(self, dst_if, capture):
Matej Klotton86d87c42016-11-11 11:38:55 +0100139 """Verify captured input packet stream for defined interface.
140
141 :param VppInterface dst_if: Interface to verify captured packet stream
Jan Geletye6c78ee2018-06-26 12:24:03 +0200142 for.
Matej Klotton86d87c42016-11-11 11:38:55 +0100143 :param list capture: Captured packet stream.
144 """
145 self.logger.info("Verifying capture on interface %s" % dst_if.name)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200146 last_info = dict()
Damjan Marionf56b77a2016-10-03 19:44:57 +0200147 for i in self.interfaces:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200148 last_info[i.sw_if_index] = None
149 is_sub_if = False
150 dst_sw_if_index = dst_if.sw_if_index
151 if hasattr(dst_if, 'parent'):
152 is_sub_if = True
Damjan Marionf56b77a2016-10-03 19:44:57 +0200153 for packet in capture:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200154 if is_sub_if:
155 # Check VLAN tags and Ethernet header
156 packet = dst_if.remove_dot1_layer(packet)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200157 self.assertTrue(Dot1Q not in packet)
158 try:
159 ip = packet[IP]
160 udp = packet[UDP]
Paul Vinciguerraeaea4212019-03-06 11:58:06 -0800161 payload_info = self.payload_to_info(packet[Raw])
Damjan Marionf56b77a2016-10-03 19:44:57 +0200162 packet_index = payload_info.index
Klement Sekeraf62ae122016-10-11 11:47:09 +0200163 self.assertEqual(payload_info.dst, dst_sw_if_index)
Klement Sekerada505f62017-01-04 12:58:53 +0100164 self.logger.debug(
165 "Got packet on port %s: src=%u (id=%u)" %
166 (dst_if.name, payload_info.src, packet_index))
Klement Sekeraf62ae122016-10-11 11:47:09 +0200167 next_info = self.get_next_packet_info_for_interface2(
168 payload_info.src, dst_sw_if_index,
169 last_info[payload_info.src])
170 last_info[payload_info.src] = next_info
Damjan Marionf56b77a2016-10-03 19:44:57 +0200171 self.assertTrue(next_info is not None)
172 self.assertEqual(packet_index, next_info.index)
173 saved_packet = next_info.data
174 # Check standard fields
175 self.assertEqual(ip.src, saved_packet[IP].src)
176 self.assertEqual(ip.dst, saved_packet[IP].dst)
177 self.assertEqual(udp.sport, saved_packet[UDP].sport)
178 self.assertEqual(udp.dport, saved_packet[UDP].dport)
179 except:
Klement Sekera7bb873a2016-11-18 07:38:42 +0100180 self.logger.error(ppp("Unexpected or invalid packet:", packet))
Damjan Marionf56b77a2016-10-03 19:44:57 +0200181 raise
182 for i in self.interfaces:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200183 remaining_packet = self.get_next_packet_info_for_interface2(
184 i.sw_if_index, dst_sw_if_index, last_info[i.sw_if_index])
Klement Sekera7bb873a2016-11-18 07:38:42 +0100185 self.assertTrue(remaining_packet is None,
186 "Interface %s: Packet expected from interface %s "
187 "didn't arrive" % (dst_if.name, i.name))
Damjan Marionf56b77a2016-10-03 19:44:57 +0200188
189 def test_fib(self):
Matej Klotton86d87c42016-11-11 11:38:55 +0100190 """ IPv4 FIB test
191
192 Test scenario:
193
194 - Create IPv4 stream for pg0 interface
Jan Geletye6c78ee2018-06-26 12:24:03 +0200195 - Create IPv4 tagged streams for pg1's and pg2's sub-interface.
Matej Klotton86d87c42016-11-11 11:38:55 +0100196 - Send and verify received packets on each interface.
197 """
Damjan Marionf56b77a2016-10-03 19:44:57 +0200198
Jan Geletye6c78ee2018-06-26 12:24:03 +0200199 pkts = self.create_stream(self.pg0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200200 self.pg0.add_stream(pkts)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200201
Klement Sekeraf62ae122016-10-11 11:47:09 +0200202 for i in self.sub_interfaces:
Jan Geletye6c78ee2018-06-26 12:24:03 +0200203 pkts = self.create_stream(i)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200204 i.parent.add_stream(pkts)
205
206 self.pg_enable_capture(self.pg_interfaces)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200207 self.pg_start()
208
Klement Sekeraf62ae122016-10-11 11:47:09 +0200209 pkts = self.pg0.get_capture()
210 self.verify_capture(self.pg0, pkts)
211
212 for i in self.sub_interfaces:
213 pkts = i.parent.get_capture()
214 self.verify_capture(i, pkts)
Damjan Marionf56b77a2016-10-03 19:44:57 +0200215
216
Christian Hoppsf5d38e02020-05-04 10:28:03 -0400217class TestIPv4RouteLookup(VppTestCase):
218 """ IPv4 Route Lookup Test Case """
219 routes = []
220
221 def route_lookup(self, prefix, exact):
222 return self.vapi.api(self.vapi.papi.ip_route_lookup,
223 {
224 'table_id': 0,
225 'exact': exact,
226 'prefix': prefix,
227 })
228
229 @classmethod
230 def setUpClass(cls):
231 super(TestIPv4RouteLookup, cls).setUpClass()
232
233 @classmethod
234 def tearDownClass(cls):
235 super(TestIPv4RouteLookup, cls).tearDownClass()
236
237 def setUp(self):
238 super(TestIPv4RouteLookup, self).setUp()
239
240 drop_nh = VppRoutePath("127.0.0.1", 0xffffffff,
241 type=FibPathType.FIB_PATH_TYPE_DROP)
242
243 # Add 3 routes
244 r = VppIpRoute(self, "1.1.0.0", 16, [drop_nh])
245 r.add_vpp_config()
246 self.routes.append(r)
247
248 r = VppIpRoute(self, "1.1.1.0", 24, [drop_nh])
249 r.add_vpp_config()
250 self.routes.append(r)
251
252 r = VppIpRoute(self, "1.1.1.1", 32, [drop_nh])
253 r.add_vpp_config()
254 self.routes.append(r)
255
256 def tearDown(self):
257 # Remove the routes we added
258 for r in self.routes:
259 r.remove_vpp_config()
260
261 super(TestIPv4RouteLookup, self).tearDown()
262
263 def test_exact_match(self):
264 # Verify we find the host route
265 prefix = "1.1.1.1/32"
266 result = self.route_lookup(prefix, True)
267 assert (prefix == str(result.route.prefix))
268
269 # Verify we find a middle prefix route
270 prefix = "1.1.1.0/24"
271 result = self.route_lookup(prefix, True)
272 assert (prefix == str(result.route.prefix))
273
274 # Verify we do not find an available LPM.
275 with self.vapi.assert_negative_api_retval():
276 self.route_lookup("1.1.1.2/32", True)
277
278 def test_longest_prefix_match(self):
279 # verify we find lpm
280 lpm_prefix = "1.1.1.0/24"
281 result = self.route_lookup("1.1.1.2/32", False)
282 assert (lpm_prefix == str(result.route.prefix))
283
284 # Verify we find the exact when not requested
285 result = self.route_lookup(lpm_prefix, False)
286 assert (lpm_prefix == str(result.route.prefix))
287
288 # Can't seem to delete the default route so no negative LPM test.
289
290
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500291class TestIPv4IfAddrRoute(VppTestCase):
Matthew G Smith88d29a92019-07-17 10:01:17 -0500292 """ IPv4 Interface Addr Route Test Case """
293
294 @classmethod
295 def setUpClass(cls):
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500296 super(TestIPv4IfAddrRoute, cls).setUpClass()
Matthew G Smith88d29a92019-07-17 10:01:17 -0500297
298 @classmethod
299 def tearDownClass(cls):
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500300 super(TestIPv4IfAddrRoute, cls).tearDownClass()
Matthew G Smith88d29a92019-07-17 10:01:17 -0500301
302 def setUp(self):
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500303 super(TestIPv4IfAddrRoute, self).setUp()
Matthew G Smith88d29a92019-07-17 10:01:17 -0500304
305 # create 1 pg interface
306 self.create_pg_interfaces(range(1))
307
308 for i in self.pg_interfaces:
309 i.admin_up()
310 i.config_ip4()
311 i.resolve_arp()
312
313 def tearDown(self):
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500314 super(TestIPv4IfAddrRoute, self).tearDown()
Matthew G Smith88d29a92019-07-17 10:01:17 -0500315 for i in self.pg_interfaces:
316 i.unconfig_ip4()
317 i.admin_down()
318
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500319 def test_ipv4_ifaddrs_same_prefix(self):
320 """ IPv4 Interface Addresses Same Prefix test
321
322 Test scenario:
323
324 - Verify no route in FIB for prefix 10.10.10.0/24
325 - Configure IPv4 address 10.10.10.10/24 on an interface
326 - Verify route in FIB for prefix 10.10.10.0/24
327 - Configure IPv4 address 10.10.10.20/24 on an interface
328 - Delete 10.10.10.10/24 from interface
329 - Verify route in FIB for prefix 10.10.10.0/24
330 - Delete 10.10.10.20/24 from interface
331 - Verify no route in FIB for prefix 10.10.10.0/24
332 """
333
334 # create two addresses, verify route not present
Neale Rannsefd7bc22019-11-11 08:32:34 +0000335 if_addr1 = VppIpInterfaceAddress(self, self.pg0, "10.10.10.10", 24)
336 if_addr2 = VppIpInterfaceAddress(self, self.pg0, "10.10.10.20", 24)
337 self.assertFalse(if_addr1.query_vpp_config()) # 10.10.10.10/24
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500338 self.assertFalse(find_route(self, "10.10.10.10", 32))
339 self.assertFalse(find_route(self, "10.10.10.20", 32))
340 self.assertFalse(find_route(self, "10.10.10.255", 32))
341 self.assertFalse(find_route(self, "10.10.10.0", 32))
342
343 # configure first address, verify route present
344 if_addr1.add_vpp_config()
Neale Rannsefd7bc22019-11-11 08:32:34 +0000345 self.assertTrue(if_addr1.query_vpp_config()) # 10.10.10.10/24
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500346 self.assertTrue(find_route(self, "10.10.10.10", 32))
347 self.assertFalse(find_route(self, "10.10.10.20", 32))
348 self.assertTrue(find_route(self, "10.10.10.255", 32))
349 self.assertTrue(find_route(self, "10.10.10.0", 32))
350
351 # configure second address, delete first, verify route not removed
352 if_addr2.add_vpp_config()
353 if_addr1.remove_vpp_config()
Neale Rannsefd7bc22019-11-11 08:32:34 +0000354 self.assertFalse(if_addr1.query_vpp_config()) # 10.10.10.10/24
355 self.assertTrue(if_addr2.query_vpp_config()) # 10.10.10.20/24
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500356 self.assertFalse(find_route(self, "10.10.10.10", 32))
357 self.assertTrue(find_route(self, "10.10.10.20", 32))
358 self.assertTrue(find_route(self, "10.10.10.255", 32))
359 self.assertTrue(find_route(self, "10.10.10.0", 32))
360
361 # delete second address, verify route removed
362 if_addr2.remove_vpp_config()
Neale Rannsefd7bc22019-11-11 08:32:34 +0000363 self.assertFalse(if_addr2.query_vpp_config()) # 10.10.10.20/24
Matthew Smith6c92f5b2019-08-07 11:46:30 -0500364 self.assertFalse(find_route(self, "10.10.10.10", 32))
365 self.assertFalse(find_route(self, "10.10.10.20", 32))
366 self.assertFalse(find_route(self, "10.10.10.255", 32))
367 self.assertFalse(find_route(self, "10.10.10.0", 32))
368
Matthew G Smith88d29a92019-07-17 10:01:17 -0500369 def test_ipv4_ifaddr_route(self):
370 """ IPv4 Interface Address Route test
371
372 Test scenario:
373
374 - Create loopback
375 - Configure IPv4 address on loopback
376 - Verify that address is not in the FIB
377 - Bring loopback up
378 - Verify that address is in the FIB now
379 - Bring loopback down
380 - Verify that address is not in the FIB anymore
381 - Bring loopback up
382 - Configure IPv4 address on loopback
383 - Verify that address is in the FIB now
384 """
385
386 # create a loopback and configure IPv4
387 loopbacks = self.create_loopback_interfaces(1)
388 lo_if = self.lo_interfaces[0]
389
390 lo_if.local_ip4_prefix_len = 32
391 lo_if.config_ip4()
392
393 # The intf was down when addr was added -> entry not in FIB
394 fib4_dump = self.vapi.ip_route_dump(0)
395 self.assertFalse(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
396
397 # When intf is brought up, entry is added
398 lo_if.admin_up()
399 fib4_dump = self.vapi.ip_route_dump(0)
400 self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
401
402 # When intf is brought down, entry is removed
403 lo_if.admin_down()
404 fib4_dump = self.vapi.ip_route_dump(0)
405 self.assertFalse(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
406
407 # Remove addr, bring up interface, re-add -> entry in FIB
408 lo_if.unconfig_ip4()
409 lo_if.admin_up()
410 lo_if.config_ip4()
411 fib4_dump = self.vapi.ip_route_dump(0)
412 self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
413
yedgdbd366b2020-05-14 10:51:53 +0800414 def test_ipv4_ifaddr_del(self):
415 """ Delete an interface address that does not exist """
416
417 loopbacks = self.create_loopback_interfaces(1)
418 lo = self.lo_interfaces[0]
419
420 lo.config_ip4()
421 lo.admin_up()
422
423 #
424 # try and remove pg0's subnet from lo
425 #
426 with self.vapi.assert_negative_api_retval():
427 self.vapi.sw_interface_add_del_address(
428 sw_if_index=lo.sw_if_index,
429 prefix=self.pg0.local_ip4_prefix,
430 is_add=0)
431
Matthew G Smith88d29a92019-07-17 10:01:17 -0500432
Jan Geletye6c78ee2018-06-26 12:24:03 +0200433class TestICMPEcho(VppTestCase):
434 """ ICMP Echo Test Case """
435
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700436 @classmethod
437 def setUpClass(cls):
438 super(TestICMPEcho, cls).setUpClass()
439
440 @classmethod
441 def tearDownClass(cls):
442 super(TestICMPEcho, cls).tearDownClass()
443
Jan Geletye6c78ee2018-06-26 12:24:03 +0200444 def setUp(self):
445 super(TestICMPEcho, self).setUp()
446
447 # create 1 pg interface
448 self.create_pg_interfaces(range(1))
449
450 for i in self.pg_interfaces:
451 i.admin_up()
452 i.config_ip4()
453 i.resolve_arp()
454
455 def tearDown(self):
456 super(TestICMPEcho, self).tearDown()
457 for i in self.pg_interfaces:
458 i.unconfig_ip4()
459 i.admin_down()
460
461 def test_icmp_echo(self):
462 """ VPP replies to ICMP Echo Request
463
464 Test scenario:
465
466 - Receive ICMP Echo Request message on pg0 interface.
467 - Check outgoing ICMP Echo Reply message on pg0 interface.
468 """
469
470 icmp_id = 0xb
471 icmp_seq = 5
Ole Troan6ed154f2019-10-15 19:31:55 +0200472 icmp_load = b'\x0a' * 18
Jan Geletye6c78ee2018-06-26 12:24:03 +0200473 p_echo_request = (Ether(src=self.pg0.remote_mac,
474 dst=self.pg0.local_mac) /
475 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
476 ICMP(id=icmp_id, seq=icmp_seq) /
477 Raw(load=icmp_load))
478
479 self.pg0.add_stream(p_echo_request)
480 self.pg_enable_capture(self.pg_interfaces)
481 self.pg_start()
482
483 rx = self.pg0.get_capture(1)
484 rx = rx[0]
485 ether = rx[Ether]
486 ipv4 = rx[IP]
487 icmp = rx[ICMP]
488
489 self.assertEqual(ether.src, self.pg0.local_mac)
490 self.assertEqual(ether.dst, self.pg0.remote_mac)
491
492 self.assertEqual(ipv4.src, self.pg0.local_ip4)
493 self.assertEqual(ipv4.dst, self.pg0.remote_ip4)
494
495 self.assertEqual(icmptypes[icmp.type], "echo-reply")
496 self.assertEqual(icmp.id, icmp_id)
497 self.assertEqual(icmp.seq, icmp_seq)
498 self.assertEqual(icmp[Raw].load, icmp_load)
499
500
Matej Klotton16a14cd2016-12-07 15:09:13 +0100501class TestIPv4FibCrud(VppTestCase):
502 """ FIB - add/update/delete - ip4 routes
503
504 Test scenario:
505 - add 1k,
506 - del 100,
507 - add new 1k,
508 - del 1.5k
509
Klement Sekerada505f62017-01-04 12:58:53 +0100510 ..note:: Python API is too slow to add many routes, needs replacement.
Matej Klotton16a14cd2016-12-07 15:09:13 +0100511 """
512
Neale Ranns097fa662018-05-01 05:17:55 -0700513 def config_fib_many_to_one(self, start_dest_addr, next_hop_addr,
514 count, start=0):
Matej Klotton16a14cd2016-12-07 15:09:13 +0100515 """
516
517 :param start_dest_addr:
518 :param next_hop_addr:
519 :param count:
520 :return list: added ips with 32 prefix
521 """
Neale Ranns097fa662018-05-01 05:17:55 -0700522 routes = []
523 for i in range(count):
524 r = VppIpRoute(self, start_dest_addr % (i + start), 32,
525 [VppRoutePath(next_hop_addr, 0xffffffff)])
526 r.add_vpp_config()
527 routes.append(r)
528 return routes
Matej Klotton16a14cd2016-12-07 15:09:13 +0100529
Neale Ranns097fa662018-05-01 05:17:55 -0700530 def unconfig_fib_many_to_one(self, start_dest_addr, next_hop_addr,
531 count, start=0):
Matej Klotton16a14cd2016-12-07 15:09:13 +0100532
Neale Ranns097fa662018-05-01 05:17:55 -0700533 routes = []
534 for i in range(count):
535 r = VppIpRoute(self, start_dest_addr % (i + start), 32,
536 [VppRoutePath(next_hop_addr, 0xffffffff)])
537 r.remove_vpp_config()
538 routes.append(r)
539 return routes
Matej Klotton16a14cd2016-12-07 15:09:13 +0100540
Neale Ranns097fa662018-05-01 05:17:55 -0700541 def create_stream(self, src_if, dst_if, routes, count):
Matej Klotton16a14cd2016-12-07 15:09:13 +0100542 pkts = []
543
544 for _ in range(count):
Neale Rannsefd7bc22019-11-11 08:32:34 +0000545 dst_addr = random.choice(routes).prefix.network_address
Klement Sekeradab231a2016-12-21 08:50:14 +0100546 info = self.create_packet_info(src_if, dst_if)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100547 payload = self.info_to_payload(info)
548 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
Neale Rannsefd7bc22019-11-11 08:32:34 +0000549 IP(src=src_if.remote_ip4, dst=str(dst_addr)) /
Matej Klotton16a14cd2016-12-07 15:09:13 +0100550 UDP(sport=1234, dport=1234) /
551 Raw(payload))
552 info.data = p.copy()
Matej Klotton16a14cd2016-12-07 15:09:13 +0100553 self.extend_packet(p, random.choice(self.pg_if_packet_sizes))
554 pkts.append(p)
555
556 return pkts
557
558 def _find_ip_match(self, find_in, pkt):
559 for p in find_in:
Paul Vinciguerraeaea4212019-03-06 11:58:06 -0800560 if self.payload_to_info(p[Raw]) == \
561 self.payload_to_info(pkt[Raw]):
Matej Klotton16a14cd2016-12-07 15:09:13 +0100562 if p[IP].src != pkt[IP].src:
563 break
564 if p[IP].dst != pkt[IP].dst:
565 break
566 if p[UDP].sport != pkt[UDP].sport:
567 break
568 if p[UDP].dport != pkt[UDP].dport:
569 break
570 return p
571 return None
572
Matej Klotton16a14cd2016-12-07 15:09:13 +0100573 def verify_capture(self, dst_interface, received_pkts, expected_pkts):
574 self.assertEqual(len(received_pkts), len(expected_pkts))
575 to_verify = list(expected_pkts)
576 for p in received_pkts:
577 self.assertEqual(p.src, dst_interface.local_mac)
578 self.assertEqual(p.dst, dst_interface.remote_mac)
579 x = self._find_ip_match(to_verify, p)
580 to_verify.remove(x)
581 self.assertListEqual(to_verify, [])
582
Neale Ranns097fa662018-05-01 05:17:55 -0700583 def verify_route_dump(self, routes):
584 for r in routes:
Neale Rannsefd7bc22019-11-11 08:32:34 +0000585 self.assertTrue(find_route(self,
586 r.prefix.network_address,
587 r.prefix.prefixlen))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100588
Neale Ranns097fa662018-05-01 05:17:55 -0700589 def verify_not_in_route_dump(self, routes):
590 for r in routes:
Neale Rannsefd7bc22019-11-11 08:32:34 +0000591 self.assertFalse(find_route(self,
592 r.prefix.network_address,
593 r.prefix.prefixlen))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100594
595 @classmethod
596 def setUpClass(cls):
597 """
598 #. Create and initialize 3 pg interfaces.
599 #. initialize class attributes configured_routes and deleted_routes
600 to store information between tests.
601 """
602 super(TestIPv4FibCrud, cls).setUpClass()
603
604 try:
605 # create 3 pg interfaces
606 cls.create_pg_interfaces(range(3))
607
608 cls.interfaces = list(cls.pg_interfaces)
609
610 # setup all interfaces
611 for i in cls.interfaces:
612 i.admin_up()
613 i.config_ip4()
614 i.resolve_arp()
615
616 cls.configured_routes = []
617 cls.deleted_routes = []
618 cls.pg_if_packet_sizes = [64, 512, 1518, 9018]
619
620 except Exception:
621 super(TestIPv4FibCrud, cls).tearDownClass()
622 raise
623
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700624 @classmethod
625 def tearDownClass(cls):
626 super(TestIPv4FibCrud, cls).tearDownClass()
627
Matej Klotton16a14cd2016-12-07 15:09:13 +0100628 def setUp(self):
629 super(TestIPv4FibCrud, self).setUp()
Klement Sekeradab231a2016-12-21 08:50:14 +0100630 self.reset_packet_infos()
Matej Klotton16a14cd2016-12-07 15:09:13 +0100631
Paul Vinciguerra4eed7472018-12-16 14:52:36 -0800632 self.configured_routes = []
633 self.deleted_routes = []
634
Matej Klotton16a14cd2016-12-07 15:09:13 +0100635 def test_1_add_routes(self):
Neale Ranns097fa662018-05-01 05:17:55 -0700636 """ Add 1k routes """
Matej Klotton16a14cd2016-12-07 15:09:13 +0100637
Neale Ranns097fa662018-05-01 05:17:55 -0700638 # add 100 routes check with traffic script.
Matej Klotton16a14cd2016-12-07 15:09:13 +0100639 self.configured_routes.extend(self.config_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700640 "10.0.0.%d", self.pg0.remote_ip4, 100))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100641
Neale Ranns097fa662018-05-01 05:17:55 -0700642 self.verify_route_dump(self.configured_routes)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100643
644 self.stream_1 = self.create_stream(
645 self.pg1, self.pg0, self.configured_routes, 100)
646 self.stream_2 = self.create_stream(
647 self.pg2, self.pg0, self.configured_routes, 100)
648 self.pg1.add_stream(self.stream_1)
649 self.pg2.add_stream(self.stream_2)
650
651 self.pg_enable_capture(self.pg_interfaces)
652 self.pg_start()
653
Klement Sekeradab231a2016-12-21 08:50:14 +0100654 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100655 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
656
Matej Klotton16a14cd2016-12-07 15:09:13 +0100657 def test_2_del_routes(self):
658 """ Delete 100 routes
659
660 - delete 10 routes check with traffic script.
661 """
Paul Vinciguerra4eed7472018-12-16 14:52:36 -0800662 # config 1M FIB entries
663 self.configured_routes.extend(self.config_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700664 "10.0.0.%d", self.pg0.remote_ip4, 100))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100665 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700666 "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100667 for x in self.deleted_routes:
668 self.configured_routes.remove(x)
669
Neale Ranns097fa662018-05-01 05:17:55 -0700670 self.verify_route_dump(self.configured_routes)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100671
672 self.stream_1 = self.create_stream(
673 self.pg1, self.pg0, self.configured_routes, 100)
674 self.stream_2 = self.create_stream(
675 self.pg2, self.pg0, self.configured_routes, 100)
676 self.stream_3 = self.create_stream(
677 self.pg1, self.pg0, self.deleted_routes, 100)
678 self.stream_4 = self.create_stream(
679 self.pg2, self.pg0, self.deleted_routes, 100)
680 self.pg1.add_stream(self.stream_1 + self.stream_3)
681 self.pg2.add_stream(self.stream_2 + self.stream_4)
682 self.pg_enable_capture(self.pg_interfaces)
683 self.pg_start()
684
Klement Sekeradab231a2016-12-21 08:50:14 +0100685 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100686 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
687
688 def test_3_add_new_routes(self):
689 """ Add 1k routes
690
691 - re-add 5 routes check with traffic script.
692 - add 100 routes check with traffic script.
693 """
Paul Vinciguerra4eed7472018-12-16 14:52:36 -0800694 # config 1M FIB entries
695 self.configured_routes.extend(self.config_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700696 "10.0.0.%d", self.pg0.remote_ip4, 100))
Paul Vinciguerra4eed7472018-12-16 14:52:36 -0800697 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700698 "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
Paul Vinciguerra4eed7472018-12-16 14:52:36 -0800699 for x in self.deleted_routes:
700 self.configured_routes.remove(x)
701
Matej Klotton16a14cd2016-12-07 15:09:13 +0100702 tmp = self.config_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700703 "10.0.0.%d", self.pg0.remote_ip4, 5, start=10)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100704 self.configured_routes.extend(tmp)
705 for x in tmp:
706 self.deleted_routes.remove(x)
707
708 self.configured_routes.extend(self.config_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700709 "10.0.1.%d", self.pg0.remote_ip4, 100))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100710
Neale Ranns097fa662018-05-01 05:17:55 -0700711 self.verify_route_dump(self.configured_routes)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100712
713 self.stream_1 = self.create_stream(
714 self.pg1, self.pg0, self.configured_routes, 300)
715 self.stream_2 = self.create_stream(
716 self.pg2, self.pg0, self.configured_routes, 300)
717 self.stream_3 = self.create_stream(
718 self.pg1, self.pg0, self.deleted_routes, 100)
719 self.stream_4 = self.create_stream(
720 self.pg2, self.pg0, self.deleted_routes, 100)
721
722 self.pg1.add_stream(self.stream_1 + self.stream_3)
723 self.pg2.add_stream(self.stream_2 + self.stream_4)
724 self.pg_enable_capture(self.pg_interfaces)
725 self.pg_start()
726
Klement Sekeradab231a2016-12-21 08:50:14 +0100727 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100728 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
729
Neale Ranns097fa662018-05-01 05:17:55 -0700730 # delete 5 routes check with traffic script.
731 # add 100 routes check with traffic script.
Matej Klotton16a14cd2016-12-07 15:09:13 +0100732 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700733 "10.0.0.%d", self.pg0.remote_ip4, 15))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100734 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700735 "10.0.0.%d", self.pg0.remote_ip4, 85))
Matej Klotton16a14cd2016-12-07 15:09:13 +0100736 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
Neale Ranns097fa662018-05-01 05:17:55 -0700737 "10.0.1.%d", self.pg0.remote_ip4, 100))
738 self.verify_not_in_route_dump(self.deleted_routes)
Matej Klotton16a14cd2016-12-07 15:09:13 +0100739
740
Neale Ranns37be7362017-02-21 17:30:26 -0800741class TestIPNull(VppTestCase):
742 """ IPv4 routes via NULL """
743
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700744 @classmethod
745 def setUpClass(cls):
746 super(TestIPNull, cls).setUpClass()
747
748 @classmethod
749 def tearDownClass(cls):
750 super(TestIPNull, cls).tearDownClass()
751
Neale Ranns37be7362017-02-21 17:30:26 -0800752 def setUp(self):
753 super(TestIPNull, self).setUp()
754
755 # create 2 pg interfaces
Neale Ranns3b93be52018-09-07 01:48:54 -0700756 self.create_pg_interfaces(range(2))
Neale Ranns37be7362017-02-21 17:30:26 -0800757
758 for i in self.pg_interfaces:
759 i.admin_up()
760 i.config_ip4()
761 i.resolve_arp()
762
763 def tearDown(self):
764 super(TestIPNull, self).tearDown()
765 for i in self.pg_interfaces:
766 i.unconfig_ip4()
767 i.admin_down()
768
769 def test_ip_null(self):
770 """ IP NULL route """
771
772 #
773 # A route via IP NULL that will reply with ICMP unreachables
774 #
Neale Ranns097fa662018-05-01 05:17:55 -0700775 ip_unreach = VppIpRoute(
776 self, "10.0.0.1", 32,
777 [VppRoutePath("0.0.0.0",
778 0xffffffff,
779 type=FibPathType.FIB_PATH_TYPE_ICMP_UNREACH)])
Neale Ranns37be7362017-02-21 17:30:26 -0800780 ip_unreach.add_vpp_config()
781
782 p_unreach = (Ether(src=self.pg0.remote_mac,
783 dst=self.pg0.local_mac) /
784 IP(src=self.pg0.remote_ip4, dst="10.0.0.1") /
785 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +0200786 Raw(b'\xa5' * 100))
Neale Ranns37be7362017-02-21 17:30:26 -0800787 self.pg0.add_stream(p_unreach)
788 self.pg_enable_capture(self.pg_interfaces)
789 self.pg_start()
790
791 rx = self.pg0.get_capture(1)
792 rx = rx[0]
793 icmp = rx[ICMP]
794
795 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
796 self.assertEqual(icmpcodes[icmp.type][icmp.code], "host-unreachable")
797 self.assertEqual(icmp.src, self.pg0.remote_ip4)
798 self.assertEqual(icmp.dst, "10.0.0.1")
799
800 #
801 # ICMP replies are rate limited. so sit and spin.
802 #
803 self.sleep(1)
804
805 #
806 # A route via IP NULL that will reply with ICMP prohibited
807 #
Neale Ranns097fa662018-05-01 05:17:55 -0700808 ip_prohibit = VppIpRoute(
809 self, "10.0.0.2", 32,
810 [VppRoutePath("0.0.0.0",
811 0xffffffff,
812 type=FibPathType.FIB_PATH_TYPE_ICMP_PROHIBIT)])
Neale Ranns37be7362017-02-21 17:30:26 -0800813 ip_prohibit.add_vpp_config()
814
815 p_prohibit = (Ether(src=self.pg0.remote_mac,
816 dst=self.pg0.local_mac) /
817 IP(src=self.pg0.remote_ip4, dst="10.0.0.2") /
818 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +0200819 Raw(b'\xa5' * 100))
Neale Ranns37be7362017-02-21 17:30:26 -0800820
821 self.pg0.add_stream(p_prohibit)
822 self.pg_enable_capture(self.pg_interfaces)
823 self.pg_start()
824
825 rx = self.pg0.get_capture(1)
826
827 rx = rx[0]
828 icmp = rx[ICMP]
829
830 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
831 self.assertEqual(icmpcodes[icmp.type][icmp.code], "host-prohibited")
832 self.assertEqual(icmp.src, self.pg0.remote_ip4)
833 self.assertEqual(icmp.dst, "10.0.0.2")
834
Neale Ranns3b93be52018-09-07 01:48:54 -0700835 def test_ip_drop(self):
836 """ IP Drop Routes """
837
838 p = (Ether(src=self.pg0.remote_mac,
839 dst=self.pg0.local_mac) /
840 IP(src=self.pg0.remote_ip4, dst="1.1.1.1") /
841 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +0200842 Raw(b'\xa5' * 100))
Neale Ranns3b93be52018-09-07 01:48:54 -0700843
844 r1 = VppIpRoute(self, "1.1.1.0", 24,
845 [VppRoutePath(self.pg1.remote_ip4,
846 self.pg1.sw_if_index)])
847 r1.add_vpp_config()
848
Paul Vinciguerra4271c972019-05-14 13:25:49 -0400849 rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
Neale Ranns3b93be52018-09-07 01:48:54 -0700850
851 #
852 # insert a more specific as a drop
853 #
Neale Ranns097fa662018-05-01 05:17:55 -0700854 r2 = VppIpRoute(self, "1.1.1.1", 32,
855 [VppRoutePath("0.0.0.0",
856 0xffffffff,
857 type=FibPathType.FIB_PATH_TYPE_DROP)])
Neale Ranns3b93be52018-09-07 01:48:54 -0700858 r2.add_vpp_config()
859
Paul Vinciguerra4271c972019-05-14 13:25:49 -0400860 self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS, "Drop Route")
Neale Ranns3b93be52018-09-07 01:48:54 -0700861 r2.remove_vpp_config()
Paul Vinciguerra4271c972019-05-14 13:25:49 -0400862 rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
Neale Ranns3b93be52018-09-07 01:48:54 -0700863
Neale Ranns37be7362017-02-21 17:30:26 -0800864
Neale Ranns180279b2017-03-16 15:49:09 -0400865class TestIPDisabled(VppTestCase):
866 """ IPv4 disabled """
867
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700868 @classmethod
869 def setUpClass(cls):
870 super(TestIPDisabled, cls).setUpClass()
871
872 @classmethod
873 def tearDownClass(cls):
874 super(TestIPDisabled, cls).tearDownClass()
875
Neale Ranns180279b2017-03-16 15:49:09 -0400876 def setUp(self):
877 super(TestIPDisabled, self).setUp()
878
879 # create 2 pg interfaces
880 self.create_pg_interfaces(range(2))
881
882 # PG0 is IP enalbed
883 self.pg0.admin_up()
884 self.pg0.config_ip4()
885 self.pg0.resolve_arp()
886
887 # PG 1 is not IP enabled
888 self.pg1.admin_up()
889
890 def tearDown(self):
891 super(TestIPDisabled, self).tearDown()
892 for i in self.pg_interfaces:
893 i.unconfig_ip4()
894 i.admin_down()
895
Neale Ranns180279b2017-03-16 15:49:09 -0400896 def test_ip_disabled(self):
897 """ IP Disabled """
898
Neale Ranns990f6942020-10-20 07:20:17 +0000899 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
900 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
901
Neale Ranns180279b2017-03-16 15:49:09 -0400902 #
903 # An (S,G).
904 # one accepting interface, pg0, 2 forwarding interfaces
905 #
906 route_232_1_1_1 = VppIpMRoute(
907 self,
908 "0.0.0.0",
909 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000910 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Ranns180279b2017-03-16 15:49:09 -0400911 [VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000912 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Ranns180279b2017-03-16 15:49:09 -0400913 VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000914 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Ranns180279b2017-03-16 15:49:09 -0400915 route_232_1_1_1.add_vpp_config()
916
917 pu = (Ether(src=self.pg1.remote_mac,
918 dst=self.pg1.local_mac) /
919 IP(src="10.10.10.10", dst=self.pg0.remote_ip4) /
920 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +0200921 Raw(b'\xa5' * 100))
Neale Ranns180279b2017-03-16 15:49:09 -0400922 pm = (Ether(src=self.pg1.remote_mac,
923 dst=self.pg1.local_mac) /
924 IP(src="10.10.10.10", dst="232.1.1.1") /
925 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +0200926 Raw(b'\xa5' * 100))
Neale Ranns180279b2017-03-16 15:49:09 -0400927
928 #
929 # PG1 does not forward IP traffic
930 #
931 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
932 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
933
934 #
935 # IP enable PG1
936 #
937 self.pg1.config_ip4()
938
939 #
940 # Now we get packets through
941 #
942 self.pg1.add_stream(pu)
943 self.pg_enable_capture(self.pg_interfaces)
944 self.pg_start()
945 rx = self.pg0.get_capture(1)
946
947 self.pg1.add_stream(pm)
948 self.pg_enable_capture(self.pg_interfaces)
949 self.pg_start()
950 rx = self.pg0.get_capture(1)
951
952 #
953 # Disable PG1
954 #
955 self.pg1.unconfig_ip4()
956
957 #
958 # PG1 does not forward IP traffic
959 #
960 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
961 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
962
963
Neale Ranns9a69a602017-03-26 10:56:33 -0700964class TestIPSubNets(VppTestCase):
965 """ IPv4 Subnets """
966
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700967 @classmethod
968 def setUpClass(cls):
969 super(TestIPSubNets, cls).setUpClass()
970
971 @classmethod
972 def tearDownClass(cls):
973 super(TestIPSubNets, cls).tearDownClass()
974
Neale Ranns9a69a602017-03-26 10:56:33 -0700975 def setUp(self):
976 super(TestIPSubNets, self).setUp()
977
978 # create a 2 pg interfaces
979 self.create_pg_interfaces(range(2))
980
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700981 # pg0 we will use to experiment
Neale Ranns9a69a602017-03-26 10:56:33 -0700982 self.pg0.admin_up()
983
984 # pg1 is setup normally
985 self.pg1.admin_up()
986 self.pg1.config_ip4()
987 self.pg1.resolve_arp()
988
989 def tearDown(self):
990 super(TestIPSubNets, self).tearDown()
991 for i in self.pg_interfaces:
992 i.admin_down()
993
Neale Ranns9a69a602017-03-26 10:56:33 -0700994 def test_ip_sub_nets(self):
995 """ IP Sub Nets """
996
997 #
998 # Configure a covering route to forward so we know
999 # when we are dropping
1000 #
1001 cover_route = VppIpRoute(self, "10.0.0.0", 8,
1002 [VppRoutePath(self.pg1.remote_ip4,
1003 self.pg1.sw_if_index)])
1004 cover_route.add_vpp_config()
1005
1006 p = (Ether(src=self.pg1.remote_mac,
1007 dst=self.pg1.local_mac) /
1008 IP(dst="10.10.10.10", src=self.pg0.local_ip4) /
1009 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001010 Raw(b'\xa5' * 100))
Neale Ranns9a69a602017-03-26 10:56:33 -07001011
1012 self.pg1.add_stream(p)
1013 self.pg_enable_capture(self.pg_interfaces)
1014 self.pg_start()
1015 rx = self.pg1.get_capture(1)
1016
1017 #
1018 # Configure some non-/24 subnets on an IP interface
1019 #
1020 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
1021
Ole Troan9a475372019-03-05 16:58:24 +01001022 self.vapi.sw_interface_add_del_address(
Jakub Grajciar053204a2019-03-18 13:17:53 +01001023 sw_if_index=self.pg0.sw_if_index,
Neale Rannsefd7bc22019-11-11 08:32:34 +00001024 prefix="10.10.10.10/16")
Neale Ranns9a69a602017-03-26 10:56:33 -07001025
1026 pn = (Ether(src=self.pg1.remote_mac,
1027 dst=self.pg1.local_mac) /
1028 IP(dst="10.10.0.0", src=self.pg0.local_ip4) /
1029 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001030 Raw(b'\xa5' * 100))
Neale Ranns9a69a602017-03-26 10:56:33 -07001031 pb = (Ether(src=self.pg1.remote_mac,
1032 dst=self.pg1.local_mac) /
1033 IP(dst="10.10.255.255", src=self.pg0.local_ip4) /
1034 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001035 Raw(b'\xa5' * 100))
Neale Ranns9a69a602017-03-26 10:56:33 -07001036
1037 self.send_and_assert_no_replies(self.pg1, pn, "IP Network address")
1038 self.send_and_assert_no_replies(self.pg1, pb, "IP Broadcast address")
1039
1040 # remove the sub-net and we are forwarding via the cover again
Ole Troan9a475372019-03-05 16:58:24 +01001041 self.vapi.sw_interface_add_del_address(
Jakub Grajciar053204a2019-03-18 13:17:53 +01001042 sw_if_index=self.pg0.sw_if_index,
Neale Rannsefd7bc22019-11-11 08:32:34 +00001043 prefix="10.10.10.10/16",
1044 is_add=0)
Jakub Grajciar053204a2019-03-18 13:17:53 +01001045
Neale Ranns9a69a602017-03-26 10:56:33 -07001046 self.pg1.add_stream(pn)
1047 self.pg_enable_capture(self.pg_interfaces)
1048 self.pg_start()
1049 rx = self.pg1.get_capture(1)
1050 self.pg1.add_stream(pb)
1051 self.pg_enable_capture(self.pg_interfaces)
1052 self.pg_start()
1053 rx = self.pg1.get_capture(1)
1054
1055 #
1056 # A /31 is a special case where the 'other-side' is an attached host
1057 # packets to that peer generate ARP requests
1058 #
1059 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
1060
Ole Troan9a475372019-03-05 16:58:24 +01001061 self.vapi.sw_interface_add_del_address(
Jakub Grajciar053204a2019-03-18 13:17:53 +01001062 sw_if_index=self.pg0.sw_if_index,
Neale Rannsefd7bc22019-11-11 08:32:34 +00001063 prefix="10.10.10.10/31")
Neale Ranns9a69a602017-03-26 10:56:33 -07001064
1065 pn = (Ether(src=self.pg1.remote_mac,
1066 dst=self.pg1.local_mac) /
1067 IP(dst="10.10.10.11", src=self.pg0.local_ip4) /
1068 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001069 Raw(b'\xa5' * 100))
Neale Ranns9a69a602017-03-26 10:56:33 -07001070
1071 self.pg1.add_stream(pn)
1072 self.pg_enable_capture(self.pg_interfaces)
1073 self.pg_start()
1074 rx = self.pg0.get_capture(1)
1075 rx[ARP]
1076
1077 # remove the sub-net and we are forwarding via the cover again
Ole Troan9a475372019-03-05 16:58:24 +01001078 self.vapi.sw_interface_add_del_address(
Jakub Grajciar053204a2019-03-18 13:17:53 +01001079 sw_if_index=self.pg0.sw_if_index,
Neale Rannsefd7bc22019-11-11 08:32:34 +00001080 prefix="10.10.10.10/31", is_add=0)
Jakub Grajciar053204a2019-03-18 13:17:53 +01001081
Neale Ranns9a69a602017-03-26 10:56:33 -07001082 self.pg1.add_stream(pn)
1083 self.pg_enable_capture(self.pg_interfaces)
1084 self.pg_start()
1085 rx = self.pg1.get_capture(1)
1086
1087
Neale Ranns227038a2017-04-21 01:07:59 -07001088class TestIPLoadBalance(VppTestCase):
1089 """ IPv4 Load-Balancing """
1090
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001091 @classmethod
1092 def setUpClass(cls):
1093 super(TestIPLoadBalance, cls).setUpClass()
1094
1095 @classmethod
1096 def tearDownClass(cls):
1097 super(TestIPLoadBalance, cls).tearDownClass()
1098
Neale Ranns227038a2017-04-21 01:07:59 -07001099 def setUp(self):
1100 super(TestIPLoadBalance, self).setUp()
1101
1102 self.create_pg_interfaces(range(5))
Neale Ranns15002542017-09-10 04:39:11 -07001103 mpls_tbl = VppMplsTable(self, 0)
1104 mpls_tbl.add_vpp_config()
Neale Ranns227038a2017-04-21 01:07:59 -07001105
1106 for i in self.pg_interfaces:
1107 i.admin_up()
1108 i.config_ip4()
1109 i.resolve_arp()
Neale Ranns71275e32017-05-25 12:38:58 -07001110 i.enable_mpls()
Neale Ranns227038a2017-04-21 01:07:59 -07001111
1112 def tearDown(self):
Neale Ranns227038a2017-04-21 01:07:59 -07001113 for i in self.pg_interfaces:
Neale Ranns71275e32017-05-25 12:38:58 -07001114 i.disable_mpls()
Neale Ranns227038a2017-04-21 01:07:59 -07001115 i.unconfig_ip4()
1116 i.admin_down()
Neale Ranns15002542017-09-10 04:39:11 -07001117 super(TestIPLoadBalance, self).tearDown()
Neale Ranns227038a2017-04-21 01:07:59 -07001118
1119 def send_and_expect_load_balancing(self, input, pkts, outputs):
1120 input.add_stream(pkts)
1121 self.pg_enable_capture(self.pg_interfaces)
1122 self.pg_start()
Neale Ranns63480742019-03-13 06:41:52 -07001123 rxs = []
Neale Ranns227038a2017-04-21 01:07:59 -07001124 for oo in outputs:
1125 rx = oo._get_capture(1)
1126 self.assertNotEqual(0, len(rx))
Neale Ranns63480742019-03-13 06:41:52 -07001127 for r in rx:
1128 rxs.append(r)
1129 return rxs
Neale Ranns227038a2017-04-21 01:07:59 -07001130
Neale Ranns42e6b092017-07-31 02:56:03 -07001131 def send_and_expect_one_itf(self, input, pkts, itf):
1132 input.add_stream(pkts)
1133 self.pg_enable_capture(self.pg_interfaces)
1134 self.pg_start()
1135 rx = itf.get_capture(len(pkts))
1136
Neale Ranns227038a2017-04-21 01:07:59 -07001137 def test_ip_load_balance(self):
1138 """ IP Load-Balancing """
1139
1140 #
1141 # An array of packets that differ only in the destination port
1142 #
Neale Ranns71275e32017-05-25 12:38:58 -07001143 port_ip_pkts = []
1144 port_mpls_pkts = []
Neale Ranns227038a2017-04-21 01:07:59 -07001145
1146 #
1147 # An array of packets that differ only in the source address
1148 #
Neale Ranns71275e32017-05-25 12:38:58 -07001149 src_ip_pkts = []
1150 src_mpls_pkts = []
Neale Ranns227038a2017-04-21 01:07:59 -07001151
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001152 for ii in range(NUM_PKTS):
Neale Ranns71275e32017-05-25 12:38:58 -07001153 port_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.1") /
1154 UDP(sport=1234, dport=1234 + ii) /
Ole Troan5e56f752019-10-21 21:06:52 +02001155 Raw(b'\xa5' * 100))
Neale Ranns71275e32017-05-25 12:38:58 -07001156 port_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1157 dst=self.pg0.local_mac) /
1158 port_ip_hdr))
1159 port_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1160 dst=self.pg0.local_mac) /
1161 MPLS(label=66, ttl=2) /
1162 port_ip_hdr))
1163
1164 src_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.%d" % ii) /
1165 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001166 Raw(b'\xa5' * 100))
Neale Ranns71275e32017-05-25 12:38:58 -07001167 src_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1168 dst=self.pg0.local_mac) /
1169 src_ip_hdr))
1170 src_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1171 dst=self.pg0.local_mac) /
1172 MPLS(label=66, ttl=2) /
1173 src_ip_hdr))
Neale Ranns227038a2017-04-21 01:07:59 -07001174
1175 route_10_0_0_1 = VppIpRoute(self, "10.0.0.1", 32,
1176 [VppRoutePath(self.pg1.remote_ip4,
1177 self.pg1.sw_if_index),
1178 VppRoutePath(self.pg2.remote_ip4,
1179 self.pg2.sw_if_index)])
1180 route_10_0_0_1.add_vpp_config()
1181
Neale Ranns71275e32017-05-25 12:38:58 -07001182 binding = VppMplsIpBind(self, 66, "10.0.0.1", 32)
1183 binding.add_vpp_config()
1184
Neale Ranns227038a2017-04-21 01:07:59 -07001185 #
1186 # inject the packet on pg0 - expect load-balancing across the 2 paths
1187 # - since the default hash config is to use IP src,dst and port
1188 # src,dst
1189 # We are not going to ensure equal amounts of packets across each link,
1190 # since the hash algorithm is statistical and therefore this can never
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -07001191 # be guaranteed. But with 64 different packets we do expect some
Neale Ranns227038a2017-04-21 01:07:59 -07001192 # balancing. So instead just ensure there is traffic on each link.
1193 #
Neale Ranns71275e32017-05-25 12:38:58 -07001194 self.send_and_expect_load_balancing(self.pg0, port_ip_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001195 [self.pg1, self.pg2])
Neale Ranns71275e32017-05-25 12:38:58 -07001196 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
1197 [self.pg1, self.pg2])
1198 self.send_and_expect_load_balancing(self.pg0, port_mpls_pkts,
1199 [self.pg1, self.pg2])
1200 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001201 [self.pg1, self.pg2])
1202
1203 #
1204 # change the flow hash config so it's only IP src,dst
1205 # - now only the stream with differing source address will
1206 # load-balance
1207 #
Ole Troana5b2eec2019-03-11 19:23:25 +01001208 self.vapi.set_ip_flow_hash(vrf_id=0, src=1, dst=1, sport=0, dport=0)
Neale Ranns227038a2017-04-21 01:07:59 -07001209
Neale Ranns71275e32017-05-25 12:38:58 -07001210 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
1211 [self.pg1, self.pg2])
1212 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
Neale Ranns227038a2017-04-21 01:07:59 -07001213 [self.pg1, self.pg2])
1214
Neale Ranns42e6b092017-07-31 02:56:03 -07001215 self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2)
Neale Ranns227038a2017-04-21 01:07:59 -07001216
1217 #
1218 # change the flow hash config back to defaults
1219 #
Ole Troana5b2eec2019-03-11 19:23:25 +01001220 self.vapi.set_ip_flow_hash(vrf_id=0, src=1, dst=1, sport=1, dport=1)
Neale Ranns227038a2017-04-21 01:07:59 -07001221
1222 #
1223 # Recursive prefixes
1224 # - testing that 2 stages of load-balancing occurs and there is no
1225 # polarisation (i.e. only 2 of 4 paths are used)
1226 #
1227 port_pkts = []
1228 src_pkts = []
1229
1230 for ii in range(257):
1231 port_pkts.append((Ether(src=self.pg0.remote_mac,
1232 dst=self.pg0.local_mac) /
1233 IP(dst="1.1.1.1", src="20.0.0.1") /
1234 UDP(sport=1234, dport=1234 + ii) /
Ole Troan5e56f752019-10-21 21:06:52 +02001235 Raw(b'\xa5' * 100)))
Neale Ranns227038a2017-04-21 01:07:59 -07001236 src_pkts.append((Ether(src=self.pg0.remote_mac,
1237 dst=self.pg0.local_mac) /
1238 IP(dst="1.1.1.1", src="20.0.0.%d" % ii) /
1239 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001240 Raw(b'\xa5' * 100)))
Neale Ranns227038a2017-04-21 01:07:59 -07001241
1242 route_10_0_0_2 = VppIpRoute(self, "10.0.0.2", 32,
1243 [VppRoutePath(self.pg3.remote_ip4,
1244 self.pg3.sw_if_index),
1245 VppRoutePath(self.pg4.remote_ip4,
1246 self.pg4.sw_if_index)])
1247 route_10_0_0_2.add_vpp_config()
1248
1249 route_1_1_1_1 = VppIpRoute(self, "1.1.1.1", 32,
1250 [VppRoutePath("10.0.0.2", 0xffffffff),
1251 VppRoutePath("10.0.0.1", 0xffffffff)])
1252 route_1_1_1_1.add_vpp_config()
1253
1254 #
1255 # inject the packet on pg0 - expect load-balancing across all 4 paths
1256 #
1257 self.vapi.cli("clear trace")
1258 self.send_and_expect_load_balancing(self.pg0, port_pkts,
1259 [self.pg1, self.pg2,
1260 self.pg3, self.pg4])
1261 self.send_and_expect_load_balancing(self.pg0, src_pkts,
1262 [self.pg1, self.pg2,
1263 self.pg3, self.pg4])
1264
Neale Ranns42e6b092017-07-31 02:56:03 -07001265 #
Neale Ranns63480742019-03-13 06:41:52 -07001266 # bring down pg1 expect LB to adjust to use only those that are pu
1267 #
1268 self.pg1.link_down()
1269
1270 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1271 [self.pg2, self.pg3,
1272 self.pg4])
1273 self.assertEqual(len(src_pkts), len(rx))
1274
1275 #
1276 # bring down pg2 expect LB to adjust to use only those that are pu
1277 #
1278 self.pg2.link_down()
1279
1280 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1281 [self.pg3, self.pg4])
1282 self.assertEqual(len(src_pkts), len(rx))
1283
1284 #
1285 # bring the links back up - expect LB over all again
1286 #
1287 self.pg1.link_up()
1288 self.pg2.link_up()
1289
1290 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1291 [self.pg1, self.pg2,
1292 self.pg3, self.pg4])
1293 self.assertEqual(len(src_pkts), len(rx))
1294
1295 #
1296 # The same link-up/down but this time admin state
1297 #
1298 self.pg1.admin_down()
1299 self.pg2.admin_down()
1300 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1301 [self.pg3, self.pg4])
1302 self.assertEqual(len(src_pkts), len(rx))
1303 self.pg1.admin_up()
1304 self.pg2.admin_up()
1305 self.pg1.resolve_arp()
1306 self.pg2.resolve_arp()
1307 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1308 [self.pg1, self.pg2,
1309 self.pg3, self.pg4])
1310 self.assertEqual(len(src_pkts), len(rx))
1311
1312 #
Neale Ranns42e6b092017-07-31 02:56:03 -07001313 # Recursive prefixes
1314 # - testing that 2 stages of load-balancing, no choices
1315 #
1316 port_pkts = []
1317
1318 for ii in range(257):
1319 port_pkts.append((Ether(src=self.pg0.remote_mac,
1320 dst=self.pg0.local_mac) /
1321 IP(dst="1.1.1.2", src="20.0.0.2") /
1322 UDP(sport=1234, dport=1234 + ii) /
Ole Troan5e56f752019-10-21 21:06:52 +02001323 Raw(b'\xa5' * 100)))
Neale Ranns42e6b092017-07-31 02:56:03 -07001324
1325 route_10_0_0_3 = VppIpRoute(self, "10.0.0.3", 32,
1326 [VppRoutePath(self.pg3.remote_ip4,
1327 self.pg3.sw_if_index)])
1328 route_10_0_0_3.add_vpp_config()
1329
1330 route_1_1_1_2 = VppIpRoute(self, "1.1.1.2", 32,
1331 [VppRoutePath("10.0.0.3", 0xffffffff)])
1332 route_1_1_1_2.add_vpp_config()
1333
1334 #
Neale Ranns63480742019-03-13 06:41:52 -07001335 # inject the packet on pg0 - rx only on via routes output interface
Neale Ranns42e6b092017-07-31 02:56:03 -07001336 #
1337 self.vapi.cli("clear trace")
1338 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3)
1339
Neale Ranns63480742019-03-13 06:41:52 -07001340 #
1341 # Add a LB route in the presence of a down link - expect no
1342 # packets over the down link
1343 #
1344 self.pg3.link_down()
1345
1346 route_10_0_0_3 = VppIpRoute(self, "10.0.0.3", 32,
1347 [VppRoutePath(self.pg3.remote_ip4,
1348 self.pg3.sw_if_index),
1349 VppRoutePath(self.pg4.remote_ip4,
1350 self.pg4.sw_if_index)])
1351 route_10_0_0_3.add_vpp_config()
1352
1353 port_pkts = []
1354 for ii in range(257):
1355 port_pkts.append(Ether(src=self.pg0.remote_mac,
1356 dst=self.pg0.local_mac) /
1357 IP(dst="10.0.0.3", src="20.0.0.2") /
1358 UDP(sport=1234, dport=1234 + ii) /
Ole Troan5e56f752019-10-21 21:06:52 +02001359 Raw(b'\xa5' * 100))
Neale Ranns63480742019-03-13 06:41:52 -07001360
1361 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg4)
1362
1363 # bring the link back up
1364 self.pg3.link_up()
1365
1366 rx = self.send_and_expect_load_balancing(self.pg0, port_pkts,
1367 [self.pg3, self.pg4])
1368 self.assertEqual(len(src_pkts), len(rx))
1369
Neale Ranns30d0fd42017-05-30 07:30:04 -07001370
1371class TestIPVlan0(VppTestCase):
1372 """ IPv4 VLAN-0 """
1373
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001374 @classmethod
1375 def setUpClass(cls):
1376 super(TestIPVlan0, cls).setUpClass()
1377
1378 @classmethod
1379 def tearDownClass(cls):
1380 super(TestIPVlan0, cls).tearDownClass()
1381
Neale Ranns30d0fd42017-05-30 07:30:04 -07001382 def setUp(self):
1383 super(TestIPVlan0, self).setUp()
1384
1385 self.create_pg_interfaces(range(2))
Neale Ranns15002542017-09-10 04:39:11 -07001386 mpls_tbl = VppMplsTable(self, 0)
1387 mpls_tbl.add_vpp_config()
Neale Ranns30d0fd42017-05-30 07:30:04 -07001388
1389 for i in self.pg_interfaces:
1390 i.admin_up()
1391 i.config_ip4()
1392 i.resolve_arp()
1393 i.enable_mpls()
1394
1395 def tearDown(self):
Neale Ranns30d0fd42017-05-30 07:30:04 -07001396 for i in self.pg_interfaces:
1397 i.disable_mpls()
1398 i.unconfig_ip4()
1399 i.admin_down()
Neale Ranns15002542017-09-10 04:39:11 -07001400 super(TestIPVlan0, self).tearDown()
Neale Ranns30d0fd42017-05-30 07:30:04 -07001401
Neale Ranns30d0fd42017-05-30 07:30:04 -07001402 def test_ip_vlan_0(self):
1403 """ IP VLAN-0 """
1404
1405 pkts = (Ether(src=self.pg0.remote_mac,
1406 dst=self.pg0.local_mac) /
1407 Dot1Q(vlan=0) /
1408 IP(dst=self.pg1.remote_ip4,
1409 src=self.pg0.remote_ip4) /
1410 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001411 Raw(b'\xa5' * 100)) * NUM_PKTS
Neale Ranns30d0fd42017-05-30 07:30:04 -07001412
1413 #
1414 # Expect that packets sent on VLAN-0 are forwarded on the
1415 # main interface.
1416 #
1417 self.send_and_expect(self.pg0, pkts, self.pg1)
1418
1419
Neale Rannsd91c1db2017-07-31 02:30:50 -07001420class TestIPPunt(VppTestCase):
1421 """ IPv4 Punt Police/Redirect """
1422
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001423 @classmethod
1424 def setUpClass(cls):
1425 super(TestIPPunt, cls).setUpClass()
1426
1427 @classmethod
1428 def tearDownClass(cls):
1429 super(TestIPPunt, cls).tearDownClass()
1430
Neale Rannsd91c1db2017-07-31 02:30:50 -07001431 def setUp(self):
1432 super(TestIPPunt, self).setUp()
1433
Pavel Kotucek609e1212018-11-27 09:59:44 +01001434 self.create_pg_interfaces(range(4))
Neale Rannsd91c1db2017-07-31 02:30:50 -07001435
1436 for i in self.pg_interfaces:
1437 i.admin_up()
1438 i.config_ip4()
1439 i.resolve_arp()
1440
1441 def tearDown(self):
1442 super(TestIPPunt, self).tearDown()
1443 for i in self.pg_interfaces:
1444 i.unconfig_ip4()
1445 i.admin_down()
1446
Neale Rannsd91c1db2017-07-31 02:30:50 -07001447 def test_ip_punt(self):
1448 """ IP punt police and redirect """
1449
Neale Ranns68577d22019-06-04 13:31:23 +00001450 # use UDP packet that have a port we need to explicitly
1451 # register to get punted.
1452 pt_l4 = VppEnum.vl_api_punt_type_t.PUNT_API_TYPE_L4
1453 af_ip4 = VppEnum.vl_api_address_family_t.ADDRESS_IP4
1454 udp_proto = VppEnum.vl_api_ip_proto_t.IP_API_PROTO_UDP
1455 punt_udp = {
1456 'type': pt_l4,
1457 'punt': {
1458 'l4': {
1459 'af': af_ip4,
1460 'protocol': udp_proto,
1461 'port': 1234,
1462 }
1463 }
1464 }
1465
1466 self.vapi.set_punt(is_add=1, punt=punt_udp)
1467
Neale Rannsd91c1db2017-07-31 02:30:50 -07001468 p = (Ether(src=self.pg0.remote_mac,
1469 dst=self.pg0.local_mac) /
1470 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
Neale Ranns68577d22019-06-04 13:31:23 +00001471 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001472 Raw(b'\xa5' * 100))
Neale Rannsd91c1db2017-07-31 02:30:50 -07001473
1474 pkts = p * 1025
1475
1476 #
1477 # Configure a punt redirect via pg1.
1478 #
Ole Troan0bcad322018-12-11 13:04:01 +01001479 nh_addr = self.pg1.remote_ip4
Neale Rannsd91c1db2017-07-31 02:30:50 -07001480 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1481 self.pg1.sw_if_index,
1482 nh_addr)
1483
1484 self.send_and_expect(self.pg0, pkts, self.pg1)
1485
1486 #
1487 # add a policer
1488 #
Jakub Grajciarcd01fb42020-03-02 13:16:53 +01001489 policer = VppPolicer(self, "ip4-punt", 400, 0, 10, 0, rate_type=1)
1490 policer.add_vpp_config()
Neale Rannsd91c1db2017-07-31 02:30:50 -07001491 self.vapi.ip_punt_police(policer.policer_index)
1492
1493 self.vapi.cli("clear trace")
1494 self.pg0.add_stream(pkts)
1495 self.pg_enable_capture(self.pg_interfaces)
1496 self.pg_start()
1497
1498 #
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -07001499 # the number of packet received should be greater than 0,
Neale Rannsd91c1db2017-07-31 02:30:50 -07001500 # but not equal to the number sent, since some were policed
1501 #
1502 rx = self.pg1._get_capture(1)
Paul Vinciguerra3d2df212018-11-24 23:19:53 -08001503 self.assertGreater(len(rx), 0)
1504 self.assertLess(len(rx), len(pkts))
Neale Rannsd91c1db2017-07-31 02:30:50 -07001505
1506 #
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -07001507 # remove the policer. back to full rx
Neale Rannsd91c1db2017-07-31 02:30:50 -07001508 #
1509 self.vapi.ip_punt_police(policer.policer_index, is_add=0)
Jakub Grajciarcd01fb42020-03-02 13:16:53 +01001510 policer.remove_vpp_config()
Neale Rannsd91c1db2017-07-31 02:30:50 -07001511 self.send_and_expect(self.pg0, pkts, self.pg1)
1512
1513 #
1514 # remove the redirect. expect full drop.
1515 #
1516 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1517 self.pg1.sw_if_index,
1518 nh_addr,
1519 is_add=0)
1520 self.send_and_assert_no_replies(self.pg0, pkts,
1521 "IP no punt config")
1522
1523 #
1524 # Add a redirect that is not input port selective
1525 #
1526 self.vapi.ip_punt_redirect(0xffffffff,
1527 self.pg1.sw_if_index,
1528 nh_addr)
1529 self.send_and_expect(self.pg0, pkts, self.pg1)
1530
1531 self.vapi.ip_punt_redirect(0xffffffff,
1532 self.pg1.sw_if_index,
1533 nh_addr,
1534 is_add=0)
1535
Pavel Kotucek609e1212018-11-27 09:59:44 +01001536 def test_ip_punt_dump(self):
1537 """ IP4 punt redirect dump"""
1538
1539 #
1540 # Configure a punt redirects
1541 #
Ole Troan0bcad322018-12-11 13:04:01 +01001542 nh_address = self.pg3.remote_ip4
Pavel Kotucek609e1212018-11-27 09:59:44 +01001543 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1544 self.pg3.sw_if_index,
1545 nh_address)
1546 self.vapi.ip_punt_redirect(self.pg1.sw_if_index,
1547 self.pg3.sw_if_index,
1548 nh_address)
1549 self.vapi.ip_punt_redirect(self.pg2.sw_if_index,
1550 self.pg3.sw_if_index,
Ole Troan0bcad322018-12-11 13:04:01 +01001551 '0.0.0.0')
Pavel Kotucek609e1212018-11-27 09:59:44 +01001552
1553 #
1554 # Dump pg0 punt redirects
1555 #
1556 punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index)
1557 for p in punts:
1558 self.assertEqual(p.punt.rx_sw_if_index, self.pg0.sw_if_index)
1559
1560 #
1561 # Dump punt redirects for all interfaces
1562 #
1563 punts = self.vapi.ip_punt_redirect_dump(0xffffffff)
1564 self.assertEqual(len(punts), 3)
1565 for p in punts:
1566 self.assertEqual(p.punt.tx_sw_if_index, self.pg3.sw_if_index)
Ole Troan0bcad322018-12-11 13:04:01 +01001567 self.assertNotEqual(punts[1].punt.nh, self.pg3.remote_ip4)
1568 self.assertEqual(str(punts[2].punt.nh), '0.0.0.0')
Pavel Kotucek609e1212018-11-27 09:59:44 +01001569
Neale Rannsd91c1db2017-07-31 02:30:50 -07001570
Neale Ranns054c03a2017-10-13 05:15:07 -07001571class TestIPDeag(VppTestCase):
1572 """ IPv4 Deaggregate Routes """
1573
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001574 @classmethod
1575 def setUpClass(cls):
1576 super(TestIPDeag, cls).setUpClass()
1577
1578 @classmethod
1579 def tearDownClass(cls):
1580 super(TestIPDeag, cls).tearDownClass()
1581
Neale Ranns054c03a2017-10-13 05:15:07 -07001582 def setUp(self):
1583 super(TestIPDeag, self).setUp()
1584
1585 self.create_pg_interfaces(range(3))
1586
1587 for i in self.pg_interfaces:
1588 i.admin_up()
1589 i.config_ip4()
1590 i.resolve_arp()
1591
1592 def tearDown(self):
1593 super(TestIPDeag, self).tearDown()
1594 for i in self.pg_interfaces:
1595 i.unconfig_ip4()
1596 i.admin_down()
1597
Neale Ranns054c03a2017-10-13 05:15:07 -07001598 def test_ip_deag(self):
1599 """ IP Deag Routes """
1600
1601 #
1602 # Create a table to be used for:
1603 # 1 - another destination address lookup
1604 # 2 - a source address lookup
1605 #
1606 table_dst = VppIpTable(self, 1)
1607 table_src = VppIpTable(self, 2)
1608 table_dst.add_vpp_config()
1609 table_src.add_vpp_config()
1610
1611 #
1612 # Add a route in the default table to point to a deag/
1613 # second lookup in each of these tables
1614 #
1615 route_to_dst = VppIpRoute(self, "1.1.1.1", 32,
1616 [VppRoutePath("0.0.0.0",
1617 0xffffffff,
1618 nh_table_id=1)])
Neale Ranns097fa662018-05-01 05:17:55 -07001619 route_to_src = VppIpRoute(
1620 self, "1.1.1.2", 32,
1621 [VppRoutePath("0.0.0.0",
1622 0xffffffff,
1623 nh_table_id=2,
1624 type=FibPathType.FIB_PATH_TYPE_SOURCE_LOOKUP)])
Neale Ranns054c03a2017-10-13 05:15:07 -07001625 route_to_dst.add_vpp_config()
1626 route_to_src.add_vpp_config()
1627
1628 #
1629 # packets to these destination are dropped, since they'll
1630 # hit the respective default routes in the second table
1631 #
1632 p_dst = (Ether(src=self.pg0.remote_mac,
1633 dst=self.pg0.local_mac) /
1634 IP(src="5.5.5.5", dst="1.1.1.1") /
1635 TCP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001636 Raw(b'\xa5' * 100))
Neale Ranns054c03a2017-10-13 05:15:07 -07001637 p_src = (Ether(src=self.pg0.remote_mac,
1638 dst=self.pg0.local_mac) /
1639 IP(src="2.2.2.2", dst="1.1.1.2") /
1640 TCP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001641 Raw(b'\xa5' * 100))
Neale Ranns054c03a2017-10-13 05:15:07 -07001642 pkts_dst = p_dst * 257
1643 pkts_src = p_src * 257
1644
1645 self.send_and_assert_no_replies(self.pg0, pkts_dst,
1646 "IP in dst table")
1647 self.send_and_assert_no_replies(self.pg0, pkts_src,
1648 "IP in src table")
1649
1650 #
1651 # add a route in the dst table to forward via pg1
1652 #
1653 route_in_dst = VppIpRoute(self, "1.1.1.1", 32,
1654 [VppRoutePath(self.pg1.remote_ip4,
1655 self.pg1.sw_if_index)],
1656 table_id=1)
1657 route_in_dst.add_vpp_config()
Neale Ranns097fa662018-05-01 05:17:55 -07001658
Neale Ranns054c03a2017-10-13 05:15:07 -07001659 self.send_and_expect(self.pg0, pkts_dst, self.pg1)
1660
1661 #
1662 # add a route in the src table to forward via pg2
1663 #
1664 route_in_src = VppIpRoute(self, "2.2.2.2", 32,
1665 [VppRoutePath(self.pg2.remote_ip4,
1666 self.pg2.sw_if_index)],
1667 table_id=2)
1668 route_in_src.add_vpp_config()
1669 self.send_and_expect(self.pg0, pkts_src, self.pg2)
1670
Neale Rannsce9e0b42018-08-01 12:53:17 -07001671 #
1672 # loop in the lookup DP
1673 #
1674 route_loop = VppIpRoute(self, "2.2.2.3", 32,
1675 [VppRoutePath("0.0.0.0",
1676 0xffffffff,
1677 nh_table_id=0)])
1678 route_loop.add_vpp_config()
1679
1680 p_l = (Ether(src=self.pg0.remote_mac,
1681 dst=self.pg0.local_mac) /
1682 IP(src="2.2.2.4", dst="2.2.2.3") /
1683 TCP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001684 Raw(b'\xa5' * 100))
Neale Rannsce9e0b42018-08-01 12:53:17 -07001685
1686 self.send_and_assert_no_replies(self.pg0, p_l * 257,
1687 "IP lookup loop")
1688
Neale Ranns054c03a2017-10-13 05:15:07 -07001689
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001690class TestIPInput(VppTestCase):
1691 """ IPv4 Input Exceptions """
1692
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001693 @classmethod
1694 def setUpClass(cls):
1695 super(TestIPInput, cls).setUpClass()
1696
1697 @classmethod
1698 def tearDownClass(cls):
1699 super(TestIPInput, cls).tearDownClass()
1700
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001701 def setUp(self):
1702 super(TestIPInput, self).setUp()
1703
1704 self.create_pg_interfaces(range(2))
1705
1706 for i in self.pg_interfaces:
1707 i.admin_up()
1708 i.config_ip4()
1709 i.resolve_arp()
1710
1711 def tearDown(self):
1712 super(TestIPInput, self).tearDown()
1713 for i in self.pg_interfaces:
1714 i.unconfig_ip4()
1715 i.admin_down()
1716
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001717 def test_ip_input(self):
1718 """ IP Input Exceptions """
1719
1720 # i can't find a way in scapy to construct an IP packet
1721 # with a length less than the IP header length
1722
1723 #
1724 # Packet too short - this is forwarded
1725 #
1726 p_short = (Ether(src=self.pg0.remote_mac,
1727 dst=self.pg0.local_mac) /
1728 IP(src=self.pg0.remote_ip4,
1729 dst=self.pg1.remote_ip4,
1730 len=40) /
1731 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001732 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001733
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001734 rx = self.send_and_expect(self.pg0, p_short * NUM_PKTS, self.pg1)
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001735
1736 #
1737 # Packet too long - this is dropped
1738 #
1739 p_long = (Ether(src=self.pg0.remote_mac,
1740 dst=self.pg0.local_mac) /
1741 IP(src=self.pg0.remote_ip4,
1742 dst=self.pg1.remote_ip4,
1743 len=400) /
1744 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001745 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001746
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001747 rx = self.send_and_assert_no_replies(self.pg0, p_long * NUM_PKTS,
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001748 "too long")
1749
1750 #
1751 # bad chksum - this is dropped
1752 #
1753 p_chksum = (Ether(src=self.pg0.remote_mac,
1754 dst=self.pg0.local_mac) /
1755 IP(src=self.pg0.remote_ip4,
1756 dst=self.pg1.remote_ip4,
1757 chksum=400) /
1758 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001759 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001760
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001761 rx = self.send_and_assert_no_replies(self.pg0, p_chksum * NUM_PKTS,
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001762 "bad checksum")
1763
1764 #
1765 # bad version - this is dropped
1766 #
1767 p_ver = (Ether(src=self.pg0.remote_mac,
1768 dst=self.pg0.local_mac) /
1769 IP(src=self.pg0.remote_ip4,
1770 dst=self.pg1.remote_ip4,
1771 version=3) /
1772 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001773 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001774
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001775 rx = self.send_and_assert_no_replies(self.pg0, p_ver * NUM_PKTS,
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001776 "funky version")
1777
1778 #
1779 # fragment offset 1 - this is dropped
1780 #
1781 p_frag = (Ether(src=self.pg0.remote_mac,
1782 dst=self.pg0.local_mac) /
1783 IP(src=self.pg0.remote_ip4,
1784 dst=self.pg1.remote_ip4,
1785 frag=1) /
1786 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001787 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001788
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001789 rx = self.send_and_assert_no_replies(self.pg0, p_frag * NUM_PKTS,
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001790 "frag offset")
1791
1792 #
1793 # TTL expired packet
1794 #
1795 p_ttl = (Ether(src=self.pg0.remote_mac,
1796 dst=self.pg0.local_mac) /
1797 IP(src=self.pg0.remote_ip4,
1798 dst=self.pg1.remote_ip4,
1799 ttl=1) /
1800 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001801 Raw(b'\xa5' * 100))
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001802
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001803 rx = self.send_and_expect(self.pg0, p_ttl * NUM_PKTS, self.pg0)
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001804
1805 rx = rx[0]
1806 icmp = rx[ICMP]
1807
1808 self.assertEqual(icmptypes[icmp.type], "time-exceeded")
1809 self.assertEqual(icmpcodes[icmp.type][icmp.code],
1810 "ttl-zero-during-transit")
1811 self.assertEqual(icmp.src, self.pg0.remote_ip4)
1812 self.assertEqual(icmp.dst, self.pg1.remote_ip4)
1813
Neale Rannsffd78d12018-02-09 06:05:16 -08001814 #
1815 # MTU exceeded
1816 #
1817 p_mtu = (Ether(src=self.pg0.remote_mac,
1818 dst=self.pg0.local_mac) /
1819 IP(src=self.pg0.remote_ip4,
1820 dst=self.pg1.remote_ip4,
Ole Troan8a9c8f12018-05-18 11:01:31 +02001821 ttl=10, flags='DF') /
Neale Rannsffd78d12018-02-09 06:05:16 -08001822 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001823 Raw(b'\xa5' * 2000))
Neale Rannsffd78d12018-02-09 06:05:16 -08001824
Ole Troand7231612018-06-07 10:17:57 +02001825 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1500, 0, 0, 0])
Neale Rannsffd78d12018-02-09 06:05:16 -08001826
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001827 rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg0)
Neale Rannsffd78d12018-02-09 06:05:16 -08001828 rx = rx[0]
1829 icmp = rx[ICMP]
1830
1831 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
1832 self.assertEqual(icmpcodes[icmp.type][icmp.code],
1833 "fragmentation-needed")
1834 self.assertEqual(icmp.src, self.pg0.remote_ip4)
1835 self.assertEqual(icmp.dst, self.pg1.remote_ip4)
1836
Ole Troand7231612018-06-07 10:17:57 +02001837 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [2500, 0, 0, 0])
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001838 rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg1)
Neale Rannsffd78d12018-02-09 06:05:16 -08001839
Ole Troand7231612018-06-07 10:17:57 +02001840 # Reset MTU for subsequent tests
1841 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [9000, 0, 0, 0])
Neale Ranns4c7c8e52017-10-21 09:37:55 -07001842
Neale Rannsbe2286b2018-12-09 12:54:51 -08001843 #
1844 # source address 0.0.0.0 and 25.255.255.255 and for-us
1845 #
1846 p_s0 = (Ether(src=self.pg0.remote_mac,
1847 dst=self.pg0.local_mac) /
1848 IP(src="0.0.0.0",
1849 dst=self.pg0.local_ip4) /
1850 ICMP(id=4, seq=4) /
Ole Troan5e56f752019-10-21 21:06:52 +02001851 Raw(load=b'\x0a' * 18))
Neale Rannsbe2286b2018-12-09 12:54:51 -08001852 rx = self.send_and_assert_no_replies(self.pg0, p_s0 * 17)
1853
1854 p_s0 = (Ether(src=self.pg0.remote_mac,
1855 dst=self.pg0.local_mac) /
1856 IP(src="255.255.255.255",
1857 dst=self.pg0.local_ip4) /
1858 ICMP(id=4, seq=4) /
Ole Troan5e56f752019-10-21 21:06:52 +02001859 Raw(load=b'\x0a' * 18))
Neale Rannsbe2286b2018-12-09 12:54:51 -08001860 rx = self.send_and_assert_no_replies(self.pg0, p_s0 * 17)
1861
Neale Ranns1855b8e2018-07-11 10:31:26 -07001862
1863class TestIPDirectedBroadcast(VppTestCase):
1864 """ IPv4 Directed Broadcast """
1865
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001866 @classmethod
1867 def setUpClass(cls):
1868 super(TestIPDirectedBroadcast, cls).setUpClass()
1869
1870 @classmethod
1871 def tearDownClass(cls):
1872 super(TestIPDirectedBroadcast, cls).tearDownClass()
1873
Neale Ranns1855b8e2018-07-11 10:31:26 -07001874 def setUp(self):
1875 super(TestIPDirectedBroadcast, self).setUp()
1876
1877 self.create_pg_interfaces(range(2))
1878
1879 for i in self.pg_interfaces:
1880 i.admin_up()
1881
1882 def tearDown(self):
1883 super(TestIPDirectedBroadcast, self).tearDown()
1884 for i in self.pg_interfaces:
1885 i.admin_down()
1886
1887 def test_ip_input(self):
1888 """ IP Directed Broadcast """
1889
1890 #
1891 # set the directed broadcast on pg0 first, then config IP4 addresses
1892 # for pg1 directed broadcast is always disabled
1893 self.vapi.sw_interface_set_ip_directed_broadcast(
1894 self.pg0.sw_if_index, 1)
1895
1896 p0 = (Ether(src=self.pg1.remote_mac,
1897 dst=self.pg1.local_mac) /
1898 IP(src="1.1.1.1",
1899 dst=self.pg0._local_ip4_bcast) /
1900 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001901 Raw(b'\xa5' * 2000))
Neale Ranns1855b8e2018-07-11 10:31:26 -07001902 p1 = (Ether(src=self.pg0.remote_mac,
1903 dst=self.pg0.local_mac) /
1904 IP(src="1.1.1.1",
1905 dst=self.pg1._local_ip4_bcast) /
1906 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001907 Raw(b'\xa5' * 2000))
Neale Ranns1855b8e2018-07-11 10:31:26 -07001908
1909 self.pg0.config_ip4()
1910 self.pg0.resolve_arp()
1911 self.pg1.config_ip4()
1912 self.pg1.resolve_arp()
1913
1914 #
1915 # test packet is L2 broadcast
1916 #
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001917 rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0)
Neale Ranns1855b8e2018-07-11 10:31:26 -07001918 self.assertTrue(rx[0][Ether].dst, "ff:ff:ff:ff:ff:ff")
1919
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001920 self.send_and_assert_no_replies(self.pg0, p1 * NUM_PKTS,
Neale Ranns1855b8e2018-07-11 10:31:26 -07001921 "directed broadcast disabled")
1922
1923 #
1924 # toggle directed broadcast on pg0
1925 #
1926 self.vapi.sw_interface_set_ip_directed_broadcast(
1927 self.pg0.sw_if_index, 0)
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001928 self.send_and_assert_no_replies(self.pg1, p0 * NUM_PKTS,
Neale Ranns1855b8e2018-07-11 10:31:26 -07001929 "directed broadcast disabled")
1930
1931 self.vapi.sw_interface_set_ip_directed_broadcast(
1932 self.pg0.sw_if_index, 1)
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001933 rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0)
Neale Ranns1855b8e2018-07-11 10:31:26 -07001934
1935 self.pg0.unconfig_ip4()
1936 self.pg1.unconfig_ip4()
1937
1938
mu.duojiao59a82952018-10-11 14:27:30 +08001939class TestIPLPM(VppTestCase):
1940 """ IPv4 longest Prefix Match """
1941
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07001942 @classmethod
1943 def setUpClass(cls):
1944 super(TestIPLPM, cls).setUpClass()
1945
1946 @classmethod
1947 def tearDownClass(cls):
1948 super(TestIPLPM, cls).tearDownClass()
1949
mu.duojiao59a82952018-10-11 14:27:30 +08001950 def setUp(self):
1951 super(TestIPLPM, self).setUp()
1952
1953 self.create_pg_interfaces(range(4))
1954
1955 for i in self.pg_interfaces:
1956 i.admin_up()
1957 i.config_ip4()
1958 i.resolve_arp()
1959
1960 def tearDown(self):
1961 super(TestIPLPM, self).tearDown()
1962 for i in self.pg_interfaces:
1963 i.admin_down()
1964 i.unconfig_ip4()
1965
1966 def test_ip_lpm(self):
1967 """ IP longest Prefix Match """
1968
1969 s_24 = VppIpRoute(self, "10.1.2.0", 24,
1970 [VppRoutePath(self.pg1.remote_ip4,
1971 self.pg1.sw_if_index)])
1972 s_24.add_vpp_config()
1973 s_8 = VppIpRoute(self, "10.0.0.0", 8,
1974 [VppRoutePath(self.pg2.remote_ip4,
1975 self.pg2.sw_if_index)])
1976 s_8.add_vpp_config()
1977
1978 p_8 = (Ether(src=self.pg0.remote_mac,
1979 dst=self.pg0.local_mac) /
1980 IP(src="1.1.1.1",
1981 dst="10.1.1.1") /
1982 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001983 Raw(b'\xa5' * 2000))
mu.duojiao59a82952018-10-11 14:27:30 +08001984 p_24 = (Ether(src=self.pg0.remote_mac,
1985 dst=self.pg0.local_mac) /
1986 IP(src="1.1.1.1",
1987 dst="10.1.2.1") /
1988 UDP(sport=1234, dport=1234) /
Ole Troan5e56f752019-10-21 21:06:52 +02001989 Raw(b'\xa5' * 2000))
mu.duojiao59a82952018-10-11 14:27:30 +08001990
1991 self.logger.info(self.vapi.cli("sh ip fib mtrie"))
Paul Vinciguerra4271c972019-05-14 13:25:49 -04001992 rx = self.send_and_expect(self.pg0, p_8 * NUM_PKTS, self.pg2)
1993 rx = self.send_and_expect(self.pg0, p_24 * NUM_PKTS, self.pg1)
mu.duojiao59a82952018-10-11 14:27:30 +08001994
1995
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02001996class TestIPv4Frag(VppTestCase):
1997 """ IPv4 fragmentation """
1998
1999 @classmethod
2000 def setUpClass(cls):
2001 super(TestIPv4Frag, cls).setUpClass()
2002
2003 cls.create_pg_interfaces([0, 1])
2004 cls.src_if = cls.pg0
2005 cls.dst_if = cls.pg1
2006
2007 # setup all interfaces
2008 for i in cls.pg_interfaces:
2009 i.admin_up()
2010 i.config_ip4()
2011 i.resolve_arp()
2012
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -07002013 @classmethod
2014 def tearDownClass(cls):
2015 super(TestIPv4Frag, cls).tearDownClass()
2016
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02002017 def test_frag_large_packets(self):
2018 """ Fragmentation of large packets """
2019
Neale Ranns0b6a8572019-10-30 17:34:14 +00002020 self.vapi.cli("adjacency counters enable")
2021
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02002022 p = (Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) /
2023 IP(src=self.src_if.remote_ip4, dst=self.dst_if.remote_ip4) /
2024 UDP(sport=1234, dport=5678) / Raw())
2025 self.extend_packet(p, 6000, "abcde")
2026 saved_payload = p[Raw].load
2027
Neale Ranns0b6a8572019-10-30 17:34:14 +00002028 nbr = VppNeighbor(self,
2029 self.dst_if.sw_if_index,
2030 self.dst_if.remote_mac,
2031 self.dst_if.remote_ip4).add_vpp_config()
2032
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02002033 # Force fragmentation by setting MTU of output interface
2034 # lower than packet size
2035 self.vapi.sw_interface_set_mtu(self.dst_if.sw_if_index,
2036 [5000, 0, 0, 0])
2037
2038 self.pg_enable_capture()
2039 self.src_if.add_stream(p)
2040 self.pg_start()
2041
2042 # Expecting 3 fragments because size of created fragments currently
2043 # cannot be larger then VPP buffer size (which is 2048)
2044 packets = self.dst_if.get_capture(3)
2045
Neale Ranns0b6a8572019-10-30 17:34:14 +00002046 # we should show 3 packets thru the neighbor
2047 self.assertEqual(3, nbr.get_stats()['packets'])
2048
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02002049 # Assume VPP sends the fragments in order
Ole Troan6ed154f2019-10-15 19:31:55 +02002050 payload = b''
Juraj Sloboda68b7cb82018-10-16 12:18:21 +02002051 for p in packets:
2052 payload_offset = p.frag * 8
2053 if payload_offset > 0:
2054 payload_offset -= 8 # UDP header is not in payload
2055 self.assert_equal(payload_offset, len(payload))
2056 payload += p[Raw].load
2057 self.assert_equal(payload, saved_payload, "payload")
2058
2059
Neale Ranns9db6ada2019-11-08 12:42:31 +00002060class TestIPReplace(VppTestCase):
2061 """ IPv4 Table Replace """
2062
2063 @classmethod
2064 def setUpClass(cls):
2065 super(TestIPReplace, cls).setUpClass()
2066
2067 @classmethod
2068 def tearDownClass(cls):
2069 super(TestIPReplace, cls).tearDownClass()
2070
2071 def setUp(self):
2072 super(TestIPReplace, self).setUp()
2073
2074 self.create_pg_interfaces(range(4))
2075
2076 table_id = 1
2077 self.tables = []
2078
2079 for i in self.pg_interfaces:
2080 i.admin_up()
2081 i.config_ip4()
2082 i.resolve_arp()
2083 i.generate_remote_hosts(2)
2084 self.tables.append(VppIpTable(self, table_id).add_vpp_config())
2085 table_id += 1
2086
2087 def tearDown(self):
2088 super(TestIPReplace, self).tearDown()
2089 for i in self.pg_interfaces:
2090 i.admin_down()
2091 i.unconfig_ip4()
2092
2093 def test_replace(self):
2094 """ IP Table Replace """
2095
Neale Ranns990f6942020-10-20 07:20:17 +00002096 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
2097 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
Neale Ranns9db6ada2019-11-08 12:42:31 +00002098 N_ROUTES = 20
2099 links = [self.pg0, self.pg1, self.pg2, self.pg3]
2100 routes = [[], [], [], []]
2101
2102 # load up the tables with some routes
2103 for ii, t in enumerate(self.tables):
2104 for jj in range(N_ROUTES):
2105 uni = VppIpRoute(
2106 self, "10.0.0.%d" % jj, 32,
2107 [VppRoutePath(links[ii].remote_hosts[0].ip4,
2108 links[ii].sw_if_index),
2109 VppRoutePath(links[ii].remote_hosts[1].ip4,
2110 links[ii].sw_if_index)],
2111 table_id=t.table_id).add_vpp_config()
2112 multi = VppIpMRoute(
2113 self, "0.0.0.0",
2114 "239.0.0.%d" % jj, 32,
Neale Ranns990f6942020-10-20 07:20:17 +00002115 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Ranns9db6ada2019-11-08 12:42:31 +00002116 [VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +00002117 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Ranns9db6ada2019-11-08 12:42:31 +00002118 VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +00002119 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
Neale Ranns9db6ada2019-11-08 12:42:31 +00002120 VppMRoutePath(self.pg2.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +00002121 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
Neale Ranns9db6ada2019-11-08 12:42:31 +00002122 VppMRoutePath(self.pg3.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +00002123 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)],
Neale Ranns9db6ada2019-11-08 12:42:31 +00002124 table_id=t.table_id).add_vpp_config()
2125 routes[ii].append({'uni': uni,
2126 'multi': multi})
2127
2128 #
2129 # replace the tables a few times
2130 #
2131 for kk in range(3):
2132 # replace_begin each table
2133 for t in self.tables:
2134 t.replace_begin()
2135
2136 # all the routes are still there
2137 for ii, t in enumerate(self.tables):
2138 dump = t.dump()
2139 mdump = t.mdump()
2140 for r in routes[ii]:
2141 self.assertTrue(find_route_in_dump(dump, r['uni'], t))
2142 self.assertTrue(find_mroute_in_dump(mdump, r['multi'], t))
2143
2144 # redownload the even numbered routes
2145 for ii, t in enumerate(self.tables):
2146 for jj in range(0, N_ROUTES, 2):
2147 routes[ii][jj]['uni'].add_vpp_config()
2148 routes[ii][jj]['multi'].add_vpp_config()
2149
2150 # signal each table replace_end
2151 for t in self.tables:
2152 t.replace_end()
2153
2154 # we should find the even routes, but not the odd
2155 for ii, t in enumerate(self.tables):
2156 dump = t.dump()
2157 mdump = t.mdump()
2158 for jj in range(0, N_ROUTES, 2):
2159 self.assertTrue(find_route_in_dump(
2160 dump, routes[ii][jj]['uni'], t))
2161 self.assertTrue(find_mroute_in_dump(
2162 mdump, routes[ii][jj]['multi'], t))
2163 for jj in range(1, N_ROUTES - 1, 2):
2164 self.assertFalse(find_route_in_dump(
2165 dump, routes[ii][jj]['uni'], t))
2166 self.assertFalse(find_mroute_in_dump(
2167 mdump, routes[ii][jj]['multi'], t))
2168
2169 # reload all the routes
2170 for ii, t in enumerate(self.tables):
2171 for r in routes[ii]:
2172 r['uni'].add_vpp_config()
2173 r['multi'].add_vpp_config()
2174
2175 # all the routes are still there
2176 for ii, t in enumerate(self.tables):
2177 dump = t.dump()
2178 mdump = t.mdump()
2179 for r in routes[ii]:
2180 self.assertTrue(find_route_in_dump(dump, r['uni'], t))
2181 self.assertTrue(find_mroute_in_dump(mdump, r['multi'], t))
2182
2183 #
2184 # finally flush the tables for good measure
2185 #
2186 for t in self.tables:
2187 t.flush()
2188 self.assertEqual(len(t.dump()), 5)
Neale Ranns03c254e2020-03-17 14:25:10 +00002189 self.assertEqual(len(t.mdump()), 3)
Neale Ranns9db6ada2019-11-08 12:42:31 +00002190
2191
Neale Ranns9efcee62019-11-26 19:30:08 +00002192class TestIPCover(VppTestCase):
2193 """ IPv4 Table Cover """
2194
2195 @classmethod
2196 def setUpClass(cls):
2197 super(TestIPCover, cls).setUpClass()
2198
2199 @classmethod
2200 def tearDownClass(cls):
2201 super(TestIPCover, cls).tearDownClass()
2202
2203 def setUp(self):
2204 super(TestIPCover, self).setUp()
2205
2206 self.create_pg_interfaces(range(4))
2207
2208 table_id = 1
2209 self.tables = []
2210
2211 for i in self.pg_interfaces:
2212 i.admin_up()
2213 i.config_ip4()
2214 i.resolve_arp()
2215 i.generate_remote_hosts(2)
2216 self.tables.append(VppIpTable(self, table_id).add_vpp_config())
2217 table_id += 1
2218
2219 def tearDown(self):
2220 super(TestIPCover, self).tearDown()
2221 for i in self.pg_interfaces:
2222 i.admin_down()
2223 i.unconfig_ip4()
2224
2225 def test_cover(self):
2226 """ IP Table Cover """
2227
2228 # add a loop back with a /32 prefix
2229 lo = VppLoInterface(self)
2230 lo.admin_up()
2231 a = VppIpInterfaceAddress(self, lo, "127.0.0.1", 32).add_vpp_config()
2232
2233 # add a neighbour that matches the loopback's /32
2234 nbr = VppNeighbor(self,
2235 lo.sw_if_index,
2236 lo.remote_mac,
2237 "127.0.0.1").add_vpp_config()
2238
2239 # add the default route which will be the cover for /32
2240 r = VppIpRoute(self, "0.0.0.0", 0,
2241 [VppRoutePath("127.0.0.1",
2242 lo.sw_if_index)],
2243 register=False).add_vpp_config()
2244
2245 # add/remove/add a longer mask cover
Neale Ranns87866032020-11-25 09:14:22 +00002246 r8 = VppIpRoute(self, "127.0.0.0", 8,
2247 [VppRoutePath("127.0.0.1",
2248 lo.sw_if_index)]).add_vpp_config()
2249 r8.remove_vpp_config()
2250 r8.add_vpp_config()
2251 r8.remove_vpp_config()
Neale Ranns9efcee62019-11-26 19:30:08 +00002252
2253 # remove the default route
2254 r.remove_vpp_config()
2255
Neale Ranns87866032020-11-25 09:14:22 +00002256 # remove the interface prefix
2257 a.remove_vpp_config()
2258
Neale Ranns59f71132020-04-08 12:19:38 +00002259
2260class TestIP4Replace(VppTestCase):
2261 """ IPv4 Interface Address Replace """
2262
2263 @classmethod
2264 def setUpClass(cls):
2265 super(TestIP4Replace, cls).setUpClass()
2266
2267 @classmethod
2268 def tearDownClass(cls):
2269 super(TestIP4Replace, cls).tearDownClass()
2270
2271 def setUp(self):
2272 super(TestIP4Replace, self).setUp()
2273
2274 self.create_pg_interfaces(range(4))
2275
2276 for i in self.pg_interfaces:
2277 i.admin_up()
2278
2279 def tearDown(self):
2280 super(TestIP4Replace, self).tearDown()
2281 for i in self.pg_interfaces:
2282 i.admin_down()
2283
2284 def get_n_pfxs(self, intf):
2285 return len(self.vapi.ip_address_dump(intf.sw_if_index))
2286
2287 def test_replace(self):
2288 """ IP interface address replace """
2289
2290 intf_pfxs = [[], [], [], []]
2291
2292 # add prefixes to each of the interfaces
2293 for i in range(len(self.pg_interfaces)):
2294 intf = self.pg_interfaces[i]
2295
2296 # 172.16.x.1/24
2297 addr = "172.16.%d.1" % intf.sw_if_index
2298 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2299 intf_pfxs[i].append(a)
2300
2301 # 172.16.x.2/24 - a different address in the same subnet as above
2302 addr = "172.16.%d.2" % intf.sw_if_index
2303 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2304 intf_pfxs[i].append(a)
2305
2306 # 172.15.x.2/24 - a different address and subnet
2307 addr = "172.15.%d.2" % intf.sw_if_index
2308 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2309 intf_pfxs[i].append(a)
2310
2311 # a dump should n_address in it
2312 for intf in self.pg_interfaces:
2313 self.assertEqual(self.get_n_pfxs(intf), 3)
2314
2315 #
2316 # remove all the address thru a replace
2317 #
2318 self.vapi.sw_interface_address_replace_begin()
2319 self.vapi.sw_interface_address_replace_end()
2320 for intf in self.pg_interfaces:
2321 self.assertEqual(self.get_n_pfxs(intf), 0)
2322
2323 #
2324 # add all the interface addresses back
2325 #
2326 for p in intf_pfxs:
2327 for v in p:
2328 v.add_vpp_config()
2329 for intf in self.pg_interfaces:
2330 self.assertEqual(self.get_n_pfxs(intf), 3)
2331
2332 #
2333 # replace again, but this time update/re-add the address on the first
2334 # two interfaces
2335 #
2336 self.vapi.sw_interface_address_replace_begin()
2337
2338 for p in intf_pfxs[:2]:
2339 for v in p:
2340 v.add_vpp_config()
2341
2342 self.vapi.sw_interface_address_replace_end()
2343
2344 # on the first two the address still exist,
2345 # on the other two they do not
2346 for intf in self.pg_interfaces[:2]:
2347 self.assertEqual(self.get_n_pfxs(intf), 3)
2348 for p in intf_pfxs[:2]:
2349 for v in p:
2350 self.assertTrue(v.query_vpp_config())
2351 for intf in self.pg_interfaces[2:]:
2352 self.assertEqual(self.get_n_pfxs(intf), 0)
2353
2354 #
2355 # add all the interface addresses back on the last two
2356 #
2357 for p in intf_pfxs[2:]:
2358 for v in p:
2359 v.add_vpp_config()
2360 for intf in self.pg_interfaces:
2361 self.assertEqual(self.get_n_pfxs(intf), 3)
2362
2363 #
2364 # replace again, this time add different prefixes on all the interfaces
2365 #
2366 self.vapi.sw_interface_address_replace_begin()
2367
2368 pfxs = []
2369 for intf in self.pg_interfaces:
2370 # 172.18.x.1/24
2371 addr = "172.18.%d.1" % intf.sw_if_index
2372 pfxs.append(VppIpInterfaceAddress(self, intf, addr,
2373 24).add_vpp_config())
2374
2375 self.vapi.sw_interface_address_replace_end()
2376
2377 # only .18 should exist on each interface
2378 for intf in self.pg_interfaces:
2379 self.assertEqual(self.get_n_pfxs(intf), 1)
2380 for pfx in pfxs:
2381 self.assertTrue(pfx.query_vpp_config())
2382
2383 #
2384 # remove everything
2385 #
2386 self.vapi.sw_interface_address_replace_begin()
2387 self.vapi.sw_interface_address_replace_end()
2388 for intf in self.pg_interfaces:
2389 self.assertEqual(self.get_n_pfxs(intf), 0)
2390
2391 #
2392 # add prefixes to each interface. post-begin add the prefix from
2393 # interface X onto interface Y. this would normally be an error
2394 # since it would generate a 'duplicate address' warning. but in
2395 # this case, since what is newly downloaded is sane, it's ok
2396 #
2397 for intf in self.pg_interfaces:
2398 # 172.18.x.1/24
2399 addr = "172.18.%d.1" % intf.sw_if_index
2400 VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2401
2402 self.vapi.sw_interface_address_replace_begin()
2403
2404 pfxs = []
2405 for intf in self.pg_interfaces:
2406 # 172.18.x.1/24
2407 addr = "172.18.%d.1" % (intf.sw_if_index + 1)
2408 pfxs.append(VppIpInterfaceAddress(self, intf,
2409 addr, 24).add_vpp_config())
2410
2411 self.vapi.sw_interface_address_replace_end()
2412
2413 self.logger.info(self.vapi.cli("sh int addr"))
2414
2415 for intf in self.pg_interfaces:
2416 self.assertEqual(self.get_n_pfxs(intf), 1)
2417 for pfx in pfxs:
2418 self.assertTrue(pfx.query_vpp_config())
2419
2420
Damjan Marionf56b77a2016-10-03 19:44:57 +02002421if __name__ == '__main__':
Klement Sekeraf62ae122016-10-11 11:47:09 +02002422 unittest.main(testRunner=VppTestRunner)