8 from scapy.contrib.mpls import MPLS
9 from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
10 from scapy.layers.l2 import Ether, Dot1Q, ARP
11 from scapy.packet import Raw
14 from framework import VppTestCase, VppTestRunner
16 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
17 VppMRoutePath, VppMplsIpBind, \
18 VppMplsTable, VppIpTable, FibPathType, find_route, \
19 VppIpInterfaceAddress, find_route_in_dump, find_mroute_in_dump
20 from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
21 from vpp_papi import VppEnum
22 from vpp_neighbor import VppNeighbor
23 from vpp_lo_interface import VppLoInterface
24 from vpp_policer import VppPolicer
29 class TestIPv4(VppTestCase):
30 """ IPv4 Test Case """
34 super(TestIPv4, cls).setUpClass()
37 def tearDownClass(cls):
38 super(TestIPv4, cls).tearDownClass()
42 Perform test setup before test case.
45 - create 3 pg interfaces
46 - untagged pg0 interface
47 - Dot1Q subinterface on pg1
48 - Dot1AD subinterface on pg2
50 - put it into UP state
52 - resolve neighbor address using ARP
53 - configure 200 fib entries
55 :ivar list interfaces: pg interfaces and subinterfaces.
56 :ivar dict flows: IPv4 packet flows in test.
58 super(TestIPv4, self).setUp()
60 # create 3 pg interfaces
61 self.create_pg_interfaces(range(3))
63 # 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)]
68 # packet flows mapping pg0 -> pg1.sub, pg2.sub, etc.
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]
75 self.pg_if_packet_sizes = [64, 1500, 9020]
77 self.interfaces = list(self.pg_interfaces)
78 self.interfaces.extend(self.sub_interfaces)
80 # setup all interfaces
81 for i in self.interfaces:
86 # config 2M FIB entries
89 """Run standard test teardown and log ``show ip arp``."""
90 super(TestIPv4, self).tearDown()
92 def show_commands_at_teardown(self):
93 self.logger.info(self.vapi.cli("show ip4 neighbors"))
94 # info(self.vapi.cli("show ip fib")) # many entries
96 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.
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.
104 dst_if_idx = int(packet_size / 10 % 2)
105 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)
109 p[IP].dst = dst_if.remote_ip4
111 if isinstance(src_if, VppSubInterface):
112 p = src_if.add_dot1_layer(p)
113 self.extend_packet(p, packet_size)
117 def create_stream(self, src_if):
118 """Create input packet stream for defined interface.
120 :param VppInterface src_if: Interface to create packet stream for.
122 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))
127 pkts = [self.modify_packet(src_if, i, pkt_tmpl)
128 for i in moves.range(self.pg_if_packet_sizes[0],
129 self.pg_if_packet_sizes[1], 10)]
130 pkts_b = [self.modify_packet(src_if, i, pkt_tmpl)
131 for i in moves.range(self.pg_if_packet_sizes[1] + hdr_ext,
132 self.pg_if_packet_sizes[2] + hdr_ext,
138 def verify_capture(self, dst_if, capture):
139 """Verify captured input packet stream for defined interface.
141 :param VppInterface dst_if: Interface to verify captured packet stream
143 :param list capture: Captured packet stream.
145 self.logger.info("Verifying capture on interface %s" % dst_if.name)
147 for i in self.interfaces:
148 last_info[i.sw_if_index] = None
150 dst_sw_if_index = dst_if.sw_if_index
151 if hasattr(dst_if, 'parent'):
153 for packet in capture:
155 # Check VLAN tags and Ethernet header
156 packet = dst_if.remove_dot1_layer(packet)
157 self.assertTrue(Dot1Q not in packet)
161 payload_info = self.payload_to_info(packet[Raw])
162 packet_index = payload_info.index
163 self.assertEqual(payload_info.dst, dst_sw_if_index)
165 "Got packet on port %s: src=%u (id=%u)" %
166 (dst_if.name, payload_info.src, packet_index))
167 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
171 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)
180 self.logger.error(ppp("Unexpected or invalid packet:", packet))
182 for i in self.interfaces:
183 remaining_packet = self.get_next_packet_info_for_interface2(
184 i.sw_if_index, dst_sw_if_index, last_info[i.sw_if_index])
185 self.assertTrue(remaining_packet is None,
186 "Interface %s: Packet expected from interface %s "
187 "didn't arrive" % (dst_if.name, i.name))
194 - Create IPv4 stream for pg0 interface
195 - Create IPv4 tagged streams for pg1's and pg2's sub-interface.
196 - Send and verify received packets on each interface.
199 pkts = self.create_stream(self.pg0)
200 self.pg0.add_stream(pkts)
202 for i in self.sub_interfaces:
203 pkts = self.create_stream(i)
204 i.parent.add_stream(pkts)
206 self.pg_enable_capture(self.pg_interfaces)
209 pkts = self.pg0.get_capture()
210 self.verify_capture(self.pg0, pkts)
212 for i in self.sub_interfaces:
213 pkts = i.parent.get_capture()
214 self.verify_capture(i, pkts)
217 class TestIPv4RouteLookup(VppTestCase):
218 """ IPv4 Route Lookup Test Case """
221 def route_lookup(self, prefix, exact):
222 return self.vapi.api(self.vapi.papi.ip_route_lookup,
231 super(TestIPv4RouteLookup, cls).setUpClass()
234 def tearDownClass(cls):
235 super(TestIPv4RouteLookup, cls).tearDownClass()
238 super(TestIPv4RouteLookup, self).setUp()
240 drop_nh = VppRoutePath("127.0.0.1", 0xffffffff,
241 type=FibPathType.FIB_PATH_TYPE_DROP)
244 r = VppIpRoute(self, "1.1.0.0", 16, [drop_nh])
246 self.routes.append(r)
248 r = VppIpRoute(self, "1.1.1.0", 24, [drop_nh])
250 self.routes.append(r)
252 r = VppIpRoute(self, "1.1.1.1", 32, [drop_nh])
254 self.routes.append(r)
257 # Remove the routes we added
258 for r in self.routes:
259 r.remove_vpp_config()
261 super(TestIPv4RouteLookup, self).tearDown()
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))
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))
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)
278 def test_longest_prefix_match(self):
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))
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))
288 # Can't seem to delete the default route so no negative LPM test.
291 class TestIPv4IfAddrRoute(VppTestCase):
292 """ IPv4 Interface Addr Route Test Case """
296 super(TestIPv4IfAddrRoute, cls).setUpClass()
299 def tearDownClass(cls):
300 super(TestIPv4IfAddrRoute, cls).tearDownClass()
303 super(TestIPv4IfAddrRoute, self).setUp()
305 # create 1 pg interface
306 self.create_pg_interfaces(range(1))
308 for i in self.pg_interfaces:
314 super(TestIPv4IfAddrRoute, self).tearDown()
315 for i in self.pg_interfaces:
319 def test_ipv4_ifaddrs_same_prefix(self):
320 """ IPv4 Interface Addresses Same Prefix test
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
334 # create two addresses, verify route not present
335 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
338 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))
343 # configure first address, verify route present
344 if_addr1.add_vpp_config()
345 self.assertTrue(if_addr1.query_vpp_config()) # 10.10.10.10/24
346 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))
351 # configure second address, delete first, verify route not removed
352 if_addr2.add_vpp_config()
353 if_addr1.remove_vpp_config()
354 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
356 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))
361 # delete second address, verify route removed
362 if_addr2.remove_vpp_config()
363 self.assertFalse(if_addr2.query_vpp_config()) # 10.10.10.20/24
364 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))
369 def test_ipv4_ifaddr_route(self):
370 """ IPv4 Interface Address Route test
375 - Configure IPv4 address on loopback
376 - Verify that address is not in the FIB
378 - Verify that address is in the FIB now
379 - Bring loopback down
380 - Verify that address is not in the FIB anymore
382 - Configure IPv4 address on loopback
383 - Verify that address is in the FIB now
386 # create a loopback and configure IPv4
387 loopbacks = self.create_loopback_interfaces(1)
388 lo_if = self.lo_interfaces[0]
390 lo_if.local_ip4_prefix_len = 32
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))
397 # When intf is brought up, entry is added
399 fib4_dump = self.vapi.ip_route_dump(0)
400 self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
402 # When intf is brought down, entry is removed
404 fib4_dump = self.vapi.ip_route_dump(0)
405 self.assertFalse(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
407 # Remove addr, bring up interface, re-add -> entry in FIB
411 fib4_dump = self.vapi.ip_route_dump(0)
412 self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump))
414 def test_ipv4_ifaddr_del(self):
415 """ Delete an interface address that does not exist """
417 loopbacks = self.create_loopback_interfaces(1)
418 lo = self.lo_interfaces[0]
424 # try and remove pg0's subnet from lo
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,
433 class TestICMPEcho(VppTestCase):
434 """ ICMP Echo Test Case """
438 super(TestICMPEcho, cls).setUpClass()
441 def tearDownClass(cls):
442 super(TestICMPEcho, cls).tearDownClass()
445 super(TestICMPEcho, self).setUp()
447 # create 1 pg interface
448 self.create_pg_interfaces(range(1))
450 for i in self.pg_interfaces:
456 super(TestICMPEcho, self).tearDown()
457 for i in self.pg_interfaces:
461 def test_icmp_echo(self):
462 """ VPP replies to ICMP Echo Request
466 - Receive ICMP Echo Request message on pg0 interface.
467 - Check outgoing ICMP Echo Reply message on pg0 interface.
472 icmp_load = b'\x0a' * 18
473 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) /
479 self.pg0.add_stream(p_echo_request)
480 self.pg_enable_capture(self.pg_interfaces)
483 rx = self.pg0.get_capture(1)
489 self.assertEqual(ether.src, self.pg0.local_mac)
490 self.assertEqual(ether.dst, self.pg0.remote_mac)
492 self.assertEqual(ipv4.src, self.pg0.local_ip4)
493 self.assertEqual(ipv4.dst, self.pg0.remote_ip4)
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)
501 class TestIPv4FibCrud(VppTestCase):
502 """ FIB - add/update/delete - ip4 routes
510 ..note:: Python API is too slow to add many routes, needs replacement.
513 def config_fib_many_to_one(self, start_dest_addr, next_hop_addr,
517 :param start_dest_addr:
518 :param next_hop_addr:
520 :return list: added ips with 32 prefix
523 for i in range(count):
524 r = VppIpRoute(self, start_dest_addr % (i + start), 32,
525 [VppRoutePath(next_hop_addr, 0xffffffff)])
530 def unconfig_fib_many_to_one(self, start_dest_addr, next_hop_addr,
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()
541 def create_stream(self, src_if, dst_if, routes, count):
544 for _ in range(count):
545 dst_addr = random.choice(routes).prefix.network_address
546 info = self.create_packet_info(src_if, dst_if)
547 payload = self.info_to_payload(info)
548 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
549 IP(src=src_if.remote_ip4, dst=str(dst_addr)) /
550 UDP(sport=1234, dport=1234) /
553 self.extend_packet(p, random.choice(self.pg_if_packet_sizes))
558 def _find_ip_match(self, find_in, pkt):
560 if self.payload_to_info(p[Raw]) == \
561 self.payload_to_info(pkt[Raw]):
562 if p[IP].src != pkt[IP].src:
564 if p[IP].dst != pkt[IP].dst:
566 if p[UDP].sport != pkt[UDP].sport:
568 if p[UDP].dport != pkt[UDP].dport:
573 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)
581 self.assertListEqual(to_verify, [])
583 def verify_route_dump(self, routes):
585 self.assertTrue(find_route(self,
586 r.prefix.network_address,
589 def verify_not_in_route_dump(self, routes):
591 self.assertFalse(find_route(self,
592 r.prefix.network_address,
598 #. Create and initialize 3 pg interfaces.
599 #. initialize class attributes configured_routes and deleted_routes
600 to store information between tests.
602 super(TestIPv4FibCrud, cls).setUpClass()
605 # create 3 pg interfaces
606 cls.create_pg_interfaces(range(3))
608 cls.interfaces = list(cls.pg_interfaces)
610 # setup all interfaces
611 for i in cls.interfaces:
616 cls.configured_routes = []
617 cls.deleted_routes = []
618 cls.pg_if_packet_sizes = [64, 512, 1518, 9018]
621 super(TestIPv4FibCrud, cls).tearDownClass()
625 def tearDownClass(cls):
626 super(TestIPv4FibCrud, cls).tearDownClass()
629 super(TestIPv4FibCrud, self).setUp()
630 self.reset_packet_infos()
632 self.configured_routes = []
633 self.deleted_routes = []
635 def test_1_add_routes(self):
636 """ Add 1k routes """
638 # add 100 routes check with traffic script.
639 self.configured_routes.extend(self.config_fib_many_to_one(
640 "10.0.0.%d", self.pg0.remote_ip4, 100))
642 self.verify_route_dump(self.configured_routes)
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)
651 self.pg_enable_capture(self.pg_interfaces)
654 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
655 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
657 def test_2_del_routes(self):
658 """ Delete 100 routes
660 - delete 10 routes check with traffic script.
662 # config 1M FIB entries
663 self.configured_routes.extend(self.config_fib_many_to_one(
664 "10.0.0.%d", self.pg0.remote_ip4, 100))
665 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
666 "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
667 for x in self.deleted_routes:
668 self.configured_routes.remove(x)
670 self.verify_route_dump(self.configured_routes)
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)
685 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
686 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
688 def test_3_add_new_routes(self):
691 - re-add 5 routes check with traffic script.
692 - add 100 routes check with traffic script.
694 # config 1M FIB entries
695 self.configured_routes.extend(self.config_fib_many_to_one(
696 "10.0.0.%d", self.pg0.remote_ip4, 100))
697 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
698 "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
699 for x in self.deleted_routes:
700 self.configured_routes.remove(x)
702 tmp = self.config_fib_many_to_one(
703 "10.0.0.%d", self.pg0.remote_ip4, 5, start=10)
704 self.configured_routes.extend(tmp)
706 self.deleted_routes.remove(x)
708 self.configured_routes.extend(self.config_fib_many_to_one(
709 "10.0.1.%d", self.pg0.remote_ip4, 100))
711 self.verify_route_dump(self.configured_routes)
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)
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)
727 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
728 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
730 # delete 5 routes check with traffic script.
731 # add 100 routes check with traffic script.
732 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
733 "10.0.0.%d", self.pg0.remote_ip4, 15))
734 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
735 "10.0.0.%d", self.pg0.remote_ip4, 85))
736 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
737 "10.0.1.%d", self.pg0.remote_ip4, 100))
738 self.verify_not_in_route_dump(self.deleted_routes)
741 class TestIPNull(VppTestCase):
742 """ IPv4 routes via NULL """
746 super(TestIPNull, cls).setUpClass()
749 def tearDownClass(cls):
750 super(TestIPNull, cls).tearDownClass()
753 super(TestIPNull, self).setUp()
755 # create 2 pg interfaces
756 self.create_pg_interfaces(range(2))
758 for i in self.pg_interfaces:
764 super(TestIPNull, self).tearDown()
765 for i in self.pg_interfaces:
769 def test_ip_null(self):
770 """ IP NULL route """
773 # A route via IP NULL that will reply with ICMP unreachables
775 ip_unreach = VppIpRoute(
776 self, "10.0.0.1", 32,
777 [VppRoutePath("0.0.0.0",
779 type=FibPathType.FIB_PATH_TYPE_ICMP_UNREACH)])
780 ip_unreach.add_vpp_config()
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) /
787 self.pg0.add_stream(p_unreach)
788 self.pg_enable_capture(self.pg_interfaces)
791 rx = self.pg0.get_capture(1)
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")
801 # ICMP replies are rate limited. so sit and spin.
806 # A route via IP NULL that will reply with ICMP prohibited
808 ip_prohibit = VppIpRoute(
809 self, "10.0.0.2", 32,
810 [VppRoutePath("0.0.0.0",
812 type=FibPathType.FIB_PATH_TYPE_ICMP_PROHIBIT)])
813 ip_prohibit.add_vpp_config()
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) /
821 self.pg0.add_stream(p_prohibit)
822 self.pg_enable_capture(self.pg_interfaces)
825 rx = self.pg0.get_capture(1)
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")
835 def test_ip_drop(self):
836 """ IP Drop Routes """
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) /
844 r1 = VppIpRoute(self, "1.1.1.0", 24,
845 [VppRoutePath(self.pg1.remote_ip4,
846 self.pg1.sw_if_index)])
849 rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
852 # insert a more specific as a drop
854 r2 = VppIpRoute(self, "1.1.1.1", 32,
855 [VppRoutePath("0.0.0.0",
857 type=FibPathType.FIB_PATH_TYPE_DROP)])
860 self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS, "Drop Route")
861 r2.remove_vpp_config()
862 rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
865 class TestIPDisabled(VppTestCase):
866 """ IPv4 disabled """
870 super(TestIPDisabled, cls).setUpClass()
873 def tearDownClass(cls):
874 super(TestIPDisabled, cls).tearDownClass()
877 super(TestIPDisabled, self).setUp()
879 # create 2 pg interfaces
880 self.create_pg_interfaces(range(2))
884 self.pg0.config_ip4()
885 self.pg0.resolve_arp()
887 # PG 1 is not IP enabled
891 super(TestIPDisabled, self).tearDown()
892 for i in self.pg_interfaces:
896 def test_ip_disabled(self):
899 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
900 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
904 # one accepting interface, pg0, 2 forwarding interfaces
906 route_232_1_1_1 = VppIpMRoute(
910 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
911 [VppMRoutePath(self.pg1.sw_if_index,
912 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
913 VppMRoutePath(self.pg0.sw_if_index,
914 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
915 route_232_1_1_1.add_vpp_config()
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) /
922 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) /
929 # PG1 does not forward IP traffic
931 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
932 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
937 self.pg1.config_ip4()
940 # Now we get packets through
942 self.pg1.add_stream(pu)
943 self.pg_enable_capture(self.pg_interfaces)
945 rx = self.pg0.get_capture(1)
947 self.pg1.add_stream(pm)
948 self.pg_enable_capture(self.pg_interfaces)
950 rx = self.pg0.get_capture(1)
955 self.pg1.unconfig_ip4()
958 # PG1 does not forward IP traffic
960 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
961 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
964 class TestIPSubNets(VppTestCase):
969 super(TestIPSubNets, cls).setUpClass()
972 def tearDownClass(cls):
973 super(TestIPSubNets, cls).tearDownClass()
976 super(TestIPSubNets, self).setUp()
978 # create a 2 pg interfaces
979 self.create_pg_interfaces(range(2))
981 # pg0 we will use to experiment
984 # pg1 is setup normally
986 self.pg1.config_ip4()
987 self.pg1.resolve_arp()
990 super(TestIPSubNets, self).tearDown()
991 for i in self.pg_interfaces:
994 def test_ip_sub_nets(self):
998 # Configure a covering route to forward so we know
999 # when we are dropping
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()
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) /
1012 self.pg1.add_stream(p)
1013 self.pg_enable_capture(self.pg_interfaces)
1015 rx = self.pg1.get_capture(1)
1018 # Configure some non-/24 subnets on an IP interface
1020 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
1022 self.vapi.sw_interface_add_del_address(
1023 sw_if_index=self.pg0.sw_if_index,
1024 prefix="10.10.10.10/16")
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) /
1031 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) /
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")
1040 # remove the sub-net and we are forwarding via the cover again
1041 self.vapi.sw_interface_add_del_address(
1042 sw_if_index=self.pg0.sw_if_index,
1043 prefix="10.10.10.10/16",
1046 self.pg1.add_stream(pn)
1047 self.pg_enable_capture(self.pg_interfaces)
1049 rx = self.pg1.get_capture(1)
1050 self.pg1.add_stream(pb)
1051 self.pg_enable_capture(self.pg_interfaces)
1053 rx = self.pg1.get_capture(1)
1056 # A /31 is a special case where the 'other-side' is an attached host
1057 # packets to that peer generate ARP requests
1059 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
1061 self.vapi.sw_interface_add_del_address(
1062 sw_if_index=self.pg0.sw_if_index,
1063 prefix="10.10.10.10/31")
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) /
1071 self.pg1.add_stream(pn)
1072 self.pg_enable_capture(self.pg_interfaces)
1074 rx = self.pg0.get_capture(1)
1077 # remove the sub-net and we are forwarding via the cover again
1078 self.vapi.sw_interface_add_del_address(
1079 sw_if_index=self.pg0.sw_if_index,
1080 prefix="10.10.10.10/31", is_add=0)
1082 self.pg1.add_stream(pn)
1083 self.pg_enable_capture(self.pg_interfaces)
1085 rx = self.pg1.get_capture(1)
1088 class TestIPLoadBalance(VppTestCase):
1089 """ IPv4 Load-Balancing """
1092 def setUpClass(cls):
1093 super(TestIPLoadBalance, cls).setUpClass()
1096 def tearDownClass(cls):
1097 super(TestIPLoadBalance, cls).tearDownClass()
1100 super(TestIPLoadBalance, self).setUp()
1102 self.create_pg_interfaces(range(5))
1103 mpls_tbl = VppMplsTable(self, 0)
1104 mpls_tbl.add_vpp_config()
1106 for i in self.pg_interfaces:
1113 for i in self.pg_interfaces:
1117 super(TestIPLoadBalance, self).tearDown()
1119 def send_and_expect_load_balancing(self, input, pkts, outputs):
1120 input.add_stream(pkts)
1121 self.pg_enable_capture(self.pg_interfaces)
1125 rx = oo._get_capture(1)
1126 self.assertNotEqual(0, len(rx))
1131 def send_and_expect_one_itf(self, input, pkts, itf):
1132 input.add_stream(pkts)
1133 self.pg_enable_capture(self.pg_interfaces)
1135 rx = itf.get_capture(len(pkts))
1137 def test_ip_load_balance(self):
1138 """ IP Load-Balancing """
1141 # An array of packets that differ only in the destination port
1147 # An array of packets that differ only in the source address
1152 for ii in range(NUM_PKTS):
1153 port_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.1") /
1154 UDP(sport=1234, dport=1234 + ii) /
1156 port_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1157 dst=self.pg0.local_mac) /
1159 port_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1160 dst=self.pg0.local_mac) /
1161 MPLS(label=66, ttl=2) /
1164 src_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.%d" % ii) /
1165 UDP(sport=1234, dport=1234) /
1167 src_ip_pkts.append((Ether(src=self.pg0.remote_mac,
1168 dst=self.pg0.local_mac) /
1170 src_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
1171 dst=self.pg0.local_mac) /
1172 MPLS(label=66, ttl=2) /
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()
1182 binding = VppMplsIpBind(self, 66, "10.0.0.1", 32)
1183 binding.add_vpp_config()
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
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
1191 # be guaranteed. But with 64 different packets we do expect some
1192 # balancing. So instead just ensure there is traffic on each link.
1194 self.send_and_expect_load_balancing(self.pg0, port_ip_pkts,
1195 [self.pg1, self.pg2])
1196 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,
1201 [self.pg1, self.pg2])
1204 # change the flow hash config so it's only IP src,dst
1205 # - now only the stream with differing source address will
1208 self.vapi.set_ip_flow_hash(vrf_id=0, src=1, dst=1, sport=0, dport=0)
1210 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,
1213 [self.pg1, self.pg2])
1215 self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2)
1218 # change the flow hash config back to defaults
1220 self.vapi.set_ip_flow_hash(vrf_id=0, src=1, dst=1, sport=1, dport=1)
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)
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) /
1235 Raw(b'\xa5' * 100)))
1236 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) /
1240 Raw(b'\xa5' * 100)))
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()
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()
1255 # inject the packet on pg0 - expect load-balancing across all 4 paths
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])
1266 # bring down pg1 expect LB to adjust to use only those that are pu
1268 self.pg1.link_down()
1270 rx = self.send_and_expect_load_balancing(self.pg0, src_pkts,
1271 [self.pg2, self.pg3,
1273 self.assertEqual(len(src_pkts), len(rx))
1276 # bring down pg2 expect LB to adjust to use only those that are pu
1278 self.pg2.link_down()
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))
1285 # bring the links back up - expect LB over all again
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))
1296 # The same link-up/down but this time admin state
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))
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))
1313 # Recursive prefixes
1314 # - testing that 2 stages of load-balancing, no choices
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) /
1323 Raw(b'\xa5' * 100)))
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()
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()
1335 # inject the packet on pg0 - rx only on via routes output interface
1337 self.vapi.cli("clear trace")
1338 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3)
1341 # Add a LB route in the presence of a down link - expect no
1342 # packets over the down link
1344 self.pg3.link_down()
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()
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) /
1361 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg4)
1363 # bring the link back up
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))
1371 class TestIPVlan0(VppTestCase):
1375 def setUpClass(cls):
1376 super(TestIPVlan0, cls).setUpClass()
1379 def tearDownClass(cls):
1380 super(TestIPVlan0, cls).tearDownClass()
1383 super(TestIPVlan0, self).setUp()
1385 self.create_pg_interfaces(range(2))
1386 mpls_tbl = VppMplsTable(self, 0)
1387 mpls_tbl.add_vpp_config()
1389 for i in self.pg_interfaces:
1396 for i in self.pg_interfaces:
1400 super(TestIPVlan0, self).tearDown()
1402 def test_ip_vlan_0(self):
1405 pkts = (Ether(src=self.pg0.remote_mac,
1406 dst=self.pg0.local_mac) /
1408 IP(dst=self.pg1.remote_ip4,
1409 src=self.pg0.remote_ip4) /
1410 UDP(sport=1234, dport=1234) /
1411 Raw(b'\xa5' * 100)) * NUM_PKTS
1414 # Expect that packets sent on VLAN-0 are forwarded on the
1417 self.send_and_expect(self.pg0, pkts, self.pg1)
1420 class TestIPPunt(VppTestCase):
1421 """ IPv4 Punt Police/Redirect """
1424 def setUpClass(cls):
1425 super(TestIPPunt, cls).setUpClass()
1428 def tearDownClass(cls):
1429 super(TestIPPunt, cls).tearDownClass()
1432 super(TestIPPunt, self).setUp()
1434 self.create_pg_interfaces(range(4))
1436 for i in self.pg_interfaces:
1442 super(TestIPPunt, self).tearDown()
1443 for i in self.pg_interfaces:
1447 def test_ip_punt(self):
1448 """ IP punt police and redirect """
1450 # 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
1460 'protocol': udp_proto,
1466 self.vapi.set_punt(is_add=1, punt=punt_udp)
1468 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) /
1471 UDP(sport=1234, dport=1234) /
1477 # Configure a punt redirect via pg1.
1479 nh_addr = self.pg1.remote_ip4
1480 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1481 self.pg1.sw_if_index,
1484 self.send_and_expect(self.pg0, pkts, self.pg1)
1489 policer = VppPolicer(self, "ip4-punt", 400, 0, 10, 0, rate_type=1)
1490 policer.add_vpp_config()
1491 self.vapi.ip_punt_police(policer.policer_index)
1493 self.vapi.cli("clear trace")
1494 self.pg0.add_stream(pkts)
1495 self.pg_enable_capture(self.pg_interfaces)
1499 # the number of packet received should be greater than 0,
1500 # but not equal to the number sent, since some were policed
1502 rx = self.pg1._get_capture(1)
1503 self.assertGreater(len(rx), 0)
1504 self.assertLess(len(rx), len(pkts))
1507 # remove the policer. back to full rx
1509 self.vapi.ip_punt_police(policer.policer_index, is_add=0)
1510 policer.remove_vpp_config()
1511 self.send_and_expect(self.pg0, pkts, self.pg1)
1514 # remove the redirect. expect full drop.
1516 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1517 self.pg1.sw_if_index,
1520 self.send_and_assert_no_replies(self.pg0, pkts,
1521 "IP no punt config")
1524 # Add a redirect that is not input port selective
1526 self.vapi.ip_punt_redirect(0xffffffff,
1527 self.pg1.sw_if_index,
1529 self.send_and_expect(self.pg0, pkts, self.pg1)
1531 self.vapi.ip_punt_redirect(0xffffffff,
1532 self.pg1.sw_if_index,
1536 def test_ip_punt_dump(self):
1537 """ IP4 punt redirect dump"""
1540 # Configure a punt redirects
1542 nh_address = self.pg3.remote_ip4
1543 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1544 self.pg3.sw_if_index,
1546 self.vapi.ip_punt_redirect(self.pg1.sw_if_index,
1547 self.pg3.sw_if_index,
1549 self.vapi.ip_punt_redirect(self.pg2.sw_if_index,
1550 self.pg3.sw_if_index,
1554 # Dump pg0 punt redirects
1556 punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index)
1558 self.assertEqual(p.punt.rx_sw_if_index, self.pg0.sw_if_index)
1561 # Dump punt redirects for all interfaces
1563 punts = self.vapi.ip_punt_redirect_dump(0xffffffff)
1564 self.assertEqual(len(punts), 3)
1566 self.assertEqual(p.punt.tx_sw_if_index, self.pg3.sw_if_index)
1567 self.assertNotEqual(punts[1].punt.nh, self.pg3.remote_ip4)
1568 self.assertEqual(str(punts[2].punt.nh), '0.0.0.0')
1571 class TestIPDeag(VppTestCase):
1572 """ IPv4 Deaggregate Routes """
1575 def setUpClass(cls):
1576 super(TestIPDeag, cls).setUpClass()
1579 def tearDownClass(cls):
1580 super(TestIPDeag, cls).tearDownClass()
1583 super(TestIPDeag, self).setUp()
1585 self.create_pg_interfaces(range(3))
1587 for i in self.pg_interfaces:
1593 super(TestIPDeag, self).tearDown()
1594 for i in self.pg_interfaces:
1598 def test_ip_deag(self):
1599 """ IP Deag Routes """
1602 # Create a table to be used for:
1603 # 1 - another destination address lookup
1604 # 2 - a source address lookup
1606 table_dst = VppIpTable(self, 1)
1607 table_src = VppIpTable(self, 2)
1608 table_dst.add_vpp_config()
1609 table_src.add_vpp_config()
1612 # Add a route in the default table to point to a deag/
1613 # second lookup in each of these tables
1615 route_to_dst = VppIpRoute(self, "1.1.1.1", 32,
1616 [VppRoutePath("0.0.0.0",
1619 route_to_src = VppIpRoute(
1620 self, "1.1.1.2", 32,
1621 [VppRoutePath("0.0.0.0",
1624 type=FibPathType.FIB_PATH_TYPE_SOURCE_LOOKUP)])
1625 route_to_dst.add_vpp_config()
1626 route_to_src.add_vpp_config()
1629 # packets to these destination are dropped, since they'll
1630 # hit the respective default routes in the second table
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) /
1637 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) /
1642 pkts_dst = p_dst * 257
1643 pkts_src = p_src * 257
1645 self.send_and_assert_no_replies(self.pg0, pkts_dst,
1647 self.send_and_assert_no_replies(self.pg0, pkts_src,
1651 # add a route in the dst table to forward via pg1
1653 route_in_dst = VppIpRoute(self, "1.1.1.1", 32,
1654 [VppRoutePath(self.pg1.remote_ip4,
1655 self.pg1.sw_if_index)],
1657 route_in_dst.add_vpp_config()
1659 self.send_and_expect(self.pg0, pkts_dst, self.pg1)
1662 # add a route in the src table to forward via pg2
1664 route_in_src = VppIpRoute(self, "2.2.2.2", 32,
1665 [VppRoutePath(self.pg2.remote_ip4,
1666 self.pg2.sw_if_index)],
1668 route_in_src.add_vpp_config()
1669 self.send_and_expect(self.pg0, pkts_src, self.pg2)
1672 # loop in the lookup DP
1674 route_loop = VppIpRoute(self, "2.2.2.3", 32,
1675 [VppRoutePath("0.0.0.0",
1678 route_loop.add_vpp_config()
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) /
1686 self.send_and_assert_no_replies(self.pg0, p_l * 257,
1690 class TestIPInput(VppTestCase):
1691 """ IPv4 Input Exceptions """
1694 def setUpClass(cls):
1695 super(TestIPInput, cls).setUpClass()
1698 def tearDownClass(cls):
1699 super(TestIPInput, cls).tearDownClass()
1702 super(TestIPInput, self).setUp()
1704 self.create_pg_interfaces(range(2))
1706 for i in self.pg_interfaces:
1712 super(TestIPInput, self).tearDown()
1713 for i in self.pg_interfaces:
1717 def test_ip_input(self):
1718 """ IP Input Exceptions """
1720 # i can't find a way in scapy to construct an IP packet
1721 # with a length less than the IP header length
1724 # Packet too short - this is forwarded
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,
1731 UDP(sport=1234, dport=1234) /
1734 rx = self.send_and_expect(self.pg0, p_short * NUM_PKTS, self.pg1)
1737 # Packet too long - this is dropped
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,
1744 UDP(sport=1234, dport=1234) /
1747 rx = self.send_and_assert_no_replies(self.pg0, p_long * NUM_PKTS,
1751 # bad chksum - this is dropped
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,
1758 UDP(sport=1234, dport=1234) /
1761 rx = self.send_and_assert_no_replies(self.pg0, p_chksum * NUM_PKTS,
1765 # bad version - this is dropped
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,
1772 UDP(sport=1234, dport=1234) /
1775 rx = self.send_and_assert_no_replies(self.pg0, p_ver * NUM_PKTS,
1779 # fragment offset 1 - this is dropped
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,
1786 UDP(sport=1234, dport=1234) /
1789 rx = self.send_and_assert_no_replies(self.pg0, p_frag * NUM_PKTS,
1793 # TTL expired packet
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,
1800 UDP(sport=1234, dport=1234) /
1803 rx = self.send_and_expect(self.pg0, p_ttl * NUM_PKTS, self.pg0)
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)
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,
1821 ttl=10, flags='DF') /
1822 UDP(sport=1234, dport=1234) /
1823 Raw(b'\xa5' * 2000))
1825 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1500, 0, 0, 0])
1827 rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg0)
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)
1837 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [2500, 0, 0, 0])
1838 rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg1)
1840 # Reset MTU for subsequent tests
1841 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [9000, 0, 0, 0])
1844 # source address 0.0.0.0 and 25.255.255.255 and for-us
1846 p_s0 = (Ether(src=self.pg0.remote_mac,
1847 dst=self.pg0.local_mac) /
1849 dst=self.pg0.local_ip4) /
1851 Raw(load=b'\x0a' * 18))
1852 rx = self.send_and_assert_no_replies(self.pg0, p_s0 * 17)
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) /
1859 Raw(load=b'\x0a' * 18))
1860 rx = self.send_and_assert_no_replies(self.pg0, p_s0 * 17)
1863 class TestIPDirectedBroadcast(VppTestCase):
1864 """ IPv4 Directed Broadcast """
1867 def setUpClass(cls):
1868 super(TestIPDirectedBroadcast, cls).setUpClass()
1871 def tearDownClass(cls):
1872 super(TestIPDirectedBroadcast, cls).tearDownClass()
1875 super(TestIPDirectedBroadcast, self).setUp()
1877 self.create_pg_interfaces(range(2))
1879 for i in self.pg_interfaces:
1883 super(TestIPDirectedBroadcast, self).tearDown()
1884 for i in self.pg_interfaces:
1887 def test_ip_input(self):
1888 """ IP Directed Broadcast """
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)
1896 p0 = (Ether(src=self.pg1.remote_mac,
1897 dst=self.pg1.local_mac) /
1899 dst=self.pg0._local_ip4_bcast) /
1900 UDP(sport=1234, dport=1234) /
1901 Raw(b'\xa5' * 2000))
1902 p1 = (Ether(src=self.pg0.remote_mac,
1903 dst=self.pg0.local_mac) /
1905 dst=self.pg1._local_ip4_bcast) /
1906 UDP(sport=1234, dport=1234) /
1907 Raw(b'\xa5' * 2000))
1909 self.pg0.config_ip4()
1910 self.pg0.resolve_arp()
1911 self.pg1.config_ip4()
1912 self.pg1.resolve_arp()
1915 # test packet is L2 broadcast
1917 rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0)
1918 self.assertTrue(rx[0][Ether].dst, "ff:ff:ff:ff:ff:ff")
1920 self.send_and_assert_no_replies(self.pg0, p1 * NUM_PKTS,
1921 "directed broadcast disabled")
1924 # toggle directed broadcast on pg0
1926 self.vapi.sw_interface_set_ip_directed_broadcast(
1927 self.pg0.sw_if_index, 0)
1928 self.send_and_assert_no_replies(self.pg1, p0 * NUM_PKTS,
1929 "directed broadcast disabled")
1931 self.vapi.sw_interface_set_ip_directed_broadcast(
1932 self.pg0.sw_if_index, 1)
1933 rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0)
1935 self.pg0.unconfig_ip4()
1936 self.pg1.unconfig_ip4()
1939 class TestIPLPM(VppTestCase):
1940 """ IPv4 longest Prefix Match """
1943 def setUpClass(cls):
1944 super(TestIPLPM, cls).setUpClass()
1947 def tearDownClass(cls):
1948 super(TestIPLPM, cls).tearDownClass()
1951 super(TestIPLPM, self).setUp()
1953 self.create_pg_interfaces(range(4))
1955 for i in self.pg_interfaces:
1961 super(TestIPLPM, self).tearDown()
1962 for i in self.pg_interfaces:
1966 def test_ip_lpm(self):
1967 """ IP longest Prefix Match """
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()
1978 p_8 = (Ether(src=self.pg0.remote_mac,
1979 dst=self.pg0.local_mac) /
1982 UDP(sport=1234, dport=1234) /
1983 Raw(b'\xa5' * 2000))
1984 p_24 = (Ether(src=self.pg0.remote_mac,
1985 dst=self.pg0.local_mac) /
1988 UDP(sport=1234, dport=1234) /
1989 Raw(b'\xa5' * 2000))
1991 self.logger.info(self.vapi.cli("sh ip fib mtrie"))
1992 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)
1996 class TestIPv4Frag(VppTestCase):
1997 """ IPv4 fragmentation """
2000 def setUpClass(cls):
2001 super(TestIPv4Frag, cls).setUpClass()
2003 cls.create_pg_interfaces([0, 1])
2004 cls.src_if = cls.pg0
2005 cls.dst_if = cls.pg1
2007 # setup all interfaces
2008 for i in cls.pg_interfaces:
2014 def tearDownClass(cls):
2015 super(TestIPv4Frag, cls).tearDownClass()
2017 def test_frag_large_packets(self):
2018 """ Fragmentation of large packets """
2020 self.vapi.cli("adjacency counters enable")
2022 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
2028 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()
2033 # 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,
2038 self.pg_enable_capture()
2039 self.src_if.add_stream(p)
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)
2046 # we should show 3 packets thru the neighbor
2047 self.assertEqual(3, nbr.get_stats()['packets'])
2049 # Assume VPP sends the fragments in order
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")
2060 class TestIPReplace(VppTestCase):
2061 """ IPv4 Table Replace """
2064 def setUpClass(cls):
2065 super(TestIPReplace, cls).setUpClass()
2068 def tearDownClass(cls):
2069 super(TestIPReplace, cls).tearDownClass()
2072 super(TestIPReplace, self).setUp()
2074 self.create_pg_interfaces(range(4))
2079 for i in self.pg_interfaces:
2083 i.generate_remote_hosts(2)
2084 self.tables.append(VppIpTable(self, table_id).add_vpp_config())
2088 super(TestIPReplace, self).tearDown()
2089 for i in self.pg_interfaces:
2093 def test_replace(self):
2094 """ IP Table Replace """
2096 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
2097 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
2099 links = [self.pg0, self.pg1, self.pg2, self.pg3]
2100 routes = [[], [], [], []]
2102 # load up the tables with some routes
2103 for ii, t in enumerate(self.tables):
2104 for jj in range(N_ROUTES):
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(
2114 "239.0.0.%d" % jj, 32,
2115 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
2116 [VppMRoutePath(self.pg0.sw_if_index,
2117 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
2118 VppMRoutePath(self.pg1.sw_if_index,
2119 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
2120 VppMRoutePath(self.pg2.sw_if_index,
2121 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
2122 VppMRoutePath(self.pg3.sw_if_index,
2123 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)],
2124 table_id=t.table_id).add_vpp_config()
2125 routes[ii].append({'uni': uni,
2129 # replace the tables a few times
2132 # replace_begin each table
2133 for t in self.tables:
2136 # all the routes are still there
2137 for ii, t in enumerate(self.tables):
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))
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()
2150 # signal each table replace_end
2151 for t in self.tables:
2154 # we should find the even routes, but not the odd
2155 for ii, t in enumerate(self.tables):
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))
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()
2175 # all the routes are still there
2176 for ii, t in enumerate(self.tables):
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))
2184 # finally flush the tables for good measure
2186 for t in self.tables:
2188 self.assertEqual(len(t.dump()), 5)
2189 self.assertEqual(len(t.mdump()), 3)
2192 class TestIPCover(VppTestCase):
2193 """ IPv4 Table Cover """
2196 def setUpClass(cls):
2197 super(TestIPCover, cls).setUpClass()
2200 def tearDownClass(cls):
2201 super(TestIPCover, cls).tearDownClass()
2204 super(TestIPCover, self).setUp()
2206 self.create_pg_interfaces(range(4))
2211 for i in self.pg_interfaces:
2215 i.generate_remote_hosts(2)
2216 self.tables.append(VppIpTable(self, table_id).add_vpp_config())
2220 super(TestIPCover, self).tearDown()
2221 for i in self.pg_interfaces:
2225 def test_cover(self):
2226 """ IP Table Cover """
2228 # add a loop back with a /32 prefix
2229 lo = VppLoInterface(self)
2231 a = VppIpInterfaceAddress(self, lo, "127.0.0.1", 32).add_vpp_config()
2233 # add a neighbour that matches the loopback's /32
2234 nbr = VppNeighbor(self,
2237 "127.0.0.1").add_vpp_config()
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",
2243 register=False).add_vpp_config()
2245 # add/remove/add a longer mask cover
2246 r = VppIpRoute(self, "127.0.0.0", 8,
2247 [VppRoutePath("127.0.0.1",
2248 lo.sw_if_index)]).add_vpp_config()
2249 r.remove_vpp_config()
2252 # remove the default route
2253 r.remove_vpp_config()
2256 class TestIP4Replace(VppTestCase):
2257 """ IPv4 Interface Address Replace """
2260 def setUpClass(cls):
2261 super(TestIP4Replace, cls).setUpClass()
2264 def tearDownClass(cls):
2265 super(TestIP4Replace, cls).tearDownClass()
2268 super(TestIP4Replace, self).setUp()
2270 self.create_pg_interfaces(range(4))
2272 for i in self.pg_interfaces:
2276 super(TestIP4Replace, self).tearDown()
2277 for i in self.pg_interfaces:
2280 def get_n_pfxs(self, intf):
2281 return len(self.vapi.ip_address_dump(intf.sw_if_index))
2283 def test_replace(self):
2284 """ IP interface address replace """
2286 intf_pfxs = [[], [], [], []]
2288 # add prefixes to each of the interfaces
2289 for i in range(len(self.pg_interfaces)):
2290 intf = self.pg_interfaces[i]
2293 addr = "172.16.%d.1" % intf.sw_if_index
2294 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2295 intf_pfxs[i].append(a)
2297 # 172.16.x.2/24 - a different address in the same subnet as above
2298 addr = "172.16.%d.2" % intf.sw_if_index
2299 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2300 intf_pfxs[i].append(a)
2302 # 172.15.x.2/24 - a different address and subnet
2303 addr = "172.15.%d.2" % intf.sw_if_index
2304 a = VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2305 intf_pfxs[i].append(a)
2307 # a dump should n_address in it
2308 for intf in self.pg_interfaces:
2309 self.assertEqual(self.get_n_pfxs(intf), 3)
2312 # remove all the address thru a replace
2314 self.vapi.sw_interface_address_replace_begin()
2315 self.vapi.sw_interface_address_replace_end()
2316 for intf in self.pg_interfaces:
2317 self.assertEqual(self.get_n_pfxs(intf), 0)
2320 # add all the interface addresses back
2325 for intf in self.pg_interfaces:
2326 self.assertEqual(self.get_n_pfxs(intf), 3)
2329 # replace again, but this time update/re-add the address on the first
2332 self.vapi.sw_interface_address_replace_begin()
2334 for p in intf_pfxs[:2]:
2338 self.vapi.sw_interface_address_replace_end()
2340 # on the first two the address still exist,
2341 # on the other two they do not
2342 for intf in self.pg_interfaces[:2]:
2343 self.assertEqual(self.get_n_pfxs(intf), 3)
2344 for p in intf_pfxs[:2]:
2346 self.assertTrue(v.query_vpp_config())
2347 for intf in self.pg_interfaces[2:]:
2348 self.assertEqual(self.get_n_pfxs(intf), 0)
2351 # add all the interface addresses back on the last two
2353 for p in intf_pfxs[2:]:
2356 for intf in self.pg_interfaces:
2357 self.assertEqual(self.get_n_pfxs(intf), 3)
2360 # replace again, this time add different prefixes on all the interfaces
2362 self.vapi.sw_interface_address_replace_begin()
2365 for intf in self.pg_interfaces:
2367 addr = "172.18.%d.1" % intf.sw_if_index
2368 pfxs.append(VppIpInterfaceAddress(self, intf, addr,
2369 24).add_vpp_config())
2371 self.vapi.sw_interface_address_replace_end()
2373 # only .18 should exist on each interface
2374 for intf in self.pg_interfaces:
2375 self.assertEqual(self.get_n_pfxs(intf), 1)
2377 self.assertTrue(pfx.query_vpp_config())
2382 self.vapi.sw_interface_address_replace_begin()
2383 self.vapi.sw_interface_address_replace_end()
2384 for intf in self.pg_interfaces:
2385 self.assertEqual(self.get_n_pfxs(intf), 0)
2388 # add prefixes to each interface. post-begin add the prefix from
2389 # interface X onto interface Y. this would normally be an error
2390 # since it would generate a 'duplicate address' warning. but in
2391 # this case, since what is newly downloaded is sane, it's ok
2393 for intf in self.pg_interfaces:
2395 addr = "172.18.%d.1" % intf.sw_if_index
2396 VppIpInterfaceAddress(self, intf, addr, 24).add_vpp_config()
2398 self.vapi.sw_interface_address_replace_begin()
2401 for intf in self.pg_interfaces:
2403 addr = "172.18.%d.1" % (intf.sw_if_index + 1)
2404 pfxs.append(VppIpInterfaceAddress(self, intf,
2405 addr, 24).add_vpp_config())
2407 self.vapi.sw_interface_address_replace_end()
2409 self.logger.info(self.vapi.cli("sh int addr"))
2411 for intf in self.pg_interfaces:
2412 self.assertEqual(self.get_n_pfxs(intf), 1)
2414 self.assertTrue(pfx.query_vpp_config())
2417 if __name__ == '__main__':
2418 unittest.main(testRunner=VppTestRunner)