X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ip6.py;h=1d7fa766d148fb08a616685f3ab84cb3464142d2;hb=609e1210c;hp=9a0c752ebfd0ae12638f807bfef86df8a182bca2;hpb=ce9e0b4d48705d693f4e03093e3f506bdecaf141;p=vpp.git diff --git a/test/test_ip6.py b/test/test_ip6.py index 9a0c752ebfd..1d7fa766d14 100644 --- a/test/test_ip6.py +++ b/test/test_ip6.py @@ -7,9 +7,10 @@ from framework import VppTestCase, VppTestRunner from util import ppp, ip6_normalize from vpp_sub_interface import VppSubInterface, VppDot1QSubint from vpp_pg_interface import is_ipv6_misc +from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, VppIpMRoute, \ VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \ - VppMplsRoute, DpoProto, VppMplsTable, VppIpTable + VppMplsRoute, VppMplsTable, VppIpTable, VppIpAddress from vpp_neighbor import find_nbr, VppNeighbor from scapy.packet import Raw @@ -1866,7 +1867,7 @@ class TestIP6Punt(VppTestCase): def setUp(self): super(TestIP6Punt, self).setUp() - self.create_pg_interfaces(range(2)) + self.create_pg_interfaces(range(4)) for i in self.pg_interfaces: i.admin_up() @@ -1893,12 +1894,10 @@ class TestIP6Punt(VppTestCase): # # Configure a punt redirect via pg1. # - nh_addr = inet_pton(AF_INET6, - self.pg1.remote_ip6) + nh_addr = VppIpAddress(self.pg1.remote_ip6).encode() self.vapi.ip_punt_redirect(self.pg0.sw_if_index, self.pg1.sw_if_index, - nh_addr, - is_ip6=1) + nh_addr) self.send_and_expect(self.pg0, pkts, self.pg1) @@ -1919,8 +1918,8 @@ class TestIP6Punt(VppTestCase): # but not equal to the number sent, since some were policed # rx = self.pg1._get_capture(1) - self.assertTrue(len(rx) > 0) - self.assertTrue(len(rx) < len(pkts)) + self.assertGreater(len(rx), 0) + self.assertLess(len(rx), len(pkts)) # # remove the poilcer. back to full rx @@ -1936,8 +1935,7 @@ class TestIP6Punt(VppTestCase): self.vapi.ip_punt_redirect(self.pg0.sw_if_index, self.pg1.sw_if_index, nh_addr, - is_add=0, - is_ip6=1) + is_add=0) self.send_and_assert_no_replies(self.pg0, pkts, "IP no punt config") @@ -1946,15 +1944,48 @@ class TestIP6Punt(VppTestCase): # self.vapi.ip_punt_redirect(0xffffffff, self.pg1.sw_if_index, - nh_addr, - is_ip6=1) + nh_addr) self.send_and_expect(self.pg0, pkts, self.pg1) self.vapi.ip_punt_redirect(0xffffffff, self.pg1.sw_if_index, nh_addr, - is_add=0, - is_ip6=1) + is_add=0) + + def test_ip_punt_dump(self): + """ IP6 punt redirect dump""" + + # + # Configure a punt redirects + # + nh_addr = VppIpAddress(self.pg3.remote_ip6).encode() + self.vapi.ip_punt_redirect(self.pg0.sw_if_index, + self.pg3.sw_if_index, + nh_addr) + self.vapi.ip_punt_redirect(self.pg1.sw_if_index, + self.pg3.sw_if_index, + nh_addr) + self.vapi.ip_punt_redirect(self.pg2.sw_if_index, + self.pg3.sw_if_index, + VppIpAddress('0::0').encode()) + + # + # Dump pg0 punt redirects + # + punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index, + is_ipv6=1) + for p in punts: + self.assertEqual(p.punt.rx_sw_if_index, self.pg0.sw_if_index) + + # + # Dump punt redirects for all interfaces + # + punts = self.vapi.ip_punt_redirect_dump(0xffffffff, is_ipv6=1) + self.assertEqual(len(punts), 3) + for p in punts: + self.assertEqual(p.punt.tx_sw_if_index, self.pg3.sw_if_index) + self.assertNotEqual(punts[1].punt.nh.un.ip6, self.pg3.remote_ip6) + self.assertEqual(punts[2].punt.nh.un.ip6.address, '\x00'*16) class TestIPDeag(VppTestCase):