aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_ip4.py41
-rw-r--r--test/test_ip6.py54
-rw-r--r--test/vpp_papi_provider.py17
3 files changed, 89 insertions, 23 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 9f2c925ec4d..9ec7f4e8129 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -8,7 +8,7 @@ from framework import VppTestCase, VppTestRunner
from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
- VppMplsTable, VppIpTable
+ VppMplsTable, VppIpTable, VppIpAddress
from scapy.packet import Raw
from scapy.layers.l2 import Ether, Dot1Q, ARP
@@ -1094,7 +1094,7 @@ class TestIPPunt(VppTestCase):
def setUp(self):
super(TestIPPunt, self).setUp()
- self.create_pg_interfaces(range(2))
+ self.create_pg_interfaces(range(4))
for i in self.pg_interfaces:
i.admin_up()
@@ -1121,8 +1121,7 @@ class TestIPPunt(VppTestCase):
#
# Configure a punt redirect via pg1.
#
- nh_addr = socket.inet_pton(socket.AF_INET,
- self.pg1.remote_ip4)
+ nh_addr = VppIpAddress(self.pg1.remote_ip4).encode()
self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
self.pg1.sw_if_index,
nh_addr)
@@ -1180,6 +1179,40 @@ class TestIPPunt(VppTestCase):
nh_addr,
is_add=0)
+ def test_ip_punt_dump(self):
+ """ IP4 punt redirect dump"""
+
+ #
+ # Configure a punt redirects
+ #
+ nh_address = VppIpAddress(self.pg3.remote_ip4).encode()
+ self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
+ self.pg3.sw_if_index,
+ nh_address)
+ self.vapi.ip_punt_redirect(self.pg1.sw_if_index,
+ self.pg3.sw_if_index,
+ nh_address)
+ self.vapi.ip_punt_redirect(self.pg2.sw_if_index,
+ self.pg3.sw_if_index,
+ VppIpAddress('0.0.0.0').encode())
+
+ #
+ # Dump pg0 punt redirects
+ #
+ punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index)
+ 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)
+ 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.ip4, self.pg3.remote_ip4)
+ self.assertEqual(punts[2].punt.nh.un.ip4.address, '\x00'*4)
+
class TestIPDeag(VppTestCase):
""" IPv4 Deaggregate Routes """
diff --git a/test/test_ip6.py b/test/test_ip6.py
index 33194ebc5b2..1d7fa766d14 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -10,7 +10,7 @@ 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, VppMplsTable, VppIpTable
+ VppMplsRoute, VppMplsTable, VppIpTable, VppIpAddress
from vpp_neighbor import find_nbr, VppNeighbor
from scapy.packet import Raw
@@ -1867,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()
@@ -1894,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)
@@ -1937,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")
@@ -1947,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):
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 966d9198fa0..662732ffb30 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -3168,15 +3168,18 @@ class VppPapiProvider(object):
def ip_punt_redirect(self,
rx_sw_if_index,
tx_sw_if_index,
- nh,
- is_ip6=0,
+ address,
is_add=1):
return self.api(self.papi.ip_punt_redirect,
- {'rx_sw_if_index': rx_sw_if_index,
- 'tx_sw_if_index': tx_sw_if_index,
- 'nh': nh,
- 'is_add': is_add,
- 'is_ip6': is_ip6})
+ {'punt': {'rx_sw_if_index': rx_sw_if_index,
+ 'tx_sw_if_index': tx_sw_if_index,
+ 'nh': address},
+ 'is_add': is_add})
+
+ def ip_punt_redirect_dump(self, sw_if_index, is_ipv6=0):
+ return self.api(self.papi.ip_punt_redirect_dump,
+ {'sw_if_index': sw_if_index,
+ 'is_ipv6': is_ipv6})
def bier_table_add_del(self,
bti,