diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_gre.py | 36 | ||||
-rw-r--r-- | test/test_ip_mcast.py | 155 | ||||
-rw-r--r-- | test/test_mfib.py | 23 | ||||
-rw-r--r-- | test/test_mpls.py | 141 | ||||
-rw-r--r-- | test/vpp_ip_route.py | 116 | ||||
-rw-r--r-- | test/vpp_papi_provider.py | 6 |
6 files changed, 280 insertions, 197 deletions
diff --git a/test/test_gre.py b/test/test_gre.py index b13130447e3..89f39e4eb11 100644 --- a/test/test_gre.py +++ b/test/test_gre.py @@ -6,7 +6,7 @@ from logging import * from framework import VppTestCase, VppTestRunner from vpp_sub_interface import VppDot1QSubint from vpp_gre_interface import VppGreInterface -from vpp_ip_route import IpRoute, RoutePath +from vpp_ip_route import VppIpRoute, VppRoutePath from vpp_papi_provider import L2_VTR_OP from scapy.packet import Raw @@ -298,8 +298,9 @@ class TestGRE(VppTestCase): gre_if.admin_up() gre_if.config_ip4() - route_via_tun = IpRoute(self, "4.4.4.4", 32, - [RoutePath("0.0.0.0", gre_if.sw_if_index)]) + route_via_tun = VppIpRoute(self, "4.4.4.4", 32, + [VppRoutePath("0.0.0.0", + gre_if.sw_if_index)]) route_via_tun.add_vpp_config() @@ -321,9 +322,9 @@ class TestGRE(VppTestCase): # # Add a route that resolves the tunnel's destination # - route_tun_dst = IpRoute(self, "1.1.1.2", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index)]) + route_tun_dst = VppIpRoute(self, "1.1.1.2", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index)]) route_tun_dst.add_vpp_config() # @@ -453,17 +454,18 @@ class TestGRE(VppTestCase): # # Add a route via the tunnel - in the overlay # - route_via_tun = IpRoute(self, "9.9.9.9", 32, - [RoutePath("0.0.0.0", gre_if.sw_if_index)]) + route_via_tun = VppIpRoute(self, "9.9.9.9", 32, + [VppRoutePath("0.0.0.0", + gre_if.sw_if_index)]) route_via_tun.add_vpp_config() # # Add a route that resolves the tunnel's destination - in the # underlay table # - route_tun_dst = IpRoute(self, "2.2.2.2", 32, table_id=1, - paths=[RoutePath(self.pg1.remote_ip4, - self.pg1.sw_if_index)]) + route_tun_dst = VppIpRoute(self, "2.2.2.2", 32, table_id=1, + paths=[VppRoutePath(self.pg1.remote_ip4, + self.pg1.sw_if_index)]) route_tun_dst.add_vpp_config() # @@ -514,12 +516,12 @@ class TestGRE(VppTestCase): # # Add routes to resolve the tunnel destinations # - route_tun1_dst = IpRoute(self, "2.2.2.2", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index)]) - route_tun2_dst = IpRoute(self, "2.2.2.3", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index)]) + route_tun1_dst = VppIpRoute(self, "2.2.2.2", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index)]) + route_tun2_dst = VppIpRoute(self, "2.2.2.3", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index)]) route_tun1_dst.add_vpp_config() route_tun2_dst.add_vpp_config() diff --git a/test/test_ip_mcast.py b/test/test_ip_mcast.py index 2e0db430fa7..34ee417a8e5 100644 --- a/test/test_ip_mcast.py +++ b/test/test_ip_mcast.py @@ -4,7 +4,7 @@ import unittest from framework import VppTestCase, VppTestRunner from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint -from vpp_ip_route import IpMRoute, MRoutePath, MFibSignal +from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal from scapy.packet import Raw from scapy.layers.l2 import Ether @@ -38,6 +38,21 @@ class MRouteEntryFlags: N_PKTS_IN_STREAM = 90 +class TestMFIB(VppTestCase): + """ MFIB Test Case """ + + def setUp(self): + super(TestMFIB, self).setUp() + + def test_mfib(self): + """ MFIB Unit Tests """ + error = self.vapi.cli("test mfib") + + if error: + self.logger.critical(error) + self.assertEqual(error.find("Failed"), -1) + + class TestIPMcast(VppTestCase): """ IP Multicast Test Case """ @@ -163,51 +178,51 @@ class TestIPMcast(VppTestCase): # A (*,G). # one accepting interface, pg0, 3 forwarding interfaces # - route_232_1_1_1 = IpMRoute( + route_232_1_1_1 = VppIpMRoute( self, "0.0.0.0", "232.1.1.1", 32, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg2.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg3.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg2.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg3.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_232_1_1_1.add_vpp_config() # # An (S,G). # one accepting interface, pg0, 2 forwarding interfaces # - route_1_1_1_1_232_1_1_1 = IpMRoute( + route_1_1_1_1_232_1_1_1 = VppIpMRoute( self, "1.1.1.1", "232.1.1.1", 64, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg2.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg2.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_1_1_1_1_232_1_1_1.add_vpp_config() # # An (*,G/m). # one accepting interface, pg0, 1 forwarding interfaces # - route_232 = IpMRoute( + route_232 = VppIpMRoute( self, "0.0.0.0", "232.0.0.0", 8, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_232.add_vpp_config() # @@ -296,19 +311,19 @@ class TestIPMcast(VppTestCase): # A (*,G). # one accepting interface, pg0, 3 forwarding interfaces # - route_ff01_1 = IpMRoute( + route_ff01_1 = VppIpMRoute( self, "::", "ff01::1", 128, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg2.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg3.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg2.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg3.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], is_ip6=1) route_ff01_1.add_vpp_config() @@ -316,17 +331,17 @@ class TestIPMcast(VppTestCase): # An (S,G). # one accepting interface, pg0, 2 forwarding interfaces # - route_2001_ff01_1 = IpMRoute( + route_2001_ff01_1 = VppIpMRoute( self, "2001::1", "ff01::1", 256, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), - MRoutePath(self.pg2.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD), + VppMRoutePath(self.pg2.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], is_ip6=1) route_2001_ff01_1.add_vpp_config() @@ -334,15 +349,15 @@ class TestIPMcast(VppTestCase): # An (*,G/m). # one accepting interface, pg0, 1 forwarding interface # - route_ff01 = IpMRoute( + route_ff01 = VppIpMRoute( self, "::", "ff01::", 16, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)], is_ip6=1) route_ff01.add_vpp_config() @@ -432,15 +447,15 @@ class TestIPMcast(VppTestCase): # A (*,G). # one accepting interface, pg0, 1 forwarding interfaces # - route_232_1_1_1 = IpMRoute( + route_232_1_1_1 = VppIpMRoute( self, "0.0.0.0", "232.1.1.1", 32, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_232_1_1_1.add_vpp_config() route_232_1_1_1.update_entry_flags( @@ -454,10 +469,10 @@ class TestIPMcast(VppTestCase): # # Constrct a representation of the signal we expect on pg0 # - signal_232_1_1_1_itf_0 = MFibSignal(self, - route_232_1_1_1, - self.pg0.sw_if_index, - tx[0]) + signal_232_1_1_1_itf_0 = VppMFibSignal(self, + route_232_1_1_1, + self.pg0.sw_if_index, + tx[0]) # # read the only expected signal @@ -482,15 +497,15 @@ class TestIPMcast(VppTestCase): # A Second entry with connected check # one accepting interface, pg0, 1 forwarding interfaces # - route_232_1_1_2 = IpMRoute( + route_232_1_1_2 = VppIpMRoute( self, "0.0.0.0", "232.1.1.2", 32, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_232_1_1_2.add_vpp_config() route_232_1_1_2.update_entry_flags( @@ -499,10 +514,10 @@ class TestIPMcast(VppTestCase): # # Send traffic to both entries. One read should net us two signals # - signal_232_1_1_2_itf_0 = MFibSignal(self, - route_232_1_1_2, - self.pg0.sw_if_index, - tx[0]) + signal_232_1_1_2_itf_0 = VppMFibSignal(self, + route_232_1_1_2, + self.pg0.sw_if_index, + tx[0]) tx = self._mcast_connected_send_stream("232.1.1.1") tx2 = self._mcast_connected_send_stream("232.1.1.2") @@ -526,15 +541,15 @@ class TestIPMcast(VppTestCase): # A (*,G). # one accepting interface, pg0, 1 forwarding interfaces # - route_232_1_1_1 = IpMRoute( + route_232_1_1_1 = VppIpMRoute( self, "0.0.0.0", "232.1.1.1", 32, MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE, - [MRoutePath(self.pg0.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), - MRoutePath(self.pg1.sw_if_index, - MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) + [VppMRoutePath(self.pg0.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT), + VppMRoutePath(self.pg1.sw_if_index, + MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)]) route_232_1_1_1.add_vpp_config() route_232_1_1_1.update_entry_flags( @@ -548,10 +563,10 @@ class TestIPMcast(VppTestCase): # # Constrct a representation of the signal we expect on pg0 # - signal_232_1_1_1_itf_0 = MFibSignal(self, - route_232_1_1_1, - self.pg0.sw_if_index, - tx[0]) + signal_232_1_1_1_itf_0 = VppMFibSignal(self, + route_232_1_1_1, + self.pg0.sw_if_index, + tx[0]) # # read the only expected signal diff --git a/test/test_mfib.py b/test/test_mfib.py deleted file mode 100644 index 4d0d2a3f074..00000000000 --- a/test/test_mfib.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -import unittest - -from framework import VppTestCase, VppTestRunner - - -class TestMFIB(VppTestCase): - """ MFIB Test Case """ - - def setUp(self): - super(TestMFIB, self).setUp() - - def test_mfib(self): - """ MFIB Unit Tests """ - error = self.vapi.cli("test mfib") - - if error: - self.logger.critical(error) - self.assertEqual(error.find("Failed"), -1) - -if __name__ == '__main__': - unittest.main(testRunner=VppTestRunner) diff --git a/test/test_mpls.py b/test/test_mpls.py index 806e69dc2fa..41d9426b508 100644 --- a/test/test_mpls.py +++ b/test/test_mpls.py @@ -4,7 +4,8 @@ import unittest import socket from framework import VppTestCase, VppTestRunner -from vpp_ip_route import IpRoute, RoutePath, MplsRoute, MplsIpBind +from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute, \ + VppMplsIpBind from scapy.packet import Raw from scapy.layers.l2 import Ether @@ -258,10 +259,10 @@ class TestMPLS(VppTestCase): # # A simple MPLS xconnect - eos label in label out # - route_32_eos = MplsRoute(self, 32, 1, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[33])]) + route_32_eos = VppMplsRoute(self, 32, 1, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[33])]) route_32_eos.add_vpp_config() # @@ -281,10 +282,10 @@ class TestMPLS(VppTestCase): # # A simple MPLS xconnect - non-eos label in label out # - route_32_neos = MplsRoute(self, 32, 0, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[33])]) + route_32_neos = VppMplsRoute(self, 32, 0, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[33])]) route_32_neos.add_vpp_config() # @@ -304,10 +305,10 @@ class TestMPLS(VppTestCase): # # An MPLS xconnect - EOS label in IP out # - route_33_eos = MplsRoute(self, 33, 1, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[])]) + route_33_eos = VppMplsRoute(self, 33, 1, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[])]) route_33_eos.add_vpp_config() self.vapi.cli("clear trace") @@ -324,10 +325,10 @@ class TestMPLS(VppTestCase): # An MPLS xconnect - non-EOS label in IP out - an invalid configuration # so this traffic should be dropped. # - route_33_neos = MplsRoute(self, 33, 0, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[])]) + route_33_neos = VppMplsRoute(self, 33, 0, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[])]) route_33_neos.add_vpp_config() self.vapi.cli("clear trace") @@ -342,11 +343,11 @@ class TestMPLS(VppTestCase): # # A recursive EOS x-connect, which resolves through another x-connect # - route_34_eos = MplsRoute(self, 34, 1, - [RoutePath("0.0.0.0", - 0xffffffff, - nh_via_label=32, - labels=[44, 45])]) + route_34_eos = VppMplsRoute(self, 34, 1, + [VppRoutePath("0.0.0.0", + 0xffffffff, + nh_via_label=32, + labels=[44, 45])]) route_34_eos.add_vpp_config() tx = self.create_stream_labelled_ip4(self.pg0, [34]) @@ -362,11 +363,11 @@ class TestMPLS(VppTestCase): # A recursive non-EOS x-connect, which resolves through another # x-connect # - route_34_neos = MplsRoute(self, 34, 0, - [RoutePath("0.0.0.0", - 0xffffffff, - nh_via_label=32, - labels=[44, 46])]) + route_34_neos = VppMplsRoute(self, 34, 0, + [VppRoutePath("0.0.0.0", + 0xffffffff, + nh_via_label=32, + labels=[44, 46])]) route_34_neos.add_vpp_config() self.vapi.cli("clear trace") @@ -384,11 +385,11 @@ class TestMPLS(VppTestCase): # an recursive IP route that resolves through the recursive non-eos # x-connect # - ip_10_0_0_1 = IpRoute(self, "10.0.0.1", 32, - [RoutePath("0.0.0.0", - 0xffffffff, - nh_via_label=34, - labels=[55])]) + ip_10_0_0_1 = VppIpRoute(self, "10.0.0.1", 32, + [VppRoutePath("0.0.0.0", + 0xffffffff, + nh_via_label=34, + labels=[55])]) ip_10_0_0_1.add_vpp_config() self.vapi.cli("clear trace") @@ -415,14 +416,14 @@ class TestMPLS(VppTestCase): # # Add a non-recursive route with a single out label # - route_10_0_0_1 = IpRoute(self, "10.0.0.1", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[45])]) + route_10_0_0_1 = VppIpRoute(self, "10.0.0.1", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[45])]) route_10_0_0_1.add_vpp_config() # bind a local label to the route - binding = MplsIpBind(self, 44, "10.0.0.1", 32) + binding = VppMplsIpBind(self, 44, "10.0.0.1", 32) binding.add_vpp_config() # non-EOS stream @@ -470,10 +471,10 @@ class TestMPLS(VppTestCase): # # Add a non-recursive route with a single out label # - route_10_0_0_1 = IpRoute(self, "10.0.0.1", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[32])]) + route_10_0_0_1 = VppIpRoute(self, "10.0.0.1", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[32])]) route_10_0_0_1.add_vpp_config() # @@ -493,10 +494,10 @@ class TestMPLS(VppTestCase): # # Add a non-recursive route with a 3 out labels # - route_10_0_0_2 = IpRoute(self, "10.0.0.2", 32, - [RoutePath(self.pg0.remote_ip4, - self.pg0.sw_if_index, - labels=[32, 33, 34])]) + route_10_0_0_2 = VppIpRoute(self, "10.0.0.2", 32, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[32, 33, 34])]) route_10_0_0_2.add_vpp_config() # @@ -516,10 +517,10 @@ class TestMPLS(VppTestCase): # # add a recursive path, with output label, via the 1 label route # - route_11_0_0_1 = IpRoute(self, "11.0.0.1", 32, - [RoutePath("10.0.0.1", - 0xffffffff, - labels=[44])]) + route_11_0_0_1 = VppIpRoute(self, "11.0.0.1", 32, + [VppRoutePath("10.0.0.1", + 0xffffffff, + labels=[44])]) route_11_0_0_1.add_vpp_config() # @@ -539,10 +540,10 @@ class TestMPLS(VppTestCase): # # add a recursive path, with 2 labels, via the 3 label route # - route_11_0_0_2 = IpRoute(self, "11.0.0.2", 32, - [RoutePath("10.0.0.2", - 0xffffffff, - labels=[44, 45])]) + route_11_0_0_2 = VppIpRoute(self, "11.0.0.2", 32, + [VppRoutePath("10.0.0.2", + 0xffffffff, + labels=[44, 45])]) route_11_0_0_2.add_vpp_config() # @@ -590,20 +591,10 @@ class TestMPLS(VppTestCase): # # add an unlabelled route through the new tunnel # - dest_addr = socket.inet_pton(socket.AF_INET, "10.0.0.3") - nh_addr = socket.inet_pton(socket.AF_INET, "0.0.0.0") - dest_addr_len = 32 - - self.vapi.ip_add_del_route( - dest_addr, - dest_addr_len, - nh_addr, # all zeros next-hop - tunnel is p2p - reply.sw_if_index, # sw_if_index of the new tunnel - 0, # table-id - 0, # next-hop-table-id - 1, # next-hop-weight - 0, # num-out-labels, - []) # out-label + route_10_0_0_3 = VppIpRoute(self, "10.0.0.3", 32, + [VppRoutePath("0.0.0.0", + reply.sw_if_index)]) + route_10_0_0_3.add_vpp_config() self.vapi.cli("clear trace") tx = self.create_stream_ip4(self.pg0, "10.0.0.3") @@ -696,10 +687,10 @@ class TestMPLS(VppTestCase): # # A de-agg route - next-hop lookup in default table # - route_34_eos = MplsRoute(self, 34, 1, - [RoutePath("0.0.0.0", - 0xffffffff, - nh_table_id=0)]) + route_34_eos = VppMplsRoute(self, 34, 1, + [VppRoutePath("0.0.0.0", + 0xffffffff, + nh_table_id=0)]) route_34_eos.add_vpp_config() # @@ -720,10 +711,10 @@ class TestMPLS(VppTestCase): # # A de-agg route - next-hop lookup in non-default table # - route_35_eos = MplsRoute(self, 35, 1, - [RoutePath("0.0.0.0", - 0xffffffff, - nh_table_id=1)]) + route_35_eos = VppMplsRoute(self, 35, 1, + [VppRoutePath("0.0.0.0", + 0xffffffff, + nh_table_id=1)]) route_35_eos.add_vpp_config() # diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index 1804fbbdc41..f758c067f31 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -5,13 +5,14 @@ """ import socket +from vpp_object import * # from vnet/vnet/mpls/mpls_types.h MPLS_IETF_MAX_LABEL = 0xfffff MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1 -class RoutePath(object): +class VppRoutePath(object): def __init__( self, @@ -31,15 +32,15 @@ class RoutePath(object): self.nh_addr = socket.inet_pton(socket.AF_INET, nh_addr) -class MRoutePath(RoutePath): +class VppMRoutePath(VppRoutePath): def __init__(self, nh_sw_if_index, flags): - super(MRoutePath, self).__init__("0.0.0.0", - nh_sw_if_index) + super(VppMRoutePath, self).__init__("0.0.0.0", + nh_sw_if_index) self.nh_i_flags = flags -class IpRoute: +class VppIpRoute(VppObject): """ IP Route """ @@ -80,6 +81,7 @@ class IpRoute: path.nh_labels), next_hop_via_label=path.nh_via_label, is_ipv6=self.is_ip6) + self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): if self.is_local: @@ -101,8 +103,26 @@ class IpRoute: table_id=self.table_id, is_add=0) + def query_vpp_config(self): + dump = self._test.vapi.ip_fib_dump() + for e in dump: + if self.dest_addr == e.address \ + and self.dest_addr_len == e.address_length \ + and self.table_id == e.table_id: + return True + return False -class IpMRoute: + def __str__(self): + return self.object_id() + + def object_id(self): + return ("%d:%s/%d" + % (self.table_id, + socket.inet_ntop(socket.AF_INET, self.dest_addr), + self.dest_addr_len)) + + +class VppIpMRoute(VppObject): """ IP Multicast Route """ @@ -133,6 +153,7 @@ class IpMRoute: path.nh_i_flags, table_id=self.table_id, is_ipv6=self.is_ip6) + self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): for path in self.paths: @@ -171,8 +192,34 @@ class IpMRoute: table_id=self.table_id, is_ipv6=self.is_ip6) + def query_vpp_config(self): + dump = self._test.vapi.ip_fib_dump() + for e in dump: + if self.grp_addr == e.address \ + and self.grp_addr_len == e.address_length \ + and self.table_id == e.table_id: + return True + return False + + def __str__(self): + return self.object_id() + + def object_id(self): + if self.is_ip6: + return ("%d:(%s,%s/%d)" + % (self.table_id, + socket.inet_ntop(socket.AF_INET6, self.src_addr), + socket.inet_ntop(socket.AF_INET6, self.grp_addr), + self.grp_addr_len)) + else: + return ("%d:(%s,%s/%d)" + % (self.table_id, + socket.inet_ntop(socket.AF_INET, self.src_addr), + socket.inet_ntop(socket.AF_INET, self.grp_addr), + self.grp_addr_len)) + -class MFibSignal: +class VppMFibSignal(object): def __init__(self, test, route, interface, packet): self.route = route self.interface = interface @@ -193,21 +240,27 @@ class MFibSignal: signal.src_address[i]) -class MplsIpBind: +class VppMplsIpBind(VppObject): """ MPLS to IP Binding """ - def __init__(self, test, local_label, dest_addr, dest_addr_len): + def __init__(self, test, local_label, dest_addr, dest_addr_len, + table_id=0, ip_table_id=0): self._test = test self.dest_addr = socket.inet_pton(socket.AF_INET, dest_addr) self.dest_addr_len = dest_addr_len self.local_label = local_label + self.table_id = table_id + self.ip_table_id = ip_table_id def add_vpp_config(self): self._test.vapi.mpls_ip_bind_unbind(self.local_label, self.dest_addr, - self.dest_addr_len) + self.dest_addr_len, + table_id=self.table_id, + ip_table_id=self.ip_table_id) + self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): self._test.vapi.mpls_ip_bind_unbind(self.local_label, @@ -215,10 +268,30 @@ class MplsIpBind: self.dest_addr_len, is_bind=0) + def query_vpp_config(self): + dump = self._test.vapi.mpls_fib_dump() + for e in dump: + if self.local_label == e.label \ + and self.eos_bit == e.eos_bit \ + and self.table_id == e.table_id: + return True + return False + + def __str__(self): + return self.object_id() + + def object_id(self): + return ("%d:%s binds %d:%s/%d" + % (self.table_id, + self.local_label, + self.ip_table_id, + socket.inet_ntop(socket.AF_INET, self.dest_addr), + self.dest_addr_len)) -class MplsRoute: + +class VppMplsRoute(VppObject): """ - MPLS Route + MPLS Route/LSP """ def __init__(self, test, local_label, eos_bit, paths, table_id=0): @@ -242,6 +315,7 @@ class MplsRoute: path.nh_labels), next_hop_via_label=path.nh_via_label, next_hop_table_id=path.nh_table_id) + self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): for path in self.paths: @@ -252,3 +326,21 @@ class MplsRoute: path.nh_itf, table_id=self.table_id, is_add=0) + + def query_vpp_config(self): + dump = self._test.vapi.mpls_fib_dump() + for e in dump: + if self.local_label == e.label \ + and self.eos_bit == e.eos_bit \ + and self.table_id == e.table_id: + return True + return False + + def __str__(self): + return self.object_id() + + def object_id(self): + return ("%d:%s/%d" + % (self.table_id, + self.local_label, + 20+self.eos_bit)) diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index 7a508a44d3e..7e1a91cd707 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -721,6 +721,9 @@ class VppPapiProvider(object): 'outer_fib_id': outer_fib_id} ) + def mpls_fib_dump(self): + return self.api(self.papi.mpls_fib_dump, {}) + def mpls_route_add_del( self, label, @@ -1291,3 +1294,6 @@ class VppPapiProvider(object): def mfib_signal_dump(self): return self.api(self.papi.mfib_signal_dump, {}) + + def ip_mfib_dump(self): + return self.api(self.papi.ip_mfib_dump, {}) |